diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2013-06-22 16:41:16 -0400 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2013-06-30 00:40:27 +0200 |
commit | 488813197292bd1db8d533d7b42c38852971c2e8 (patch) | |
tree | 07ea7247799b1b6b487c5ca73311380fc947700e /apps/recorder/pcm_record.h | |
parent | a9ea1a42695401334717f2e497a7f5576d87691d (diff) | |
download | rockbox-488813197292bd1db8d533d7b42c38852971c2e8.tar.gz rockbox-488813197292bd1db8d533d7b42c38852971c2e8.zip |
Update software recording engine to latest codec interface.
Basically, just give it a good rewrite.
Software codec recording can be implemented in a more straightforward
and simple manner and made more robust through the better codec
control now available.
Encoded audio buffer uses a packed format instead of fixed-size
chunks and uses smaller data headers leading to more efficient usage.
The greatest benefit is with a VBR format like wavpack which needs
to request a maximum size but only actually ends up committing part
of that request.
No guard buffers are used for either PCM or encoded audio. PCM is
read into the codec's provided buffer and mono conversion done at
that time in the core if required. Any highly-specialized sample
conversion is still done within the codec itself, such as 32-bit
(wavpack) or interleaved mono (mp3).
There is no longer a separate filename array. All metadata goes
onto the main encoded audio buffer, eliminating any predermined
file limit on the buffer as well as not wasting the space for
unused path queue slots.
The core and codec interface is less awkward and a bit more sensible.
Some less useful interface features were removed. Threads are kept
on narrow code paths ie. the audio thread never calls encoding
functions and the codec thread never calls file functions as before.
Codecs no longer call file functions directly. Writes are buffered
in the core and data written to storage in larger chunks to speed up
flushing of data. In fact, codecs are no longer aware of the stream
being a file at all and have no access to the fd.
SPDIF frequency detection no longer requires a restart of recording
or plugging the source before entering the screen. It will poll
for changes and update when stopped or prerecording (which does
discard now-invalid prerecorded data).
I've seen to it that writing a proper header on full disk works
when the format makes it reasonably practical to do so. Other cases
may have incorrect data sizes but sample info will be in tact. File
left that way may play anyway.
mp3_enc.codec acquires the ability to write 'Info' headers with LAME
tags to make it gapless (bonus).
Change-Id: I670685166d5eb32ef58ef317f50b8af766ceb653
Reviewed-on: http://gerrit.rockbox.org/493
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested-by: Michael Sevakis <jethead71@rockbox.org>
Diffstat (limited to 'apps/recorder/pcm_record.h')
-rw-r--r-- | apps/recorder/pcm_record.h | 74 |
1 files changed, 46 insertions, 28 deletions
diff --git a/apps/recorder/pcm_record.h b/apps/recorder/pcm_record.h index bff7881605..cf7197946a 100644 --- a/apps/recorder/pcm_record.h +++ b/apps/recorder/pcm_record.h | |||
@@ -8,6 +8,7 @@ | |||
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2005 by Linus Nielsen Feltzing | 10 | * Copyright (C) 2005 by Linus Nielsen Feltzing |
11 | * Copyright (C) 2006-2013 by Michael Sevakis | ||
11 | * | 12 | * |
12 | * This program is free software; you can redistribute it and/or | 13 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 14 | * modify it under the terms of the GNU General Public License |
@@ -18,47 +19,64 @@ | |||
18 | * KIND, either express or implied. | 19 | * KIND, either express or implied. |
19 | * | 20 | * |
20 | ****************************************************************************/ | 21 | ****************************************************************************/ |
21 | |||
22 | #ifndef PCM_RECORD_H | 22 | #ifndef PCM_RECORD_H |
23 | #define PCM_RECORD_H | 23 | #define PCM_RECORD_H |
24 | 24 | ||
25 | #include "config.h" | 25 | /** Warnings (recording may continue with possible data loss) |
26 | ** Reset of recording clears, otherwise see notes below | ||
27 | */ | ||
26 | 28 | ||
27 | /** Warnings **/ | 29 | /* PCM buffer has overflowed; PCM samples were dropped */ |
28 | /* pcm (dma) buffer has overflowed */ | 30 | /* persists until: stop, new file, clear */ |
29 | #define PCMREC_W_PCM_BUFFER_OVF 0x00000001 | 31 | #define PCMREC_W_PCM_BUFFER_OVF 0x00000001 |
30 | /* encoder output buffer has overflowed */ | 32 | /* encoder output buffer has overflowed; encoded data was dropped */ |
33 | /* persists until: stop, new file, clear */ | ||
31 | #define PCMREC_W_ENC_BUFFER_OVF 0x00000002 | 34 | #define PCMREC_W_ENC_BUFFER_OVF 0x00000002 |
32 | /** Errors **/ | 35 | /* encoder and set/detected sample rates do not match */ |
36 | /* persists until: rates match, clear */ | ||
37 | #define PCMREC_W_SAMPR_MISMATCH 0x00000004 | ||
38 | /* PCM frame skipped because of recoverable DMA error */ | ||
39 | /* persists until: clear */ | ||
40 | #define PCMREC_W_DMA 0x00000008 | ||
41 | /* internal file size limit was reached; encoded data was dropped */ | ||
42 | /* persists until: stop, new file, clear */ | ||
43 | #define PCMREC_W_FILE_SIZE 0x00000010 | ||
44 | |||
45 | /* all warning flags */ | ||
46 | #define PCMREC_W_ALL 0x0000001f | ||
47 | |||
48 | /** Errors (recording should be reset) | ||
49 | ** | ||
50 | ** Stopping recording if recording clears internally and externally visible | ||
51 | ** status must be cleared with audio_error_clear() | ||
52 | ** reset of recording clears | ||
53 | */ | ||
54 | |||
55 | /* DMA callback has reported an error */ | ||
56 | #define PCMREC_E_DMA 0x80010000 | ||
33 | /* failed to load encoder */ | 57 | /* failed to load encoder */ |
34 | #define PCMREC_E_LOAD_ENCODER 0x80001000 | 58 | #define PCMREC_E_LOAD_ENCODER 0x80020000 |
35 | /* error originating in encoder */ | 59 | /* error originating in encoder */ |
36 | #define PCMREC_E_ENCODER 0x80002000 | 60 | #define PCMREC_E_ENCODER 0x80040000 |
37 | /* filename queue has desynced from stream markers */ | 61 | /* error from encoder setup of stream parameters */ |
38 | #define PCMREC_E_FNQ_DESYNC 0x80004000 | 62 | #define PCMREC_E_ENC_SETUP 0x80080000 |
63 | /* error writing to output stream */ | ||
64 | #define PCMREC_E_ENCODER_STREAM 0x80100000 | ||
39 | /* I/O error has occurred */ | 65 | /* I/O error has occurred */ |
40 | #define PCMREC_E_IO 0x80008000 | 66 | #define PCMREC_E_IO 0x80200000 |
41 | #ifdef DEBUG | ||
42 | /* encoder has written past end of allocated space */ | ||
43 | #define PCMREC_E_CHUNK_OVF 0x80010000 | ||
44 | #endif /* DEBUG */ | ||
45 | /* DMA callback has reported an error */ | ||
46 | #define PCMREC_E_DMA 0x80020000 | ||
47 | 67 | ||
48 | /** General functions for high level codec recording **/ | 68 | /* all error flags */ |
49 | /* pcm_rec_error_clear is deprecated for general use. audio_error_clear | 69 | #define PCMREC_E_ALL 0x803f0000 |
50 | should be used */ | 70 | |
71 | /* Functions called by audio_thread.c */ | ||
51 | void pcm_rec_error_clear(void); | 72 | void pcm_rec_error_clear(void); |
52 | /* pcm_rec_status is deprecated for general use. audio_status merges the | ||
53 | results for consistency with the hardware codec version */ | ||
54 | unsigned int pcm_rec_status(void); | 73 | unsigned int pcm_rec_status(void); |
55 | unsigned long pcm_rec_get_warnings(void); | 74 | uint32_t pcm_rec_get_warnings(void); |
56 | void pcm_rec_init(void) INIT_ATTR; | 75 | #ifdef HAVE_SPDIF_IN |
57 | int pcm_rec_current_bitrate(void); | ||
58 | int pcm_rec_encoder_afmt(void); /* AFMT_* value, AFMT_UNKNOWN if none */ | ||
59 | int pcm_rec_rec_format(void); /* Format index or -1 otherwise */ | ||
60 | unsigned long pcm_rec_sample_rate(void); | 76 | unsigned long pcm_rec_sample_rate(void); |
61 | int pcm_get_num_unprocessed(void); | 77 | #endif |
78 | |||
79 | void recording_init(void); | ||
62 | 80 | ||
63 | /* audio.h contains audio_* recording functions */ | 81 | /* audio.h contains audio_* recording functions */ |
64 | 82 | ||