1
0
Fork 0
forked from len0rd/rockbox

(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
This commit is contained in:
Jens Arnold 2005-05-13 00:16:14 +00:00
parent 61aa15969c
commit 03d08ecc25
3 changed files with 30 additions and 11 deletions

View file

@ -384,34 +384,39 @@ static bool update(void)
static void fade(bool fade_in) static void fade(bool fade_in)
{ {
unsigned fp_global_vol = global_settings.volume << 8;
unsigned fp_step = fp_global_vol / 30;
if (fade_in) { if (fade_in) {
/* fade in */ /* fade in */
int current_volume = 20; unsigned fp_volume = 0;
/* zero out the sound */ /* zero out the sound */
sound_set(SOUND_VOLUME, current_volume); sound_set(SOUND_VOLUME, 0);
sleep(HZ/10); /* let audio thread run */ sleep(HZ/10); /* let audio thread run */
audio_resume(); audio_resume();
while (current_volume < global_settings.volume) { while (fp_volume < fp_global_vol) {
current_volume += 2; fp_volume += fp_step;
sleep(1); sleep(1);
sound_set(SOUND_VOLUME, current_volume); sound_set(SOUND_VOLUME, fp_volume >> 8);
} }
sound_set(SOUND_VOLUME, global_settings.volume); sound_set(SOUND_VOLUME, global_settings.volume);
} }
else { else {
/* fade out */ /* fade out */
int current_volume = global_settings.volume; unsigned fp_volume = fp_global_vol;
while (current_volume > 20) { while (fp_volume > fp_step) {
current_volume -= 2; fp_volume -= fp_step;
sleep(1); sleep(1);
sound_set(SOUND_VOLUME, current_volume); sound_set(SOUND_VOLUME, fp_volume >> 8);
} }
audio_pause(); audio_pause();
sleep(HZ/5); /* let audio thread run */ /* let audio thread run and wait for the mas to run out of data */
while (!mp3_pause_done())
sleep(HZ/10);
/* reset volume to what it was before the fade */ /* reset volume to what it was before the fade */
sound_set(SOUND_VOLUME, global_settings.volume); sound_set(SOUND_VOLUME, global_settings.volume);

View file

@ -42,6 +42,7 @@ void mp3_play_data(const unsigned char* start, int size,
void (*get_more)(unsigned char** start, int* size) /* callback fn */ void (*get_more)(unsigned char** start, int* size) /* callback fn */
); );
void mp3_play_pause(bool play); void mp3_play_pause(bool play);
bool mp3_pause_done(void);
void mp3_play_stop(void); void mp3_play_stop(void);
long mp3_get_playtime(void); long mp3_get_playtime(void);
void mp3_reset_playtime(void); void mp3_reset_playtime(void);

View file

@ -544,6 +544,19 @@ void mp3_play_pause(bool play)
} }
} }
bool mp3_pause_done(void)
{
unsigned long frame_count;
if (!paused)
return false;
mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_FRAME_COUNT, &frame_count, 1);
/* This works because the frame counter never wraps,
* i.e. zero always means lost sync. */
return frame_count == 0;
}
void mp3_play_stop(void) void mp3_play_stop(void)
{ {
playing = false; playing = false;