From 286a4c5caa1945c8d1cb365a3d90fb09d5700cb2 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Thu, 23 Feb 2012 08:14:46 -0500 Subject: 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 Tested-by: Michael Sevakis --- apps/recorder/pcm_record.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'apps/recorder') 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 /*******************************************************************/ /* Callback for when more data is ready - called in interrupt context */ -static void pcm_rec_have_more(int status, void **start, size_t *size) +static void pcm_rec_have_more(void **start, size_t *size) { - if (status < 0) - { - /* some error condition */ - if (status == DMA_REC_ERROR_DMA) - { - /* Flush recorded data to disk and stop recording */ - queue_post(&pcmrec_queue, PCMREC_STOP, 0); - return; - } - /* else try again next transmission - frame is invalid */ - } - else if (!dma_lock) + if (!dma_lock) { /* advance write position */ 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) *size = PCM_CHUNK_SIZE; } /* pcm_rec_have_more */ +static enum pcm_dma_status pcm_rec_status_callback(enum pcm_dma_status status) +{ + if (status < PCM_DMAST_OK) + { + /* some error condition */ + if (status == PCM_DMAST_ERR_DMA) + { + /* Flush recorded data to disk and stop recording */ + queue_post(&pcmrec_queue, PCMREC_STOP, 0); + return status; + } + /* else try again next transmission - frame is invalid */ + } + + return PCM_DMAST_OK; +} /* pcm_rec_status_callback */ + static void reset_hardware(void) { /* reset pcm to defaults */ @@ -1239,8 +1245,8 @@ static void pcmrec_set_recording_options( { /* start DMA transfer */ dma_lock = pre_record_ticks == 0; - pcm_record_data(pcm_rec_have_more, GET_PCM_CHUNK(dma_wr_pos), - PCM_CHUNK_SIZE); + pcm_record_data(pcm_rec_have_more, pcm_rec_status_callback, + GET_PCM_CHUNK(dma_wr_pos), PCM_CHUNK_SIZE); } else { -- cgit v1.2.3