From b18c5e811f6569c8acb373b529e931dd7505281e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20H=C3=B6hle?= Date: Sun, 9 Dec 2012 21:39:16 +0100 Subject: [PATCH] mmdevapi: SetEventHandle is allowed only once. --- dlls/mmdevapi/tests/render.c | 2 +- dlls/winealsa.drv/mmdevdrv.c | 6 ++++++ dlls/winecoreaudio.drv/mmdevdrv.c | 6 ++++++ dlls/wineoss.drv/mmdevdrv.c | 6 ++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/dlls/mmdevapi/tests/render.c b/dlls/mmdevapi/tests/render.c index 9d9478a2898..e753299289d 100644 --- a/dlls/mmdevapi/tests/render.c +++ b/dlls/mmdevapi/tests/render.c @@ -634,7 +634,7 @@ static void test_event(void) ok(hr == S_OK, "SetEventHandle failed: %08x\n", hr); hr = IAudioClient_SetEventHandle(ac, event); - todo_wine ok(hr == HRESULT_FROM_WIN32(ERROR_INVALID_NAME), "SetEventHandle returns %08x\n", hr); + ok(hr == HRESULT_FROM_WIN32(ERROR_INVALID_NAME), "SetEventHandle returns %08x\n", hr); r = WaitForSingleObject(event, 40); ok(r == WAIT_TIMEOUT, "Wait(event) before Start gave %x\n", r); diff --git a/dlls/winealsa.drv/mmdevdrv.c b/dlls/winealsa.drv/mmdevdrv.c index 416f1ba02df..e903b9e1636 100644 --- a/dlls/winealsa.drv/mmdevdrv.c +++ b/dlls/winealsa.drv/mmdevdrv.c @@ -2284,6 +2284,12 @@ static HRESULT WINAPI AudioClient_SetEventHandle(IAudioClient *iface, return AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED; } + if (This->event){ + LeaveCriticalSection(&This->lock); + FIXME("called twice\n"); + return HRESULT_FROM_WIN32(ERROR_INVALID_NAME); + } + This->event = event; LeaveCriticalSection(&This->lock); diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c index 8ee0dec1e33..ee965e7744d 100644 --- a/dlls/winecoreaudio.drv/mmdevdrv.c +++ b/dlls/winecoreaudio.drv/mmdevdrv.c @@ -1816,6 +1816,12 @@ static HRESULT WINAPI AudioClient_SetEventHandle(IAudioClient *iface, return AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED; } + if (This->event){ + OSSpinLockUnlock(&This->lock); + FIXME("called twice\n"); + return HRESULT_FROM_WIN32(ERROR_INVALID_NAME); + } + This->event = event; OSSpinLockUnlock(&This->lock); diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c index 9fc6f0238d7..4de5ae6bbab 100644 --- a/dlls/wineoss.drv/mmdevdrv.c +++ b/dlls/wineoss.drv/mmdevdrv.c @@ -1620,6 +1620,12 @@ static HRESULT WINAPI AudioClient_SetEventHandle(IAudioClient *iface, return AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED; } + if (This->event){ + LeaveCriticalSection(&This->lock); + FIXME("called twice\n"); + return HRESULT_FROM_WIN32(ERROR_INVALID_NAME); + } + This->event = event; LeaveCriticalSection(&This->lock);