diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:36:56 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:36:56 +0000 |
commit | 51de1d8436100f725f3576aefa24a2bd2057bc28 (patch) | |
tree | c6d1d5264b6d40a8d7ca34129f36b7d61e188af3 /TOOLS/lua/ao-null-reload.lua | |
parent | Initial commit. (diff) | |
download | mpv-51de1d8436100f725f3576aefa24a2bd2057bc28.tar.xz mpv-51de1d8436100f725f3576aefa24a2bd2057bc28.zip |
Adding upstream version 0.37.0.upstream/0.37.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'TOOLS/lua/ao-null-reload.lua')
-rw-r--r-- | TOOLS/lua/ao-null-reload.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/TOOLS/lua/ao-null-reload.lua b/TOOLS/lua/ao-null-reload.lua new file mode 100644 index 0000000..5b2330b --- /dev/null +++ b/TOOLS/lua/ao-null-reload.lua @@ -0,0 +1,20 @@ +-- Handles the edge case where previous attempts to init audio have failed, but +-- might start working due to a newly added device. This is required in +-- particular for ao=wasapi, since the internal IMMNotificationClient code that +-- normally triggers ao-reload will not be running in this case. + +function do_reload() + mp.command("ao-reload") + reloading = nil +end + +function on_audio_device_list_change() + if mp.get_property("current-ao") == "null" and not reloading then + mp.msg.verbose("audio-device-list changed: reloading audio") + -- avoid calling ao-reload too often + reloading = mp.add_timeout(0.5, do_reload) + end +end + +mp.set_property("options/audio-fallback-to-null", "yes") +mp.observe_property("audio-device-list", "native", on_audio_device_list_change) |