summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-03-24 22:20:58 +0100
committerwm4 <wm4@nowhere>2015-03-24 22:21:59 +0100
commite07d1b397c9784e8b11a2055a4c54e84bd92468c (patch)
tree907d0958971d47ab8622422065b90e043f5c7601
parentb7325b2f64eb66da255b9cc28b2b70b96578883d (diff)
downloadmpv-e07d1b397c9784e8b11a2055a4c54e84bd92468c.tar.bz2
mpv-e07d1b397c9784e8b11a2055a4c54e84bd92468c.tar.xz
mixer: fix how volume is restored with per-app system mixers
This broke with PulseAudio: when changing some audio filters (like for playback speed), mixer_reinit_audio() was called - and it overwrote the volume with whatever mpv thought the volume was before. If the volume was changed externally before and while mpv was running, this would reset the volume to the old value. Fixes #1335.
-rw-r--r--audio/mixer.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/audio/mixer.c b/audio/mixer.c
index ced2196215..2358835248 100644
--- a/audio/mixer.c
+++ b/audio/mixer.c
@@ -38,6 +38,7 @@ struct mixer {
// Static, dependent on ao/softvol settings
bool softvol; // use AO (false) or af_volume (true)
bool ao_softvol; // AO has private or per-app volume
+ bool ao_perapp; // AO has persistent per-app volume
bool emulate_mute; // if true, emulate mute with volume=0
// Last known values (possibly out of sync with reality)
float vol_l, vol_r;
@@ -246,9 +247,11 @@ char *mixer_get_volume_restore_data(struct mixer *mixer)
static void probe_softvol(struct mixer *mixer)
{
- mixer->ao_softvol =
- ao_control(mixer->ao, AOCONTROL_HAS_SOFT_VOLUME, 0) == 1 ||
+ mixer->ao_perapp =
ao_control(mixer->ao, AOCONTROL_HAS_PER_APP_VOLUME, 0) == 1;
+ mixer->ao_softvol = mixer->ao_perapp ||
+ ao_control(mixer->ao, AOCONTROL_HAS_SOFT_VOLUME, 0) == 1;
+
if (mixer->opts->softvol == SOFTVOL_AUTO) {
// No system-wide volume => fine with AO volume control.
@@ -285,7 +288,7 @@ static void restore_volume(struct mixer *mixer)
const char *prev_driver = mixer->driver;
mixer->driver = mixer->softvol ? "softvol" : ao_get_name(ao);
- bool restore = mixer->softvol || mixer->ao_softvol;
+ bool restore = mixer->softvol || (mixer->ao_softvol && !mixer->ao_perapp);
// Restore old parameters if volume won't survive reinitialization.
// But not if volume scale is possibly different.