[PATCH] winmm: Allow HMIXEROBJ handles in place of device IDs in mixerGetDevCaps

Andrew Eikum aeikum at codeweavers.com
Tue Jan 27 09:02:50 CST 2015


---

Should fix bug 31924.

 dlls/winmm/tests/mixer.c | 16 ++++++++++++++++
 dlls/winmm/waveform.c    | 19 +++++++++++++------
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/dlls/winmm/tests/mixer.c b/dlls/winmm/tests/mixer.c
index 982cf8b..82eb338 100644
--- a/dlls/winmm/tests/mixer.c
+++ b/dlls/winmm/tests/mixer.c
@@ -395,6 +395,14 @@ static void mixer_test_deviceA(int device)
     ok(rc==MMSYSERR_NOERROR,
        "mixerOpen: MMSYSERR_NOERROR expected, got %s\n",mmsys_error(rc));
     if (rc==MMSYSERR_NOERROR) {
+        MIXERCAPSA capsA2;
+
+        rc=mixerGetDevCapsA((UINT_PTR)mix,&capsA2,sizeof(capsA2));
+        ok(rc==MMSYSERR_NOERROR,
+           "mixerGetDevCapsA: MMSYSERR_NOERROR expected, got %s\n",
+           mmsys_error(rc));
+        ok(!strcmp(capsA2.szPname, capsA.szPname), "Got wrong device caps\n");
+
         for (d=0;d<capsA.cDestinations;d++) {
             MIXERLINEA mixerlineA;
             mixerlineA.cbStruct = 0;
@@ -771,6 +779,14 @@ static void mixer_test_deviceW(int device)
     ok(rc==MMSYSERR_NOERROR,
        "mixerOpen: MMSYSERR_NOERROR expected, got %s\n",mmsys_error(rc));
     if (rc==MMSYSERR_NOERROR) {
+        MIXERCAPSW capsW2;
+
+        rc=mixerGetDevCapsW((UINT_PTR)mix,&capsW2,sizeof(capsW2));
+        ok(rc==MMSYSERR_NOERROR,
+           "mixerGetDevCapsW: MMSYSERR_NOERROR expected, got %s\n",
+           mmsys_error(rc));
+        ok(!lstrcmpW(capsW2.szPname, capsW.szPname), "Got wrong device caps\n");
+
         for (d=0;d<capsW.cDestinations;d++) {
             MIXERLINEW mixerlineW;
             mixerlineW.cbStruct = 0;
diff --git a/dlls/winmm/waveform.c b/dlls/winmm/waveform.c
index f381c16..ba74e02 100644
--- a/dlls/winmm/waveform.c
+++ b/dlls/winmm/waveform.c
@@ -122,6 +122,7 @@ struct _WINMM_MMDevice {
     WAVEOUTCAPSW out_caps; /* must not be modified outside of WINMM_InitMMDevices*/
     WAVEINCAPSW in_caps; /* must not be modified outside of WINMM_InitMMDevices*/
     WCHAR *dev_id;
+    EDataFlow dataflow;
 
     ISimpleAudioVolume *volume;
 
@@ -510,6 +511,7 @@ static HRESULT WINMM_InitMMDevice(EDataFlow flow, IMMDevice *device,
 {
     HRESULT hr;
 
+    dev->dataflow = flow;
     if(flow == eRender){
         dev->out_caps.wMid = 0xFF;
         dev->out_caps.wPid = 0xFF;
@@ -3749,15 +3751,20 @@ UINT WINAPI mixerGetDevCapsW(UINT_PTR uDeviceID, LPMIXERCAPSW lpCaps, UINT uSize
         return MMSYSERR_NOERROR;
 
     if(uDeviceID >= g_outmmdevices_count + g_inmmdevices_count)
-        return MMSYSERR_BADDEVICEID;
-
-    if(uDeviceID < g_outmmdevices_count){
+        mmdevice = WINMM_GetMixerMMDevice((HMIXEROBJ)uDeviceID,
+                MIXER_OBJECTF_MIXER, NULL);
+    else if(uDeviceID < g_outmmdevices_count)
         mmdevice = read_map(g_out_map, uDeviceID);
+    else
+        mmdevice = read_map(g_in_map, uDeviceID - g_outmmdevices_count);
+
+    if(!mmdevice)
+        return MMSYSERR_BADDEVICEID;
+
+    if(mmdevice->dataflow == eRender)
         memcpy(caps.szPname, mmdevice->out_caps.szPname, sizeof(caps.szPname));
-    }else{
-        mmdevice = read_map(g_in_map, uDeviceID - g_outmmdevices_count);
+    else
         memcpy(caps.szPname, mmdevice->in_caps.szPname, sizeof(caps.szPname));
-    }
 
     caps.wMid = 0xFF;
     caps.wPid = 0xFF;
-- 
2.2.2




More information about the wine-patches mailing list