summaryrefslogtreecommitdiffstats
path: root/TOOLS
diff options
context:
space:
mode:
authorKevin Mitchell <kevmitch@gmail.com>2016-01-28 01:14:14 -0800
committerKevin Mitchell <kevmitch@gmail.com>2016-01-28 06:49:36 -0800
commit946ee29a7ded5edf99942b07227cd81eb1bcc274 (patch)
treedd88de33a7d2651744f9629141cb6973eb39056c /TOOLS
parent939ad0889b2ff1910b0e1ae58b8782963db3305c (diff)
downloadmpv-946ee29a7ded5edf99942b07227cd81eb1bcc274.tar.bz2
mpv-946ee29a7ded5edf99942b07227cd81eb1bcc274.tar.xz
TOOLS/lua/ao-null-reload.lua: send ao-reload on audio-device-list change
Only triggers if ao=null. This is required for ao=wasapi to recover from periods with no available devices. fixes #2738
Diffstat (limited to 'TOOLS')
-rw-r--r--TOOLS/lua/ao-null-reload.lua20
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 0000000000..5b2330b517
--- /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)