summaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
Diffstat (limited to 'Alc')
-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);
}