[vlc-commits] mmdevice: improve handling of session disconnect event

Rémi Denis-Courmont git at videolan.org
Thu Dec 6 12:09:46 CET 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Dec  6 12:46:42 2012 +0200| [4a1c30a05481c31cc6580954920a2f67fc432426] | committer: Rémi Denis-Courmont

mmdevice: improve handling of session disconnect event

It could still be better. If the disconnection is unrecoverable,
I suspect a flood of identical errors will be emitted continuously
as the core keeps pushing audio buffers.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4a1c30a05481c31cc6580954920a2f67fc432426
---

 modules/audio_output/mmdevice.c |   28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index 258e99b..8b8e9e2 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -428,12 +428,36 @@ vlc_AudioSessionEvents_OnStateChanged(IAudioSessionEvents *this,
 
 static STDMETHODIMP
 vlc_AudioSessionEvents_OnSessionDisconnected(IAudioSessionEvents *this,
-                                             AudioSessionDisconnectReason reason)
+                                           AudioSessionDisconnectReason reason)
 {
     aout_sys_t *sys = vlc_AudioSessionEvents_sys(this);
     audio_output_t *aout = sys->aout;
 
-    msg_Dbg(aout, "session disconnected: reason %d", reason);
+    switch (reason)
+    {
+        case DisconnectReasonDeviceRemoval:
+            msg_Warn(aout, "session disconnected: %s", "device removed");
+            break;
+        case DisconnectReasonServerShutdown:
+            msg_Err(aout, "session disconnected: %s", "service stopped");
+            return S_OK;
+        case DisconnectReasonFormatChanged:
+            msg_Warn(aout, "session disconnected: %s", "format changed");
+            break;
+        case DisconnectReasonSessionLogoff:
+            msg_Err(aout, "session disconnected: %s", "user logged off");
+            return S_OK;
+        case DisconnectReasonSessionDisconnected:
+            msg_Err(aout, "session disconnected: %s", "session disconnected");
+            return S_OK;
+        case DisconnectReasonExclusiveModeOverride:
+            msg_Err(aout, "session disconnected: %s", "stream overriden");
+            return S_OK;
+        default:
+            msg_Warn(aout, "session disconnected: unknown reason %d", reason);
+            return S_OK;
+    }
+    var_TriggerCallback(aout, "audio-device");
     return S_OK;
 }
 



More information about the vlc-commits mailing list