From a2b6703a369f6cdbfec1f150c408dadc877631fb Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Wed, 29 Jun 2011 06:37:04 +0000 Subject: Commit FS#12150 - Fully-functional audio mixer - and finally whip old limitations about playback of voice and other sounds when paused. Channels are independent in state and amplitude. Fade on stop/pause is handled by the channel's volume control rather than global volume which means it now works from anywhere. Opens up the possibility of plugin sounds during music playback by merely adding an additional channel enum. If any PCM drivers were not properly modified, see one of the last comments in the task for a description of the simple change that is expected. Some params are tunable in firmware/export/pcm-mixer.h as well. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30097 a1c6a512-1295-4272-9138-f99709370657 --- apps/playback.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'apps/playback.c') diff --git a/apps/playback.c b/apps/playback.c index 2775e8a95b..cbb94a9d22 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -39,6 +39,7 @@ #include "abrepeat.h" #include "pcmbuf.h" #include "playback.h" +#include "misc.h" #ifdef HAVE_TAGCACHE #include "tagcache.h" @@ -2360,6 +2361,9 @@ static void audio_start_playback(size_t offset, unsigned int flags) #ifndef PLATFORM_HAS_VOLUME_CHANGE sound_set_volume(global_settings.volume); #endif + /* Be sure channel is audible */ + pcmbuf_fade(false, true); + /* Update our state */ play_status = PLAY_PLAYING; } @@ -2413,6 +2417,8 @@ static void audio_stop_playback(void) if (play_status == PLAY_STOPPED) return; + pcmbuf_fade(global_settings.fade_on_stop, false); + /* Stop the codec and unload it */ halt_decoding_track(true); pcmbuf_play_stop(); @@ -2452,6 +2458,11 @@ static void audio_on_pause(bool pause) if (play_status == PLAY_STOPPED || pause == (play_status == PLAY_PAUSED)) return; + bool const do_fade = global_settings.fade_on_stop; + + if (pause) + pcmbuf_fade(do_fade, false); + if (!ff_rw_mode) { /* Not in ff/rw mode - may set the state (otherwise this could make @@ -2459,6 +2470,9 @@ static void audio_on_pause(bool pause) pcmbuf_pause(pause); } + if (!pause) + pcmbuf_fade(do_fade, true); + play_status = pause ? PLAY_PAUSED : PLAY_PLAYING; if (!pause && codec_skip_pending) @@ -3170,7 +3184,7 @@ void audio_pcmbuf_track_change(bool pcmbuf) /* May pcmbuf start PCM playback when the buffer is full enough? */ bool audio_pcmbuf_may_play(void) { - return play_status != PLAY_PAUSED && !ff_rw_mode; + return play_status == PLAY_PLAYING && !ff_rw_mode; } @@ -3339,7 +3353,7 @@ void audio_skip(int offset) skip_offset = accum; if (global_settings.beep) - pcmbuf_beep(2000, 100, 2500*global_settings.beep); + beep_play(2000, 100, 2500*global_settings.beep); LOGFQUEUE("audio > audio Q_AUDIO_SKIP %d", offset); @@ -3360,7 +3374,7 @@ void audio_skip(int offset) { /* No more tracks */ if (global_settings.beep) - pcmbuf_beep(1000, 100, 1500*global_settings.beep); + beep_play(1000, 100, 1500*global_settings.beep); } id3_mutex_unlock(); -- cgit v1.2.3