summaryrefslogtreecommitdiffstats
path: root/firmware/pcm_mixer.c
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 /firmware/pcm_mixer.c
parent565a4b5baadad431e63ec183a2eaea6564346940 (diff)
downloadrockbox-39eec730b055a21d284c73095cbc42c4e4f56787.tar.gz
rockbox-39eec730b055a21d284c73095cbc42c4e4f56787.tar.bz2
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
Diffstat (limited to 'firmware/pcm_mixer.c')
-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)
pcm_play_data(mixer_pcm_callback, start, MIX_FRAME_SIZE);
}
-/* Initialize the channel and start it if it has data */
-static void mixer_channel_play_start(struct mixer_channel *chan,
- pcm_play_callback_type get_more,
- unsigned char *start, size_t size)
+/** Public interfaces **/
+
+/* Start playback on a channel */
+void mixer_channel_play_data(enum pcm_mixer_channel channel,
+ pcm_play_callback_type get_more,
+ unsigned char *start, size_t size)
{
- pcm_play_unlock(); /* Allow playback while doing any callback */
+ struct mixer_channel *chan = &channels[channel];
ALIGN_AUDIOBUF(start, size);
- if (!(start && size))
+ if (!(start && size) && get_more)
{
/* Initial buffer not passed - call the callback now */
+ pcm_play_lock();
+ mixer_deactivate_channel(chan); /* Protect chan struct if active */
+ pcm_play_unlock(); /* Allow playback while doing callback */
+
size = 0;
- if (get_more)
- {
- get_more(&start, &size);
- ALIGN_AUDIOBUF(start, size);
- }
+ get_more(&start, &size);
+ ALIGN_AUDIOBUF(start, size);
}
+ pcm_play_lock();
+
if (start && size)
{
/* We have data - start the channel */
@@ -285,31 +290,15 @@ static void mixer_channel_play_start(struct mixer_channel *chan,
chan->last_size = 0;
chan->get_more = get_more;
- pcm_play_lock();
mixer_activate_channel(chan);
mixer_start_pcm();
}
else
{
/* Never had anything - stop it now */
- pcm_play_lock();
channel_stopped(chan);
}
-}
-
-
-/** Public interfaces **/
-
-/* Start playback on a channel */
-void mixer_channel_play_data(enum pcm_mixer_channel channel,
- pcm_play_callback_type get_more,
- unsigned char *start, size_t size)
-{
- struct mixer_channel *chan = &channels[channel];
- pcm_play_lock();
- mixer_deactivate_channel(chan);
- mixer_channel_play_start(chan, get_more, start, size);
pcm_play_unlock();
}