mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-23 16:54:03 +02:00
WASAPI: Fix a bug where a result code is not getting checked.
This was not propagating the result code when retrieving the render or capture client from an audio client.
This commit is contained in:
+6
-5
@@ -3605,7 +3605,7 @@ typedef struct
|
|||||||
ma_device_type deviceType;
|
ma_device_type deviceType;
|
||||||
void* pAudioClient;
|
void* pAudioClient;
|
||||||
void** ppAudioClientService;
|
void** ppAudioClientService;
|
||||||
ma_result result; /* The result from creating the audio client service. */
|
ma_result* pResult; /* The result from creating the audio client service. */
|
||||||
} createAudioClient;
|
} createAudioClient;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
@@ -13977,9 +13977,9 @@ static ma_thread_result MA_THREADCALL ma_context_command_thread__wasapi(void* pU
|
|||||||
case MA_CONTEXT_COMMAND_CREATE_IAUDIOCLIENT__WASAPI:
|
case MA_CONTEXT_COMMAND_CREATE_IAUDIOCLIENT__WASAPI:
|
||||||
{
|
{
|
||||||
if (cmd.data.createAudioClient.deviceType == ma_device_type_playback) {
|
if (cmd.data.createAudioClient.deviceType == ma_device_type_playback) {
|
||||||
result = ma_result_from_HRESULT(ma_IAudioClient_GetService((ma_IAudioClient*)cmd.data.createAudioClient.pAudioClient, &MA_IID_IAudioRenderClient, cmd.data.createAudioClient.ppAudioClientService));
|
*cmd.data.createAudioClient.pResult = ma_result_from_HRESULT(ma_IAudioClient_GetService((ma_IAudioClient*)cmd.data.createAudioClient.pAudioClient, &MA_IID_IAudioRenderClient, cmd.data.createAudioClient.ppAudioClientService));
|
||||||
} else {
|
} else {
|
||||||
result = ma_result_from_HRESULT(ma_IAudioClient_GetService((ma_IAudioClient*)cmd.data.createAudioClient.pAudioClient, &MA_IID_IAudioCaptureClient, cmd.data.createAudioClient.ppAudioClientService));
|
*cmd.data.createAudioClient.pResult = ma_result_from_HRESULT(ma_IAudioClient_GetService((ma_IAudioClient*)cmd.data.createAudioClient.pAudioClient, &MA_IID_IAudioCaptureClient, cmd.data.createAudioClient.ppAudioClientService));
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@@ -14022,18 +14022,19 @@ static ma_thread_result MA_THREADCALL ma_context_command_thread__wasapi(void* pU
|
|||||||
static ma_result ma_device_create_IAudioClient_service__wasapi(ma_context* pContext, ma_device_type deviceType, ma_IAudioClient* pAudioClient, void** ppAudioClientService)
|
static ma_result ma_device_create_IAudioClient_service__wasapi(ma_context* pContext, ma_device_type deviceType, ma_IAudioClient* pAudioClient, void** ppAudioClientService)
|
||||||
{
|
{
|
||||||
ma_result result;
|
ma_result result;
|
||||||
|
ma_result cmdResult;
|
||||||
ma_context_command__wasapi cmd = ma_context_init_command__wasapi(MA_CONTEXT_COMMAND_CREATE_IAUDIOCLIENT__WASAPI);
|
ma_context_command__wasapi cmd = ma_context_init_command__wasapi(MA_CONTEXT_COMMAND_CREATE_IAUDIOCLIENT__WASAPI);
|
||||||
cmd.data.createAudioClient.deviceType = deviceType;
|
cmd.data.createAudioClient.deviceType = deviceType;
|
||||||
cmd.data.createAudioClient.pAudioClient = (void*)pAudioClient;
|
cmd.data.createAudioClient.pAudioClient = (void*)pAudioClient;
|
||||||
cmd.data.createAudioClient.ppAudioClientService = ppAudioClientService;
|
cmd.data.createAudioClient.ppAudioClientService = ppAudioClientService;
|
||||||
cmd.data.createAudioClient.result = MA_SUCCESS;
|
cmd.data.createAudioClient.pResult = &cmdResult; /* Declared locally, but won't be dereferenced after this function returns since execution of the command will wait here. */
|
||||||
|
|
||||||
result = ma_context_post_command__wasapi(pContext, &cmd); /* This will not return until the command has actually been run. */
|
result = ma_context_post_command__wasapi(pContext, &cmd); /* This will not return until the command has actually been run. */
|
||||||
if (result != MA_SUCCESS) {
|
if (result != MA_SUCCESS) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd.data.createAudioClient.result;
|
return *cmd.data.createAudioClient.pResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 /* Not used at the moment, but leaving here for future use. */
|
#if 0 /* Not used at the moment, but leaving here for future use. */
|
||||||
|
|||||||
Reference in New Issue
Block a user