mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
f64199fcdc
commit
7329101478
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue