Commit bd6f6bc2 authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

mmdevapi: Prevent deadlock when releasing a stream that's still playing.

parent 436d26f9
......@@ -313,7 +313,10 @@ HRESULT AudioClient_Create(MMDevice *parent, IAudioClient **ppv)
static void AudioClient_Destroy(ACImpl *This)
{
if (This->timer_id)
{
DeleteTimerQueueTimer(NULL, This->timer_id, INVALID_HANDLE_VALUE);
This->timer_id = 0;
}
if (This->render)
AudioRenderClient_Destroy(This->render);
if (This->capture)
......
......@@ -334,6 +334,52 @@ static void test_references(void)
ok(ref == 0, "AudioClock_Release gave wrong refcount: %u\n", ref);
}
static void test_event(void)
{
HANDLE event;
HRESULT hr;
IAudioClient *ac;
WAVEFORMATEX *pwfx;
hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
NULL, (void**)&ac);
ok(hr == S_OK, "Activation failed with %08x\n", hr);
if(hr != S_OK)
return;
hr = IAudioClient_GetMixFormat(ac, &pwfx);
ok(hr == S_OK, "GetMixFormat failed: %08x\n", hr);
if(hr != S_OK)
return;
hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK, 5000000,
0, pwfx, NULL);
ok(hr == S_OK, "Initialize failed: %08x\n", hr);
event = CreateEventW(NULL, FALSE, FALSE, NULL);
ok(event != NULL, "CreateEvent failed\n");
hr = IAudioClient_Start(ac);
ok(hr == AUDCLNT_E_EVENTHANDLE_NOT_SET, "Start failed: %08x\n", hr);
hr = IAudioClient_SetEventHandle(ac, event);
ok(hr == S_OK, "SetEventHandle failed: %08x\n", hr);
hr = IAudioClient_Start(ac);
ok(hr == S_OK, "Start failed: %08x\n", hr);
hr = IAudioClient_Stop(ac);
ok(hr == S_OK, "Start failed: %08x\n", hr);
/* test releasing a playing stream */
hr = IAudioClient_Start(ac);
ok(hr == S_OK, "Start failed: %08x\n", hr);
IAudioClient_Release(ac);
CloseHandle(event);
}
START_TEST(render)
{
HRESULT hr;
......@@ -360,6 +406,7 @@ START_TEST(render)
test_audioclient();
test_references();
test_event();
IMMDevice_Release(dev);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment