[MMDEVAPI_WINETEST] Sync with Wine Staging 1.7.55. CORE-10536
[reactos.git] / rostests / winetests / mmdevapi / capture.c
index 702843c..865859b 100644 (file)
@@ -38,6 +38,9 @@
 
 #define NULL_PTR_ERR MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, RPC_X_NULL_REF_POINTER)
 
+/* undocumented error code */
+#define D3D11_ERROR_4E MAKE_HRESULT(SEVERITY_ERROR, FACILITY_DIRECT3D11, 0x4e)
+
 static IMMDevice *dev = NULL;
 static const LARGE_INTEGER ullZero;
 
@@ -83,7 +86,7 @@ static void test_capture(IAudioClient *ac, HANDLE handle, WAVEFORMATEX *wfx)
     HRESULT hr;
     UINT32 frames, next, pad, sum = 0;
     BYTE *data;
-    DWORD flags, r;
+    DWORD flags;
     UINT64 pos, qpc;
     REFERENCE_TIME period;
 
@@ -241,7 +244,11 @@ static void test_capture(IAudioClient *ac, HANDLE handle, WAVEFORMATEX *wfx)
         ok(hr == S_OK, "Valid IAudioCaptureClient_GetBuffer returns %08x\n", hr);
         ok(frames2 == frames, "GetBuffer after ReleaseBuffer(0) %u/%u\n", frames2, frames);
         ok(pos2 == pos, "Position after ReleaseBuffer(0) %u/%u\n", (UINT)pos2, (UINT)pos);
-        todo_wine ok(qpc2 == qpc, "HPC after ReleaseBuffer(0) %u vs. %u\n", (UINT)qpc2, (UINT)qpc);
+        if(qpc2 != qpc)
+            /* FIXME: Some drivers fail */
+            todo_wine ok(qpc2 == qpc, "HPC after ReleaseBuffer(0) %u vs. %u\n", (UINT)qpc2, (UINT)qpc);
+        else
+            ok(qpc2 == qpc, "HPC after ReleaseBuffer(0) %u vs. %u\n", (UINT)qpc2, (UINT)qpc);
     }
 
     /* trace after the GCP test because log output to MS-DOS console disturbs timing */
@@ -304,14 +311,23 @@ static void test_capture(IAudioClient *ac, HANDLE handle, WAVEFORMATEX *wfx)
 
     if(hr == S_OK){
         /* The discontinuity is reported here, but is this an old or new packet? */
-        todo_wine ok(flags & AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY, "expect DISCONTINUITY %x\n", flags);
+        if(!(flags & AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY)){
+            /* FIXME: Some drivers fail */
+            todo_wine ok(flags & AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY, "expect DISCONTINUITY %x\n", flags);
+            todo_wine ok(pos == sum + frames, "Position %u gap %d\n",
+                         (UINT)pos, (UINT)pos - sum);
+        }else{
+            ok(flags & AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY, "expect DISCONTINUITY %x\n", flags);
+
+            /* Native's position is one period further than what we read.
+             * Perhaps that's precisely the meaning of DATA_DISCONTINUITY:
+             * signal when the position jump left a gap. */
+            ok(pos == sum + frames, "Position %u gap %d\n",
+                         (UINT)pos, (UINT)pos - sum);
+        }
+
         ok(pad == next, "GCP %u vs. BufferSize %u\n", (UINT32)pad, next);
 
-        /* Native's position is one period further than what we read.
-         * Perhaps that's precisely the meaning of DATA_DISCONTINUITY:
-         * signal when the position jump left a gap. */
-        todo_wine ok(pos == sum + frames, "Position %u gap %d\n",
-                     (UINT)pos, (UINT)pos - sum);
         if(flags & AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY)
             sum = pos;
     }
@@ -417,32 +433,6 @@ static void test_capture(IAudioClient *ac, HANDLE handle, WAVEFORMATEX *wfx)
         IAudioCaptureClient_ReleaseBuffer(acc, frames);
     }
 
-    hr = IAudioClient_Stop(ac);
-    ok(hr == S_OK, "Stop failed: %08x\n", hr);
-
-    ok(ResetEvent(handle), "ResetEvent\n");
-
-    /* Still receiving events! */
-    r = WaitForSingleObject(handle, 20);
-    ok(r == WAIT_OBJECT_0, "Wait(event) after Stop gave %x\n", r);
-
-    hr = IAudioClient_Reset(ac);
-    ok(hr == S_OK, "Reset failed: %08x\n", hr);
-
-    ok(ResetEvent(handle), "ResetEvent\n");
-
-    r = WaitForSingleObject(handle, 120);
-    ok(r == WAIT_OBJECT_0, "Wait(event) after Reset gave %x\n", r);
-
-    hr = IAudioClient_SetEventHandle(ac, NULL);
-    ok(hr == E_INVALIDARG, "SetEventHandle(NULL) returns %08x\n", hr);
-
-    r = WaitForSingleObject(handle, 70);
-    ok(r == WAIT_OBJECT_0, "Wait(NULL event) gave %x\n", r);
-
-    hr = IAudioClient_Start(ac);
-    ok(hr == S_OK, "Start failed: %08x\n", hr);
-
     IAudioCaptureClient_Release(acc);
 }
 
@@ -593,7 +583,8 @@ static void test_audioclient(void)
     ok(hr == E_INVALIDARG, "SetEventHandle(NULL) returns %08x\n", hr);
 
     hr = IAudioClient_Start(ac);
-    ok(hr == AUDCLNT_E_EVENTHANDLE_NOT_SET, "Start before SetEventHandle returns %08x\n", hr);
+    ok(hr == AUDCLNT_E_EVENTHANDLE_NOT_SET ||
+            hr == D3D11_ERROR_4E /* win10 */, "Start before SetEventHandle returns %08x\n", hr);
 
     hr = IAudioClient_SetEventHandle(ac, handle);
     ok(hr == S_OK, "SetEventHandle returns %08x\n", hr);
@@ -847,7 +838,6 @@ static void test_simplevolume(void)
 
     hr = ISimpleAudioVolume_GetMasterVolume(sav, &vol);
     ok(hr == S_OK, "GetMasterVolume failed: %08x\n", hr);
-    ok(vol == 1.f, "Master volume wasn't 1: %f\n", vol);
 
     hr = ISimpleAudioVolume_SetMasterVolume(sav, -1.f, NULL);
     ok(hr == E_INVALIDARG, "SetMasterVolume gave wrong error: %08x\n", hr);