summaryrefslogtreecommitdiff
path: root/apps/playback.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-06-29 06:37:04 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-06-29 06:37:04 +0000
commita2b6703a369f6cdbfec1f150c408dadc877631fb (patch)
tree3145a8c1372c44711d38feefeba39c7d4098f139 /apps/playback.c
parent8411614b8a068a4f274c3841aa55aab1df1bc246 (diff)
downloadrockbox-a2b6703a369f6cdbfec1f150c408dadc877631fb.tar.gz
rockbox-a2b6703a369f6cdbfec1f150c408dadc877631fb.zip
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
Diffstat (limited to 'apps/playback.c')
-rw-r--r--apps/playback.c20
1 files changed, 17 insertions, 3 deletions
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 @@
39#include "abrepeat.h" 39#include "abrepeat.h"
40#include "pcmbuf.h" 40#include "pcmbuf.h"
41#include "playback.h" 41#include "playback.h"
42#include "misc.h"
42 43
43#ifdef HAVE_TAGCACHE 44#ifdef HAVE_TAGCACHE
44#include "tagcache.h" 45#include "tagcache.h"
@@ -2360,6 +2361,9 @@ static void audio_start_playback(size_t offset, unsigned int flags)
2360#ifndef PLATFORM_HAS_VOLUME_CHANGE 2361#ifndef PLATFORM_HAS_VOLUME_CHANGE
2361 sound_set_volume(global_settings.volume); 2362 sound_set_volume(global_settings.volume);
2362#endif 2363#endif
2364 /* Be sure channel is audible */
2365 pcmbuf_fade(false, true);
2366
2363 /* Update our state */ 2367 /* Update our state */
2364 play_status = PLAY_PLAYING; 2368 play_status = PLAY_PLAYING;
2365 } 2369 }
@@ -2413,6 +2417,8 @@ static void audio_stop_playback(void)
2413 if (play_status == PLAY_STOPPED) 2417 if (play_status == PLAY_STOPPED)
2414 return; 2418 return;
2415 2419
2420 pcmbuf_fade(global_settings.fade_on_stop, false);
2421
2416 /* Stop the codec and unload it */ 2422 /* Stop the codec and unload it */
2417 halt_decoding_track(true); 2423 halt_decoding_track(true);
2418 pcmbuf_play_stop(); 2424 pcmbuf_play_stop();
@@ -2452,6 +2458,11 @@ static void audio_on_pause(bool pause)
2452 if (play_status == PLAY_STOPPED || pause == (play_status == PLAY_PAUSED)) 2458 if (play_status == PLAY_STOPPED || pause == (play_status == PLAY_PAUSED))
2453 return; 2459 return;
2454 2460
2461 bool const do_fade = global_settings.fade_on_stop;
2462
2463 if (pause)
2464 pcmbuf_fade(do_fade, false);
2465
2455 if (!ff_rw_mode) 2466 if (!ff_rw_mode)
2456 { 2467 {
2457 /* Not in ff/rw mode - may set the state (otherwise this could make 2468 /* Not in ff/rw mode - may set the state (otherwise this could make
@@ -2459,6 +2470,9 @@ static void audio_on_pause(bool pause)
2459 pcmbuf_pause(pause); 2470 pcmbuf_pause(pause);
2460 } 2471 }
2461 2472
2473 if (!pause)
2474 pcmbuf_fade(do_fade, true);
2475
2462 play_status = pause ? PLAY_PAUSED : PLAY_PLAYING; 2476 play_status = pause ? PLAY_PAUSED : PLAY_PLAYING;
2463 2477
2464 if (!pause && codec_skip_pending) 2478 if (!pause && codec_skip_pending)
@@ -3170,7 +3184,7 @@ void audio_pcmbuf_track_change(bool pcmbuf)
3170/* May pcmbuf start PCM playback when the buffer is full enough? */ 3184/* May pcmbuf start PCM playback when the buffer is full enough? */
3171bool audio_pcmbuf_may_play(void) 3185bool audio_pcmbuf_may_play(void)
3172{ 3186{
3173 return play_status != PLAY_PAUSED && !ff_rw_mode; 3187 return play_status == PLAY_PLAYING && !ff_rw_mode;
3174} 3188}
3175 3189
3176 3190
@@ -3339,7 +3353,7 @@ void audio_skip(int offset)
3339 skip_offset = accum; 3353 skip_offset = accum;
3340 3354
3341 if (global_settings.beep) 3355 if (global_settings.beep)
3342 pcmbuf_beep(2000, 100, 2500*global_settings.beep); 3356 beep_play(2000, 100, 2500*global_settings.beep);
3343 3357
3344 LOGFQUEUE("audio > audio Q_AUDIO_SKIP %d", offset); 3358 LOGFQUEUE("audio > audio Q_AUDIO_SKIP %d", offset);
3345 3359
@@ -3360,7 +3374,7 @@ void audio_skip(int offset)
3360 { 3374 {
3361 /* No more tracks */ 3375 /* No more tracks */
3362 if (global_settings.beep) 3376 if (global_settings.beep)
3363 pcmbuf_beep(1000, 100, 1500*global_settings.beep); 3377 beep_play(1000, 100, 1500*global_settings.beep);
3364 } 3378 }
3365 3379
3366 id3_mutex_unlock(); 3380 id3_mutex_unlock();