From 05b6646d7a56b8cacdf278d57723387d9e76dcd0 Mon Sep 17 00:00:00 2001 From: Kevin Mitchell Date: Mon, 21 Dec 2015 00:08:07 -0800 Subject: ao_wasapi: correctly handle audio session display failure In particular, try and release/null the interface so that it won't be marshalled. --- audio/out/ao_wasapi_utils.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'audio') diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c index 9f672b24f5..c30c4c7375 100755 --- a/audio/out/ao_wasapi_utils.c +++ b/audio/out/ao_wasapi_utils.c @@ -607,28 +607,33 @@ exit_label: return hr; } -static HRESULT init_session_display(struct wasapi_state *state) { - wchar_t path[MAX_PATH+12] = {0}; - +static void init_session_display(struct wasapi_state *state) { HRESULT hr = IAudioClient_GetService(state->pAudioClient, &IID_IAudioSessionControl, (void **)&state->pSessionControl); EXIT_ON_ERROR(hr); + wchar_t path[MAX_PATH+12] = {0}; GetModuleFileNameW(NULL, path, MAX_PATH); lstrcatW(path, L",-IDI_ICON1"); + hr = IAudioSessionControl_SetIconPath(state->pSessionControl, path, NULL); + if (FAILED(hr)) { + // don't goto exit_label here since SetDisplayName might still work + MP_WARN(state, "Error setting audio session icon: %s\n", + mp_HRESULT_to_str(hr)); + } hr = IAudioSessionControl_SetDisplayName(state->pSessionControl, MIXER_DEFAULT_LABEL, NULL); EXIT_ON_ERROR(hr); - hr = IAudioSessionControl_SetIconPath(state->pSessionControl, path, NULL); - EXIT_ON_ERROR(hr); - - return S_OK; + return; exit_label: + // if we got here then the session control is useless - release it + SAFE_RELEASE(state->pSessionControl, + IAudioSessionControl_Release(state->pSessionControl)); MP_WARN(state, "Error setting audio session display name: %s\n", mp_HRESULT_to_str(hr)); - return S_OK; // No reason to abort initialization. + return; } static HRESULT fix_format(struct ao *ao) @@ -719,8 +724,7 @@ reinit: hr = init_clock(state); EXIT_ON_ERROR(hr); - hr = init_session_display(state); - EXIT_ON_ERROR(hr); + init_session_display(state); state->hTask = AvSetMmThreadCharacteristics(L"Pro Audio", &(DWORD){0}); if (!state->hTask) { -- cgit v1.2.3