mmdevapi: Fix win10 test failures.

Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Andrew Eikum 2015-10-26 08:37:38 -05:00 committed by Alexandre Julliard
parent af0288d419
commit b1821266ca
3 changed files with 31 additions and 41 deletions

View 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;
@ -417,32 +420,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 +570,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 +825,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);

View File

@ -54,9 +54,13 @@ static const unsigned int win_formats[][4] = {
#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 IMMDeviceEnumerator *mme = NULL;
static IMMDevice *dev = NULL;
static HRESULT hexcl = S_OK; /* or AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED */
static BOOL win10 = FALSE;
static const LARGE_INTEGER ullZero;
@ -281,7 +285,8 @@ static void test_audioclient(void)
fmtex->dwChannelMask = 0xffff;
hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, 0, 5000000, 0, pwfx, NULL);
ok(hr == S_OK, "Initialize(dwChannelMask = 0xffff) returns %08x\n", hr);
ok(hr == S_OK ||
hr == AUDCLNT_E_UNSUPPORTED_FORMAT /* win10 */, "Initialize(dwChannelMask = 0xffff) returns %08x\n", hr);
IAudioClient_Release(ac);
@ -330,9 +335,12 @@ static void test_audioclient(void)
ok(hr == S_OK, "Valid GetStreamLatency call returns %08x\n", hr);
trace("Returned latency: %u.%04u ms\n",
(UINT)(t2/10000), (UINT)(t2 % 10000));
ok(t2 >= t1 || broken(t2 >= t1/2 && pwfx->nSamplesPerSec > 48000),
"Latency < default period, delta %ldus\n", (long)((t2-t1)/10));
ok(t2 >= t1 || broken(t2 >= t1/2 && pwfx->nSamplesPerSec > 48000) ||
broken(t2 == 0) /* (!) win10 */,
"Latency < default period, delta %ldus (%llu vs %llu)\n", (long)((t2-t1)/10), t2, t1);
/* Native appears to add the engine period to the HW latency in shared mode */
if(t2 == 0)
win10 = TRUE;
hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, 0, 5000000, 0, pwfx, NULL);
ok(hr == AUDCLNT_E_ALREADY_INITIALIZED, "Calling Initialize twice returns %08x\n", hr);
@ -627,13 +635,15 @@ static void test_event(void)
ok(event != NULL, "CreateEvent failed\n");
hr = IAudioClient_Start(ac);
ok(hr == AUDCLNT_E_EVENTHANDLE_NOT_SET, "Start failed: %08x\n", hr);
ok(hr == AUDCLNT_E_EVENTHANDLE_NOT_SET ||
hr == D3D11_ERROR_4E /* win10 */, "Start failed: %08x\n", hr);
hr = IAudioClient_SetEventHandle(ac, event);
ok(hr == S_OK, "SetEventHandle failed: %08x\n", hr);
hr = IAudioClient_SetEventHandle(ac, event);
ok(hr == HRESULT_FROM_WIN32(ERROR_INVALID_NAME), "SetEventHandle returns %08x\n", hr);
ok(hr == HRESULT_FROM_WIN32(ERROR_INVALID_NAME) ||
hr == E_UNEXPECTED /* win10 */, "SetEventHandle returns %08x\n", hr);
r = WaitForSingleObject(event, 40);
ok(r == WAIT_TIMEOUT, "Wait(event) before Start gave %x\n", r);
@ -733,10 +743,13 @@ static void test_padding(void)
hr = IAudioRenderClient_GetBuffer(arc, psize, &buf);
ok(hr == S_OK, "GetBuffer failed: %08x\n", hr);
ok(buf != NULL, "NULL buffer returned\n");
for(i = 0; i < psize * pwfx->nBlockAlign; ++i){
if(buf[i] != silence){
ok(0, "buffer has data in it already\n");
break;
if(!win10){
/* 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));
break;
}
}
}
@ -910,7 +923,8 @@ static void test_clock(int share)
hr = IAudioClient_GetStreamLatency(ac, &t2);
ok(hr == S_OK, "GetStreamLatency failed: %08x\n", hr);
trace("Latency: %u.%04u ms\n", (UINT)(t2/10000), (UINT)(t2 % 10000));
ok(t2 >= period || broken(t2 >= period/2 && share && pwfx->nSamplesPerSec > 48000),
ok(t2 >= period || broken(t2 >= period/2 && share && pwfx->nSamplesPerSec > 48000) ||
broken(t2 == 0) /* win10 */,
"Latency < default period, delta %ldus\n", (long)((t2-period)/10));
/** GetBufferSize
@ -1972,7 +1986,6 @@ static void test_session_creation(void)
vol = 0.5f;
hr = ISimpleAudioVolume_GetMasterVolume(cap_sav, &vol);
ok(hr == S_OK, "GetMasterVolume failed: %08x\n", hr);
ok(vol == 1.f, "Got wrong volume: %f\n", vol);
ISimpleAudioVolume_Release(cap_sav);
IAudioSessionManager_Release(cap_sesm);
@ -2001,7 +2014,6 @@ static void test_session_creation(void)
vol = 0.5f;
hr = ISimpleAudioVolume_GetMasterVolume(cap_sav, &vol);
ok(hr == S_OK, "GetMasterVolume failed: %08x\n", hr);
ok(vol == 1.f, "Got wrong volume: %f\n", vol);
ISimpleAudioVolume_Release(cap_sav);
}

View File

@ -59,6 +59,7 @@
#define FACILITY_PLA 48
#define FACILITY_FVE 49
#define FACILITY_WINDOWS_DEFENDER 80
#define FACILITY_DIRECT3D11 0x87c
#define SEVERITY_SUCCESS 0
#define SEVERITY_ERROR 1