summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-20 02:02:29 +0200
committerwm4 <wm4@nowhere>2014-09-20 02:02:29 +0200
commit73291014788d6a6617a08887ebc311a136450c09 (patch)
tree52fcd552beadf166370fce5d64ddf57b0a0cd6a5
parentf64199fcdc7979d18e2dbb432c3c719282e937c6 (diff)
downloadmpv-73291014788d6a6617a08887ebc311a136450c09.tar.bz2
mpv-73291014788d6a6617a08887ebc311a136450c09.tar.xz
mixer: always restore volume (even with pulse), don't unmute
Be less clever, and restore the volume state even with AOs like pulse, which have per-application audio. Before this commit we didn't do this, because the volume is global (even if per-application), so the volume will persist between invocations. But to me it looks like always restoring is less tricky and makes for easier to understand semantics. Also, don't always unmute on exit. Unmuting was done even with ao_pulse, and interfered with user expectations (see #1107). This might annoy some users, because mpv will change the volume all the time. We will see. Fixes #1107.
-rw-r--r--audio/mixer.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/audio/mixer.c b/audio/mixer.c
index 74c82f252c..e02388851c 100644
--- a/audio/mixer.c
+++ b/audio/mixer.c
@@ -37,6 +37,7 @@ struct mixer {
struct af_stream *af;
// Static, dependent on ao/softvol settings
bool softvol; // use AO (true) or af_volume (false)
+ bool ao_softvol; // AO has private or 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;
@@ -245,11 +246,13 @@ 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 ||
+ ao_control(mixer->ao, AOCONTROL_HAS_PER_APP_VOLUME, 0) == 1;
+
if (mixer->opts->softvol == SOFTVOL_AUTO) {
// No system-wide volume => fine with AO volume control.
- mixer->softvol =
- ao_control(mixer->ao, AOCONTROL_HAS_SOFT_VOLUME, 0) != 1 &&
- ao_control(mixer->ao, AOCONTROL_HAS_PER_APP_VOLUME, 0) != 1;
+ mixer->softvol = !mixer->ao_softvol;
} else {
mixer->softvol = mixer->opts->softvol == SOFTVOL_YES;
}
@@ -282,8 +285,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 || ao_control(ao, AOCONTROL_HAS_SOFT_VOLUME, 0) == 1;
+ bool restore = mixer->softvol || mixer->ao_softvol;
// Restore old parameters if volume won't survive reinitialization.
// But not if volume scale is possibly different.
@@ -361,7 +363,7 @@ void mixer_uninit_audio(struct mixer *mixer)
return;
checkvolume(mixer);
- if (mixer->muted_by_us) {
+ if (mixer->muted_by_us && !mixer->softvol && !mixer->ao_softvol) {
/* Current audio output API combines playing the remaining buffered
* audio and uninitializing the AO into one operation, even though
* ideally unmute would happen between those two steps. We can't do