Open MarioMastr opened 1 month ago
@ruihe774 mentioning you, in the case you didn't see this issue.
No easy fix I'm afraid. Surely we can clear ao buffer on softvol mute:
diff --git a/player/audio.c b/player/audio.c
index e86547c30e..229458da4d 100644
--- a/player/audio.c
+++ b/player/audio.c
@@ -186,6 +186,11 @@ void audio_update_volume(struct MPContext *mpctx)
gain = 0.0;
ao_set_gain(ao_c->ao, gain);
+
+ if (opts->softvol_mute) {
+ ao_reset(ao_c->ao);
+ ao_start(ao_c->ao);
+ }
}
// Call this if opts->playback_speed or mpctx->speed_factor_* change.
But this it bound to cause some AV desync.
FWIW this is not a problem specific to ao_avfoundation; all pull-based AOs have this issue if they are used with large device buffers.
For now, a simple workaround is not to use softvol mute but to use ao mute instead; ao_avfoundation works well with ao volume and ao mute with no issues that were encountered in other AOs; I don't think there are reasons not to use them. Simply put this config into your input.conf
(or put some similar config into other places if you are not using keybindings to toggle mute):
m cycle ao-mute
# if you also want to use ao volume, add and uncomment these as well:
# WHEEL_UP add ao-volume 2
# WHEEL_DOWN add ao-volume -2
Some AOs (e.g. pipewire) remember ao volume and ao mute even after mpv quits. If you want to prevent this behavior, you can use the following lua script. This does not apply to ao_avfoundation as it does not remember.
mp.register_event("audio-reconfig", function()
mp.set_property_number("ao-volume", 100)
mp.set_property_bool("ao-mute", false)
end)
@MarioMastr @low-batt I've added a new option --avfoundation-buffer
in #14058. Setting it to a lower value can make the AO reacts quicker; though lower value may lead to underruns. You can have a try.
mpv Information
Other Information
Reproduction Steps
Play any video with --no-config --ao=avfoundation and toggle mute (either by using the keybind or using the menu bar).
Expected Behavior
Same behaviour as ao_coreaudio, which mutes as soon as toggled.
Actual Behavior
It takes at least a second to actually mute the audio.
Log File
output.txt
Sample Files
No response
I carefully read all instruction and confirm that I did the following:
--log-file=output.txt
.