output/Command: flush the mixer cache when enabling/disabling output

Fixes mixer lag (http://bugs.musicpd.org/view.php?id=4425).
This commit is contained in:
Max Kellermann 2015-10-26 16:29:07 +01:00
parent 1958f78cc1
commit ac61d43720
2 changed files with 10 additions and 0 deletions

2
NEWS
View File

@ -5,6 +5,8 @@ ver 0.19.11 (not yet released)
- ffmpeg: fix crash due to wrong avio_alloc_context() call
* encoder
- flac: fix crash with 32 bit playback
* mixer
- fix mixer lag after enabling/disabling output
ver 0.19.10 (2015/06/21)
* input

View File

@ -30,6 +30,7 @@
#include "Internal.hxx"
#include "PlayerControl.hxx"
#include "mixer/MixerControl.hxx"
#include "mixer/Volume.hxx"
#include "Idle.hxx"
extern unsigned audio_output_state_version;
@ -47,6 +48,11 @@ audio_output_enable_index(MultipleOutputs &outputs, unsigned idx)
ao.enabled = true;
idle_add(IDLE_OUTPUT);
if (ao.mixer != nullptr) {
InvalidateHardwareVolume();
idle_add(IDLE_MIXER);
}
ao.player_control->UpdateAudio();
++audio_output_state_version;
@ -70,6 +76,7 @@ audio_output_disable_index(MultipleOutputs &outputs, unsigned idx)
Mixer *mixer = ao.mixer;
if (mixer != nullptr) {
mixer_close(mixer);
InvalidateHardwareVolume();
idle_add(IDLE_MIXER);
}
@ -94,6 +101,7 @@ audio_output_toggle_index(MultipleOutputs &outputs, unsigned idx)
Mixer *mixer = ao.mixer;
if (mixer != nullptr) {
mixer_close(mixer);
InvalidateHardwareVolume();
idle_add(IDLE_MIXER);
}
}