diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2012-02-23 08:14:46 -0500 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2012-03-03 07:23:38 +0100 |
commit | 286a4c5caa1945c8d1cb365a3d90fb09d5700cb2 (patch) | |
tree | 4835f46d16ec78d035ec9f49333079fe618384c1 /apps/recorder/pcm_record.c | |
parent | 3f82f3aca14eb954e55f761721ffdd2684f0e812 (diff) | |
download | rockbox-286a4c5caa1945c8d1cb365a3d90fb09d5700cb2.tar.gz rockbox-286a4c5caa1945c8d1cb365a3d90fb09d5700cb2.zip |
Revise the PCM callback system after adding multichannel audio.
Additional status callback is added to pcm_play/rec_data instead of
using a special function to set it. Status includes DMA error
reporting to the status callback. Playback and recording callback
become more alike except playback uses "const void **addr" (because
the data should not be altered) and recording uses "void **addr".
"const" is put in place throughout where appropriate.
Most changes are fairly trivial. One that should be checked in
particular because it isn't so much is telechips, if anyone cares to
bother. PP5002 is not so trivial either but that tested as working.
Change-Id: I4928d69b3b3be7fb93e259f81635232df9bd1df2
Reviewed-on: http://gerrit.rockbox.org/166
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested-by: Michael Sevakis <jethead71@rockbox.org>
Diffstat (limited to 'apps/recorder/pcm_record.c')
-rw-r--r-- | apps/recorder/pcm_record.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/apps/recorder/pcm_record.c b/apps/recorder/pcm_record.c index 90a6163b8f..d904be9a4e 100644 --- a/apps/recorder/pcm_record.c +++ b/apps/recorder/pcm_record.c | |||
@@ -257,20 +257,9 @@ enum | |||
257 | /*******************************************************************/ | 257 | /*******************************************************************/ |
258 | 258 | ||
259 | /* Callback for when more data is ready - called in interrupt context */ | 259 | /* Callback for when more data is ready - called in interrupt context */ |
260 | static void pcm_rec_have_more(int status, void **start, size_t *size) | 260 | static void pcm_rec_have_more(void **start, size_t *size) |
261 | { | 261 | { |
262 | if (status < 0) | 262 | if (!dma_lock) |
263 | { | ||
264 | /* some error condition */ | ||
265 | if (status == DMA_REC_ERROR_DMA) | ||
266 | { | ||
267 | /* Flush recorded data to disk and stop recording */ | ||
268 | queue_post(&pcmrec_queue, PCMREC_STOP, 0); | ||
269 | return; | ||
270 | } | ||
271 | /* else try again next transmission - frame is invalid */ | ||
272 | } | ||
273 | else if (!dma_lock) | ||
274 | { | 263 | { |
275 | /* advance write position */ | 264 | /* advance write position */ |
276 | int next_pos = (dma_wr_pos + PCM_CHUNK_SIZE) & PCM_CHUNK_MASK; | 265 | int next_pos = (dma_wr_pos + PCM_CHUNK_SIZE) & PCM_CHUNK_MASK; |
@@ -287,6 +276,23 @@ static void pcm_rec_have_more(int status, void **start, size_t *size) | |||
287 | *size = PCM_CHUNK_SIZE; | 276 | *size = PCM_CHUNK_SIZE; |
288 | } /* pcm_rec_have_more */ | 277 | } /* pcm_rec_have_more */ |
289 | 278 | ||
279 | static enum pcm_dma_status pcm_rec_status_callback(enum pcm_dma_status status) | ||
280 | { | ||
281 | if (status < PCM_DMAST_OK) | ||
282 | { | ||
283 | /* some error condition */ | ||
284 | if (status == PCM_DMAST_ERR_DMA) | ||
285 | { | ||
286 | /* Flush recorded data to disk and stop recording */ | ||
287 | queue_post(&pcmrec_queue, PCMREC_STOP, 0); | ||
288 | return status; | ||
289 | } | ||
290 | /* else try again next transmission - frame is invalid */ | ||
291 | } | ||
292 | |||
293 | return PCM_DMAST_OK; | ||
294 | } /* pcm_rec_status_callback */ | ||
295 | |||
290 | static void reset_hardware(void) | 296 | static void reset_hardware(void) |
291 | { | 297 | { |
292 | /* reset pcm to defaults */ | 298 | /* reset pcm to defaults */ |
@@ -1239,8 +1245,8 @@ static void pcmrec_set_recording_options( | |||
1239 | { | 1245 | { |
1240 | /* start DMA transfer */ | 1246 | /* start DMA transfer */ |
1241 | dma_lock = pre_record_ticks == 0; | 1247 | dma_lock = pre_record_ticks == 0; |
1242 | pcm_record_data(pcm_rec_have_more, GET_PCM_CHUNK(dma_wr_pos), | 1248 | pcm_record_data(pcm_rec_have_more, pcm_rec_status_callback, |
1243 | PCM_CHUNK_SIZE); | 1249 | GET_PCM_CHUNK(dma_wr_pos), PCM_CHUNK_SIZE); |
1244 | } | 1250 | } |
1245 | else | 1251 | else |
1246 | { | 1252 | { |