summaryrefslogtreecommitdiffstats
path: root/Alc/backends
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-03-27 17:17:35 -0700
committerChris Robinson <[email protected]>2014-03-27 17:17:35 -0700
commit4f3e71e5b7ce4768a33c1b3dfa0a3b3df698789b (patch)
tree30eb9896daeffa3d8da1065677a2c70fb57277ef /Alc/backends
parent045959e9c00979128679ca77b10b929182fe3397 (diff)
Reactivate the mmdevapi audio client and set the event handle on reset
Diffstat (limited to 'Alc/backends')
-rw-r--r--Alc/backends/mmdevapi.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c
index 24769213..bfa283a1 100644
--- a/Alc/backends/mmdevapi.c
+++ b/Alc/backends/mmdevapi.c
@@ -339,8 +339,21 @@ static HRESULT DoReset(ALCdevice *device)
WAVEFORMATEX *wfx = NULL;
REFERENCE_TIME min_per, buf_time;
UINT32 buffer_len, min_len;
+ void *ptr = NULL;
HRESULT hr;
+ if(data->client)
+ IAudioClient_Release(data->client);
+ data->client = NULL;
+
+ hr = IMMDevice_Activate(data->mmdev, &IID_IAudioClient, CLSCTX_INPROC_SERVER, NULL, &ptr);
+ if(FAILED(hr))
+ {
+ ERR("Failed to reactivate audio client: 0x%08lx\n", hr);
+ return hr;
+ }
+ data->client = ptr;
+
hr = IAudioClient_GetMixFormat(data->client, &wfx);
if(FAILED(hr))
{
@@ -560,6 +573,13 @@ static HRESULT DoReset(ALCdevice *device)
device->UpdateSize = buffer_len / device->NumUpdates;
}
+ hr = IAudioClient_SetEventHandle(data->client, data->NotifyEvent);
+ if(FAILED(hr))
+ {
+ ERR("Failed to set event handle: 0x%08lx\n", hr);
+ return hr;
+ }
+
return hr;
}
@@ -671,15 +691,9 @@ static DWORD CALLBACK MMDevApiMsgProc(void *ptr)
data = device->ExtraData;
ResetEvent(data->NotifyEvent);
- hr = IAudioClient_SetEventHandle(data->client, data->NotifyEvent);
+ hr = IAudioClient_Start(data->client);
if(FAILED(hr))
- ERR("Failed to set event handle: 0x%08lx\n", hr);
- else
- {
- hr = IAudioClient_Start(data->client);
- if(FAILED(hr))
- ERR("Failed to start audio client: 0x%08lx\n", hr);
- }
+ ERR("Failed to start audio client: 0x%08lx\n", hr);
if(SUCCEEDED(hr))
hr = IAudioClient_GetService(data->client, &IID_IAudioRenderClient, &ptr);
@@ -728,10 +742,12 @@ static DWORD CALLBACK MMDevApiMsgProc(void *ptr)
device = (ALCdevice*)msg.lParam;
data = device->ExtraData;
- IAudioClient_Release(data->client);
+ if(data->client)
+ IAudioClient_Release(data->client);
data->client = NULL;
- IMMDevice_Release(data->mmdev);
+ if(data->mmdev)
+ IMMDevice_Release(data->mmdev);
data->mmdev = NULL;
if(--deviceCount == 0)