[vlc-devel] [PATCH 3/3] mmdevice: add headphones detection

Thomas Guillem thomas at gllm.fr
Thu Jul 20 14:59:30 CEST 2017


---
 modules/audio_output/mmdevice.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index f7e2aac360..4f32cf0ea8 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -1129,6 +1129,28 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
         if (ret != 0)
             break;
     }
+
+    IPropertyStore *props;
+    HRESULT hr = IMMDevice_OpenPropertyStore(sys->dev, STGM_READ, &props);
+    if (SUCCEEDED(hr))
+    {
+        PROPVARIANT v;
+        PropVariantInit(&v);
+        hr = IPropertyStore_GetValue(props, &PKEY_AudioEndpoint_FormFactor, &v);
+        if (SUCCEEDED(hr))
+        {
+            switch (v.uintVal)
+            {
+                case Headphones:
+                case Headset:
+                    aout->current_sink_info.headphones = true;
+                    break;
+            }
+            PropVariantClear(&v);
+        }
+        IPropertyStore_Release(props);
+    }
+
     LeaveCriticalSection(&sys->lock);
     LeaveMTA();
 
-- 
2.11.0



More information about the vlc-devel mailing list