diff options
Diffstat (limited to 'apps/wps.c')
-rw-r--r-- | apps/wps.c | 27 |
1 files changed, 16 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); |