[MMDEVAPI_WINETEST] Sync with Wine Staging 4.18. CORE-16441
[reactos.git] / modules / rostests / winetests / mmdevapi / render.c
index c7fb7c1..3e8fd4a 100644 (file)
 
 #define COBJMACROS
 
 
 #define COBJMACROS
 
+#ifdef STANDALONE
+#include "initguid.h"
+#endif
+
 #include "unknwn.h"
 #include "uuids.h"
 #include "mmdeviceapi.h"
 #include "mmsystem.h"
 #include "audioclient.h"
 #include "audiopolicy.h"
 #include "unknwn.h"
 #include "uuids.h"
 #include "mmdeviceapi.h"
 #include "mmsystem.h"
 #include "audioclient.h"
 #include "audiopolicy.h"
-#include "initguid.h"
+#ifdef __REACTOS__
+#include <initguid.h>
+#endif
 #include "endpointvolume.h"
 
 static const unsigned int win_formats[][4] = {
 #include "endpointvolume.h"
 
 static const unsigned int win_formats[][4] = {
@@ -48,7 +54,6 @@ static const unsigned int win_formats[][4] = {
     {48000,  8, 1},   {48000,  8, 2},   {48000, 16, 1},   {48000, 16, 2},
     {96000,  8, 1},   {96000,  8, 2},   {96000, 16, 1},   {96000, 16, 2}
 };
     {48000,  8, 1},   {48000,  8, 2},   {48000, 16, 1},   {48000, 16, 2},
     {96000,  8, 1},   {96000,  8, 2},   {96000, 16, 1},   {96000, 16, 2}
 };
-#define NB_WIN_FORMATS (sizeof(win_formats)/sizeof(*win_formats))
 
 #define NULL_PTR_ERR MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, RPC_X_NULL_REF_POINTER)
 
 
 #define NULL_PTR_ERR MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, RPC_X_NULL_REF_POINTER)
 
@@ -320,11 +325,7 @@ static void test_audioclient(void)
     hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, 0, 5000000, 0, pwfx, NULL);
     ok(hr == S_OK, "Valid Initialize returns %08x\n", hr);
     if (hr != S_OK)
     hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, 0, 5000000, 0, pwfx, NULL);
     ok(hr == S_OK, "Valid Initialize returns %08x\n", hr);
     if (hr != S_OK)
-    {
-        IAudioClient_Release(ac);
-        CoTaskMemFree(pwfx);
-        return;
-    }
+        goto cleanup;
 
     hr = IAudioClient_GetStreamLatency(ac, NULL);
     ok(hr == E_POINTER, "GetStreamLatency(NULL) call returns %08x\n", hr);
 
     hr = IAudioClient_GetStreamLatency(ac, NULL);
     ok(hr == E_POINTER, "GetStreamLatency(NULL) call returns %08x\n", hr);
@@ -335,8 +336,8 @@ static void test_audioclient(void)
           (UINT)(t2/10000), (UINT)(t2 % 10000));
     ok(t2 >= t1 || broken(t2 >= t1/2 && pwfx->nSamplesPerSec > 48000) ||
             broken(t2 == 0) /* (!) win10 */,
           (UINT)(t2/10000), (UINT)(t2 % 10000));
     ok(t2 >= t1 || broken(t2 >= t1/2 && pwfx->nSamplesPerSec > 48000) ||
             broken(t2 == 0) /* (!) win10 */,
-       "Latency < default period, delta %dus (%x%08x vs %x%08x)\n",
-       (LONG)((t2-t1)/10), (DWORD)(t2 >> 32), (DWORD)t2, (DWORD)(t1 >> 32), (DWORD)t1);
+       "Latency < default period, delta %dus (%s vs %s)\n",
+       (LONG)((t2-t1)/10), wine_dbgstr_longlong(t2), wine_dbgstr_longlong(t1));
     /* Native appears to add the engine period to the HW latency in shared mode */
     if(t2 == 0)
         win10 = TRUE;
     /* Native appears to add the engine period to the HW latency in shared mode */
     if(t2 == 0)
         win10 = TRUE;
@@ -369,8 +370,8 @@ static void test_audioclient(void)
     hr = IAudioClient_Start(ac);
     ok(hr == AUDCLNT_E_NOT_STOPPED, "Start twice returns %08x\n", hr);
 
     hr = IAudioClient_Start(ac);
     ok(hr == AUDCLNT_E_NOT_STOPPED, "Start twice returns %08x\n", hr);
 
+cleanup:
     IAudioClient_Release(ac);
     IAudioClient_Release(ac);
-
     CloseHandle(handle);
     CoTaskMemFree(pwfx);
 }
     CloseHandle(handle);
     CoTaskMemFree(pwfx);
 }
@@ -385,7 +386,7 @@ static void test_formats(AUDCLNT_SHAREMODE mode)
     fmt.wFormatTag = WAVE_FORMAT_PCM;
     fmt.cbSize = 0;
 
     fmt.wFormatTag = WAVE_FORMAT_PCM;
     fmt.cbSize = 0;
 
-    for(i = 0; i < NB_WIN_FORMATS; i++) {
+    for(i = 0; i < ARRAY_SIZE(win_formats); i++) {
         hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
                 NULL, (void**)&ac);
         ok(hr == S_OK, "Activation failed with %08x\n", hr);
         hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
                 NULL, (void**)&ac);
         ok(hr == S_OK, "Activation failed with %08x\n", hr);
@@ -746,7 +747,7 @@ static void test_padding(void)
         /* win10 appears not to clear the buffer */
         for(i = 0; i < psize * pwfx->nBlockAlign; ++i){
             if(buf[i] != silence){
         /* win10 appears not to clear the buffer */
         for(i = 0; i < psize * pwfx->nBlockAlign; ++i){
             if(buf[i] != silence){
-                ok(0, "buffer has data in it already, i: %u, valu: %f\n", i, *((float*)buf));
+                ok(0, "buffer has data in it already, i: %u, value: %f\n", i, *((float*)buf));
                 break;
             }
         }
                 break;
             }
         }
@@ -949,9 +950,8 @@ static void test_clock(int share)
     ok(gbsize == bufsize,
        "BufferSize %u at rate %u\n", gbsize, pwfx->nSamplesPerSec);
     else
     ok(gbsize == bufsize,
        "BufferSize %u at rate %u\n", gbsize, pwfx->nSamplesPerSec);
     else
-        todo_wine
-        ok(gbsize == parts * fragment || gbsize == MulDiv(bufsize, 1, 1024) * 1024,
-           "BufferSize %u misfits fragment size %u at rate %u\n", gbsize, fragment, pwfx->nSamplesPerSec);
+    ok(gbsize == parts * fragment || gbsize == MulDiv(bufsize, 1, 1024) * 1024,
+       "BufferSize %u misfits fragment size %u at rate %u\n", gbsize, fragment, pwfx->nSamplesPerSec);
 
     /* In shared mode, GetCurrentPadding decreases in multiples of
      * fragment size (i.e. updated only at period ticks), whereas
 
     /* In shared mode, GetCurrentPadding decreases in multiples of
      * fragment size (i.e. updated only at period ticks), whereas