Mark Harmstone : dsound: Get speaker config from mmdevice props.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jan 5 15:01:27 CST 2015


Module: wine
Branch: master
Commit: 52345858d0a75c160e4bc2edcf32138e4a1fa492
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=52345858d0a75c160e4bc2edcf32138e4a1fa492

Author: Mark Harmstone <hellas at burntcomma.com>
Date:   Wed Dec 31 20:49:21 2014 +0000

dsound: Get speaker config from mmdevice props.

Use PKEY_AudioEndpoint_PhysicalSpeakers to set the speaker config in dsound.

---

 dlls/dsound/primary.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c
index 36c00da..ea4559c 100644
--- a/dlls/dsound/primary.c
+++ b/dlls/dsound/primary.c
@@ -146,6 +146,49 @@ static HRESULT DSOUND_WaveFormat(DirectSoundDevice *device, IAudioClient *client
     return S_OK;
 }
 
+static DWORD DSOUND_FindSpeakerConfig(IMMDevice *mmdevice)
+{
+    IPropertyStore *store;
+    HRESULT hr;
+    PROPVARIANT pv;
+    ULONG phys_speakers;
+
+    const DWORD def = DSSPEAKER_COMBINED(DSSPEAKER_STEREO, DSSPEAKER_GEOMETRY_WIDE);
+
+    hr = IMMDevice_OpenPropertyStore(mmdevice, STGM_READ, &store);
+    if (FAILED(hr)) {
+        WARN("IMMDevice_OpenPropertyStore failed: %08x\n", hr);
+        return def;
+    }
+
+    hr = IPropertyStore_GetValue(store, &PKEY_AudioEndpoint_PhysicalSpeakers, &pv);
+
+    if (FAILED(hr)) {
+        WARN("IPropertyStore_GetValue failed: %08x\n", hr);
+        IPropertyStore_Release(store);
+        return def;
+    }
+
+    if (pv.vt != VT_UI4) {
+        WARN("PKEY_AudioEndpoint_PhysicalSpeakers is not a ULONG: 0x%x\n", pv.vt);
+        PropVariantClear(&pv);
+        IPropertyStore_Release(store);
+        return def;
+    }
+
+    phys_speakers = pv.u.ulVal;
+
+    PropVariantClear(&pv);
+    IPropertyStore_Release(store);
+
+    if ((phys_speakers & KSAUDIO_SPEAKER_STEREO) == KSAUDIO_SPEAKER_STEREO)
+        return DSSPEAKER_COMBINED(DSSPEAKER_STEREO, DSSPEAKER_GEOMETRY_WIDE);
+    else if ((phys_speakers & KSAUDIO_SPEAKER_MONO) == KSAUDIO_SPEAKER_MONO)
+        return DSSPEAKER_MONO;
+
+    return def;
+}
+
 HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave)
 {
     UINT prebuf_frames;
@@ -181,6 +224,8 @@ HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave)
         return hres;
     }
 
+    device->speaker_config = DSOUND_FindSpeakerConfig(device->mmdevice);
+
     hres = DSOUND_WaveFormat(device, device->client, forcewave, &wfx);
     if (FAILED(hres)) {
         IAudioClient_Release(device->client);




More information about the wine-cvs mailing list