[vlc-devel] [PATCH 4/4] mmdevice: fix crash when unplugging a device

Thomas Guillem thomas at gllm.fr
Mon May 23 09:39:25 CEST 2016


Restarting the audio output is not enough when a device is unplugged. Indeed,
the Start function will use the old (and invalid) device.
To fix this issue, re-select the default device in case of error.
---
 modules/audio_output/mmdevice.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index a21a1ef..5729955 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -114,11 +114,12 @@ struct aout_sys_t
  * synchronization between the set of audio output callbacks, MMThread()
  * and (trivially) the device and session notifications. */
 
+static int DeviceSelect(audio_output_t *, const char *);
 static int vlc_FromHR(audio_output_t *aout, HRESULT hr)
 {
-    /* Restart on unplug */
+    /* Select the default device (and restart) on unplug */
     if (unlikely(hr == AUDCLNT_E_DEVICE_INVALIDATED))
-        aout_RestartRequest(aout, AOUT_RESTART_OUTPUT);
+        DeviceSelect(aout, NULL);
     return SUCCEEDED(hr) ? 0 : -1;
 }
 
-- 
2.8.1



More information about the vlc-devel mailing list