diff options
author | Jens Arnold <amiconn@rockbox.org> | 2005-05-13 00:16:14 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2005-05-13 00:16:14 +0000 |
commit | 03d08ecc250ee095f46a77848bde28f162493276 (patch) | |
tree | 2076b2d4ce8551be8ae47fcfb577250bb16cdca8 | |
parent | 61aa15969cce7a40ecac5243998ffe05129502b0 (diff) | |
download | rockbox-03d08ecc250ee095f46a77848bde28f162493276.tar.gz rockbox-03d08ecc250ee095f46a77848bde28f162493276.zip |
(1) Wait for the MAS to run out of buffered data on fade out. Fixes bug #778930/#1189756. (2) Fade in/out from/to zero. (3) Always fade in 30 steps, independent of the global volume.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6463 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/wps.c | 27 | ||||
-rw-r--r-- | firmware/export/mp3_playback.h | 1 | ||||
-rw-r--r-- | firmware/mp3_playback.c | 13 |
3 files changed, 30 insertions, 11 deletions
diff --git a/apps/wps.c b/apps/wps.c index e281131836..097c908ca8 100644 --- a/apps/wps.c +++ b/apps/wps.c | |||
@@ -384,34 +384,39 @@ static bool update(void) | |||
384 | 384 | ||
385 | static void fade(bool fade_in) | 385 | static void fade(bool fade_in) |
386 | { | 386 | { |
387 | unsigned fp_global_vol = global_settings.volume << 8; | ||
388 | unsigned fp_step = fp_global_vol / 30; | ||
389 | |||
387 | if (fade_in) { | 390 | if (fade_in) { |
388 | /* fade in */ | 391 | /* fade in */ |
389 | int current_volume = 20; | 392 | unsigned fp_volume = 0; |
390 | 393 | ||
391 | /* zero out the sound */ | 394 | /* zero out the sound */ |
392 | sound_set(SOUND_VOLUME, current_volume); | 395 | sound_set(SOUND_VOLUME, 0); |
393 | 396 | ||
394 | sleep(HZ/10); /* let audio thread run */ | 397 | sleep(HZ/10); /* let audio thread run */ |
395 | audio_resume(); | 398 | audio_resume(); |
396 | 399 | ||
397 | while (current_volume < global_settings.volume) { | 400 | while (fp_volume < fp_global_vol) { |
398 | current_volume += 2; | 401 | fp_volume += fp_step; |
399 | sleep(1); | 402 | sleep(1); |
400 | sound_set(SOUND_VOLUME, current_volume); | 403 | sound_set(SOUND_VOLUME, fp_volume >> 8); |
401 | } | 404 | } |
402 | sound_set(SOUND_VOLUME, global_settings.volume); | 405 | sound_set(SOUND_VOLUME, global_settings.volume); |
403 | } | 406 | } |
404 | else { | 407 | else { |
405 | /* fade out */ | 408 | /* fade out */ |
406 | int current_volume = global_settings.volume; | 409 | unsigned fp_volume = fp_global_vol; |
407 | 410 | ||
408 | while (current_volume > 20) { | 411 | while (fp_volume > fp_step) { |
409 | current_volume -= 2; | 412 | fp_volume -= fp_step; |
410 | sleep(1); | 413 | sleep(1); |
411 | sound_set(SOUND_VOLUME, current_volume); | 414 | sound_set(SOUND_VOLUME, fp_volume >> 8); |
412 | } | 415 | } |
413 | audio_pause(); | 416 | audio_pause(); |
414 | sleep(HZ/5); /* let audio thread run */ | 417 | /* let audio thread run and wait for the mas to run out of data */ |
418 | while (!mp3_pause_done()) | ||
419 | sleep(HZ/10); | ||
415 | 420 | ||
416 | /* reset volume to what it was before the fade */ | 421 | /* reset volume to what it was before the fade */ |
417 | sound_set(SOUND_VOLUME, global_settings.volume); | 422 | sound_set(SOUND_VOLUME, global_settings.volume); |
diff --git a/firmware/export/mp3_playback.h b/firmware/export/mp3_playback.h index 4da1ffce6d..3611c1c9c1 100644 --- a/firmware/export/mp3_playback.h +++ b/firmware/export/mp3_playback.h | |||
@@ -42,6 +42,7 @@ void mp3_play_data(const unsigned char* start, int size, | |||
42 | void (*get_more)(unsigned char** start, int* size) /* callback fn */ | 42 | void (*get_more)(unsigned char** start, int* size) /* callback fn */ |
43 | ); | 43 | ); |
44 | void mp3_play_pause(bool play); | 44 | void mp3_play_pause(bool play); |
45 | bool mp3_pause_done(void); | ||
45 | void mp3_play_stop(void); | 46 | void mp3_play_stop(void); |
46 | long mp3_get_playtime(void); | 47 | long mp3_get_playtime(void); |
47 | void mp3_reset_playtime(void); | 48 | void mp3_reset_playtime(void); |
diff --git a/firmware/mp3_playback.c b/firmware/mp3_playback.c index 67a5ff739b..a8d2d698eb 100644 --- a/firmware/mp3_playback.c +++ b/firmware/mp3_playback.c | |||
@@ -542,6 +542,19 @@ void mp3_play_pause(bool play) | |||
542 | paused = true; | 542 | paused = true; |
543 | cumulative_ticks += current_tick - playstart_tick; | 543 | cumulative_ticks += current_tick - playstart_tick; |
544 | } | 544 | } |
545 | } | ||
546 | |||
547 | bool mp3_pause_done(void) | ||
548 | { | ||
549 | unsigned long frame_count; | ||
550 | |||
551 | if (!paused) | ||
552 | return false; | ||
553 | |||
554 | mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_FRAME_COUNT, &frame_count, 1); | ||
555 | /* This works because the frame counter never wraps, | ||
556 | * i.e. zero always means lost sync. */ | ||
557 | return frame_count == 0; | ||
545 | } | 558 | } |
546 | 559 | ||
547 | void mp3_play_stop(void) | 560 | void mp3_play_stop(void) |