summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2012-02-17 03:54:45 -0500
committerMichael Sevakis <jethead71@rockbox.org>2012-02-17 03:54:45 -0500
commit39eec730b055a21d284c73095cbc42c4e4f56787 (patch)
tree617a3f9ba95f49d6504a27e79fb7f3112e00d62a
parent565a4b5baadad431e63ec183a2eaea6564346940 (diff)
downloadrockbox-39eec730b055a21d284c73095cbc42c4e4f56787.tar.gz
rockbox-39eec730b055a21d284c73095cbc42c4e4f56787.zip
PCM mixer: Simplify mixer_channel_play_data.
Streamline it to do fewer PCM lock calls in the case of having a prepared buffer. Change-Id: I7fca2b95cc5da314ae257522bb6f1ad7aec6634a
-rw-r--r--firmware/pcm_mixer.c43
1 files changed, 16 insertions, 27 deletions
diff --git a/firmware/pcm_mixer.c b/firmware/pcm_mixer.c
index 0038b0f5e7..fcd9a1c4fd 100644
--- a/firmware/pcm_mixer.c
+++ b/firmware/pcm_mixer.c
@@ -256,26 +256,31 @@ static void mixer_start_pcm(void)
256 pcm_play_data(mixer_pcm_callback, start, MIX_FRAME_SIZE); 256 pcm_play_data(mixer_pcm_callback, start, MIX_FRAME_SIZE);
257} 257}
258 258
259/* Initialize the channel and start it if it has data */ 259/** Public interfaces **/
260static void mixer_channel_play_start(struct mixer_channel *chan, 260
261 pcm_play_callback_type get_more, 261/* Start playback on a channel */
262 unsigned char *start, size_t size) 262void mixer_channel_play_data(enum pcm_mixer_channel channel,
263 pcm_play_callback_type get_more,
264 unsigned char *start, size_t size)
263{ 265{
264 pcm_play_unlock(); /* Allow playback while doing any callback */ 266 struct mixer_channel *chan = &channels[channel];
265 267
266 ALIGN_AUDIOBUF(start, size); 268 ALIGN_AUDIOBUF(start, size);
267 269
268 if (!(start && size)) 270 if (!(start && size) && get_more)
269 { 271 {
270 /* Initial buffer not passed - call the callback now */ 272 /* Initial buffer not passed - call the callback now */
273 pcm_play_lock();
274 mixer_deactivate_channel(chan); /* Protect chan struct if active */
275 pcm_play_unlock(); /* Allow playback while doing callback */
276
271 size = 0; 277 size = 0;
272 if (get_more) 278 get_more(&start, &size);
273 { 279 ALIGN_AUDIOBUF(start, size);
274 get_more(&start, &size);
275 ALIGN_AUDIOBUF(start, size);
276 }
277 } 280 }
278 281
282 pcm_play_lock();
283
279 if (start && size) 284 if (start && size)
280 { 285 {
281 /* We have data - start the channel */ 286 /* We have data - start the channel */
@@ -285,31 +290,15 @@ static void mixer_channel_play_start(struct mixer_channel *chan,
285 chan->last_size = 0; 290 chan->last_size = 0;
286 chan->get_more = get_more; 291 chan->get_more = get_more;
287 292
288 pcm_play_lock();
289 mixer_activate_channel(chan); 293 mixer_activate_channel(chan);
290 mixer_start_pcm(); 294 mixer_start_pcm();
291 } 295 }
292 else 296 else
293 { 297 {
294 /* Never had anything - stop it now */ 298 /* Never had anything - stop it now */
295 pcm_play_lock();
296 channel_stopped(chan); 299 channel_stopped(chan);
297 } 300 }
298}
299
300
301/** Public interfaces **/
302
303/* Start playback on a channel */
304void mixer_channel_play_data(enum pcm_mixer_channel channel,
305 pcm_play_callback_type get_more,
306 unsigned char *start, size_t size)
307{
308 struct mixer_channel *chan = &channels[channel];
309 301
310 pcm_play_lock();
311 mixer_deactivate_channel(chan);
312 mixer_channel_play_start(chan, get_more, start, size);
313 pcm_play_unlock(); 302 pcm_play_unlock();
314} 303}
315 304