aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-02-29 05:54:58 -0800
committerChris Robinson <[email protected]>2012-02-29 05:54:58 -0800
commitae1633497c1554c97755081230a4bf3edb0eb048 (patch)
tree287c04300618899dae69f97417efe649318e7c6e /Alc/backends
parent00b0e64bd20ac45bbc848746b3e04deabdbad14d (diff)
Get and release the mmdevapi render client iface on the message thread
Diffstat (limited to 'Alc/backends')
-rw-r--r--Alc/backends/mmdevapi.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c
index 2b3cfa8b..082d18a4 100644
--- a/Alc/backends/mmdevapi.c
+++ b/Alc/backends/mmdevapi.c
@@ -58,6 +58,7 @@ typedef struct {
GUID guid;
IMMDevice *mmdev;
IAudioClient *client;
+ IAudioRenderClient *render;
HANDLE hNotifyEvent;
HANDLE MsgEvent;
@@ -268,10 +269,6 @@ static ALuint MMDevApiProc(ALvoid *ptr)
{
ALCdevice *device = ptr;
MMDevApiData *data = device->ExtraData;
- union {
- IAudioRenderClient *iface;
- void *ptr;
- } render;
UINT32 update_size, num_updates;
UINT32 written, len;
BYTE *buffer;
@@ -285,14 +282,6 @@ static ALuint MMDevApiProc(ALvoid *ptr)
return 0;
}
- hr = IAudioClient_GetService(data->client, &IID_IAudioRenderClient, &render.ptr);
- if(FAILED(hr))
- {
- ERR("Failed to get AudioRenderClient service: 0x%08lx\n", hr);
- aluHandleDisconnect(device);
- return 0;
- }
-
SetRTPriority();
update_size = device->UpdateSize;
@@ -318,11 +307,11 @@ static ALuint MMDevApiProc(ALvoid *ptr)
}
len -= len%update_size;
- hr = IAudioRenderClient_GetBuffer(render.iface, len, &buffer);
+ hr = IAudioRenderClient_GetBuffer(data->render, len, &buffer);
if(SUCCEEDED(hr))
{
aluMixData(device, buffer, len);
- hr = IAudioRenderClient_ReleaseBuffer(render.iface, len, 0);
+ hr = IAudioRenderClient_ReleaseBuffer(data->render, len, 0);
}
if(FAILED(hr))
{
@@ -332,8 +321,6 @@ static ALuint MMDevApiProc(ALvoid *ptr)
}
}
- IAudioRenderClient_Release(render.iface);
-
CoUninitialize();
return 0;
}
@@ -386,6 +373,7 @@ static HRESULT DoReset(ALCdevice *device)
REFERENCE_TIME min_per, buf_time;
UINT32 buffer_len, min_len;
HRESULT hr;
+ void *ptr;
hr = IAudioClient_GetMixFormat(data->client, &wfx);
if(FAILED(hr))
@@ -612,9 +600,17 @@ static HRESULT DoReset(ALCdevice *device)
return hr;
}
- data->thread = StartThread(MMDevApiProc, device);
+ hr = IAudioClient_GetService(data->client, &IID_IAudioRenderClient, &ptr);
+ if(SUCCEEDED(hr))
+ {
+ data->render = ptr;
+ data->thread = StartThread(MMDevApiProc, device);
+ }
if(!data->thread)
{
+ if(data->render)
+ IAudioRenderClient_Release(data->render);
+ data->render = NULL;
IAudioClient_Stop(data->client);
ERR("Failed to start thread\n");
return E_FAIL;
@@ -725,6 +721,8 @@ static DWORD CALLBACK MMDevApiMsgProc(void *ptr)
data->killNow = 0;
+ IAudioRenderClient_Release(data->render);
+ data->render = NULL;
IAudioClient_Stop(data->client);
}