summaryrefslogtreecommitdiff
path: root/apps/audio_thread.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2013-06-22 16:41:16 -0400
committerMichael Sevakis <jethead71@rockbox.org>2013-06-30 00:40:27 +0200
commit488813197292bd1db8d533d7b42c38852971c2e8 (patch)
tree07ea7247799b1b6b487c5ca73311380fc947700e /apps/audio_thread.c
parenta9ea1a42695401334717f2e497a7f5576d87691d (diff)
downloadrockbox-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/audio_thread.c')
-rw-r--r--apps/audio_thread.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/apps/audio_thread.c b/apps/audio_thread.c
index 397d8b0946..bbf73470d2 100644
--- a/apps/audio_thread.c
+++ b/apps/audio_thread.c
@@ -108,6 +108,16 @@ static void NORETURN_ATTR audio_thread(void)
108 } 108 }
109} 109}
110 110
111void audio_queue_post(long id, intptr_t data)
112{
113 queue_post(&audio_queue, id, data);
114}
115
116intptr_t audio_queue_send(long id, intptr_t data)
117{
118 return queue_send(&audio_queue, id, data);
119}
120
111/* Return the playback and recording status */ 121/* Return the playback and recording status */
112int audio_status(void) 122int audio_status(void)
113{ 123{
@@ -156,7 +166,9 @@ void audio_init(void)
156 audio_thread_id); 166 audio_thread_id);
157 167
158 playback_init(); 168 playback_init();
159 /* Recording doesn't need init call */ 169#ifdef AUDIO_HAVE_RECORDING
170 recording_init();
171#endif
160 172
161 /* ...now...audio_reset_buffer must know the size of voicefile buffer so 173 /* ...now...audio_reset_buffer must know the size of voicefile buffer so
162 init talk first which will init the buffers */ 174 init talk first which will init the buffers */