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/voice_thread.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/voice_thread.c')
-rw-r--r-- | apps/voice_thread.c | 17 |
1 files changed, 10 insertions, 7 deletions
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 | |||
116 | /* Structure to store clip data callback info */ | 116 | /* Structure to store clip data callback info */ |
117 | struct voice_info | 117 | struct voice_info |
118 | { | 118 | { |
119 | pcm_play_callback_type get_more; /* Callback to get more clips */ | 119 | /* Callback to get more clips */ |
120 | unsigned char *start; /* Start of clip */ | 120 | void (*get_more)(unsigned char** start, size_t* size); |
121 | size_t size; /* Size of clip */ | 121 | /* Start of clip */ |
122 | unsigned char *start; | ||
123 | /* Size of clip */ | ||
124 | size_t size; | ||
122 | }; | 125 | }; |
123 | 126 | ||
124 | /* Private thread data for its current state that must be passed to its | 127 | /* Private thread data for its current state that must be passed to its |
@@ -148,14 +151,14 @@ static inline int voice_unplayed_frames(void) | |||
148 | } | 151 | } |
149 | 152 | ||
150 | /* Mixer channel callback */ | 153 | /* Mixer channel callback */ |
151 | static void voice_pcm_callback(unsigned char **start, size_t *size) | 154 | static void voice_pcm_callback(const void **start, size_t *size) |
152 | { | 155 | { |
153 | if (voice_unplayed_frames() == 0) | 156 | if (voice_unplayed_frames() == 0) |
154 | return; /* Done! */ | 157 | return; /* Done! */ |
155 | 158 | ||
156 | unsigned int i = ++cur_buf_out % VOICE_FRAMES; | 159 | unsigned int i = ++cur_buf_out % VOICE_FRAMES; |
157 | 160 | ||
158 | *start = (unsigned char *)voicebuf[i]; | 161 | *start = voicebuf[i]; |
159 | *size = voicebuf_sizes[i]; | 162 | *size = voicebuf_sizes[i]; |
160 | } | 163 | } |
161 | 164 | ||
@@ -167,7 +170,7 @@ static void voice_start_playback(void) | |||
167 | 170 | ||
168 | unsigned int i = cur_buf_out % VOICE_FRAMES; | 171 | unsigned int i = cur_buf_out % VOICE_FRAMES; |
169 | mixer_channel_play_data(PCM_MIXER_CHAN_VOICE, voice_pcm_callback, | 172 | mixer_channel_play_data(PCM_MIXER_CHAN_VOICE, voice_pcm_callback, |
170 | (unsigned char *)voicebuf[i], voicebuf_sizes[i]); | 173 | voicebuf[i], voicebuf_sizes[i]); |
171 | } | 174 | } |
172 | 175 | ||
173 | /* Stop the voice channel */ | 176 | /* Stop the voice channel */ |
@@ -198,7 +201,7 @@ static void voice_buf_commit(size_t size) | |||
198 | 201 | ||
199 | /* Stop any current clip and start playing a new one */ | 202 | /* Stop any current clip and start playing a new one */ |
200 | void mp3_play_data(const unsigned char* start, int size, | 203 | void mp3_play_data(const unsigned char* start, int size, |
201 | pcm_play_callback_type get_more) | 204 | void (*get_more)(unsigned char** start, size_t* size)) |
202 | { | 205 | { |
203 | if (get_more != NULL && start != NULL && (ssize_t)size > 0) | 206 | if (get_more != NULL && start != NULL && (ssize_t)size > 0) |
204 | { | 207 | { |