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/voice_thread.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'apps/voice_thread.c') diff --git a/apps/voice_thread.c b/apps/voice_thread.c index 2f216cde9d..5d23a74cbc 100644 --- a/apps/voice_thread.c +++ b/apps/voice_thread.c @@ -116,9 +116,12 @@ enum voice_thread_messages /* Structure to store clip data callback info */ struct voice_info { - pcm_play_callback_type get_more; /* Callback to get more clips */ - unsigned char *start; /* Start of clip */ - size_t size; /* Size of clip */ + /* Callback to get more clips */ + void (*get_more)(unsigned char** start, size_t* size); + /* Start of clip */ + unsigned char *start; + /* Size of clip */ + size_t size; }; /* Private thread data for its current state that must be passed to its @@ -148,14 +151,14 @@ static inline int voice_unplayed_frames(void) } /* Mixer channel callback */ -static void voice_pcm_callback(unsigned char **start, size_t *size) +static void voice_pcm_callback(const void **start, size_t *size) { if (voice_unplayed_frames() == 0) return; /* Done! */ unsigned int i = ++cur_buf_out % VOICE_FRAMES; - *start = (unsigned char *)voicebuf[i]; + *start = voicebuf[i]; *size = voicebuf_sizes[i]; } @@ -167,7 +170,7 @@ static void voice_start_playback(void) unsigned int i = cur_buf_out % VOICE_FRAMES; mixer_channel_play_data(PCM_MIXER_CHAN_VOICE, voice_pcm_callback, - (unsigned char *)voicebuf[i], voicebuf_sizes[i]); + voicebuf[i], voicebuf_sizes[i]); } /* Stop the voice channel */ @@ -198,7 +201,7 @@ static void voice_buf_commit(size_t size) /* Stop any current clip and start playing a new one */ void mp3_play_data(const unsigned char* start, int size, - pcm_play_callback_type get_more) + void (*get_more)(unsigned char** start, size_t* size)) { if (get_more != NULL && start != NULL && (ssize_t)size > 0) { -- cgit v1.2.3