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:
parent
61aa15969c
commit
03d08ecc25
3 changed files with 30 additions and 11 deletions
25
apps/wps.c
25
apps/wps.c
|
@ -384,34 +384,39 @@ static bool update(void)
|
|||
|
||||
static void fade(bool fade_in)
|
||||
{
|
||||
unsigned fp_global_vol = global_settings.volume << 8;
|
||||
unsigned fp_step = fp_global_vol / 30;
|
||||
|
||||
if (fade_in) {
|
||||
/* fade in */
|
||||
int current_volume = 20;
|
||||
unsigned fp_volume = 0;
|
||||
|
||||
/* zero out the sound */
|
||||
sound_set(SOUND_VOLUME, current_volume);
|
||||
sound_set(SOUND_VOLUME, 0);
|
||||
|
||||
sleep(HZ/10); /* let audio thread run */
|
||||
audio_resume();
|
||||
|
||||
while (current_volume < global_settings.volume) {
|
||||
current_volume += 2;
|
||||
while (fp_volume < fp_global_vol) {
|
||||
fp_volume += fp_step;
|
||||
sleep(1);
|
||||
sound_set(SOUND_VOLUME, current_volume);
|
||||
sound_set(SOUND_VOLUME, fp_volume >> 8);
|
||||
}
|
||||
sound_set(SOUND_VOLUME, global_settings.volume);
|
||||
}
|
||||
else {
|
||||
/* fade out */
|
||||
int current_volume = global_settings.volume;
|
||||
unsigned fp_volume = fp_global_vol;
|
||||
|
||||
while (current_volume > 20) {
|
||||
current_volume -= 2;
|
||||
while (fp_volume > fp_step) {
|
||||
fp_volume -= fp_step;
|
||||
sleep(1);
|
||||
sound_set(SOUND_VOLUME, current_volume);
|
||||
sound_set(SOUND_VOLUME, fp_volume >> 8);
|
||||
}
|
||||
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 */
|
||||
sound_set(SOUND_VOLUME, global_settings.volume);
|
||||
|
|
|
@ -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 mp3_play_pause(bool play);
|
||||
bool mp3_pause_done(void);
|
||||
void mp3_play_stop(void);
|
||||
long mp3_get_playtime(void);
|
||||
void mp3_reset_playtime(void);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
playing = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue