]> git.sesse.net Git - vlc/commitdiff
mmdevice: print endpoint volume range to debug
authorRémi Denis-Courmont <remi@remlab.net>
Sat, 1 Mar 2014 14:40:36 +0000 (16:40 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Sat, 1 Mar 2014 22:20:33 +0000 (00:20 +0200)
modules/audio_output/mmdevice.c

index cf00e92d7195ecaaf960c864887263f555645497..e6a8b220e2dc1f989445654e5093735d9497abab 100644 (file)
@@ -31,6 +31,7 @@
 #include <assert.h>
 #include <audiopolicy.h>
 #include <mmdeviceapi.h>
+#include <endpointvolume.h>
 
 DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd,
    0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14);
@@ -695,6 +696,7 @@ static HRESULT MMSession(audio_output_t *aout, IMMDeviceEnumerator *it)
     IAudioSessionManager *manager;
     IAudioSessionControl *control;
     ISimpleAudioVolume *volume;
+    IAudioEndpointVolume *endpoint;
     void *pv;
     HRESULT hr;
 
@@ -783,6 +785,23 @@ static HRESULT MMSession(audio_output_t *aout, IMMDeviceEnumerator *it)
         volume = NULL;
     }
 
+    hr = IMMDevice_Activate(sys->dev, &IID_IAudioEndpointVolume,
+                            CLSCTX_ALL, NULL, &pv);
+    endpoint = pv;
+    if (SUCCEEDED(hr))
+    {
+        float min, max, inc;
+
+        hr = IAudioEndpointVolume_GetVolumeRange(endpoint, &min, &max, &inc);
+        if (SUCCEEDED(hr))
+            msg_Dbg(aout, "volume from %+f dB to %+f dB with %f dB increments",
+                    min, max, inc);
+        else
+            msg_Err(aout, "cannot get volume range (error 0x%lx)", hr);
+    }
+    else
+        msg_Err(aout, "cannot activate endpoint volume (error %lx)", hr);
+
     /* Main loop (adjust volume as long as device is unchanged) */
     while (sys->device == NULL)
     {
@@ -832,6 +851,9 @@ static HRESULT MMSession(audio_output_t *aout, IMMDeviceEnumerator *it)
     }
     LeaveCriticalSection(&sys->lock);
 
+    if (endpoint != NULL)
+        IAudioEndpointVolume_Release(endpoint);
+
     if (manager != NULL)
     {   /* Deregister callbacks *without* the lock */
         if (volume != NULL)