summaryrefslogtreecommitdiffstats
path: root/audio/out
diff options
context:
space:
mode:
authorKevin Mitchell <kevmitch@gmail.com>2015-12-21 00:08:07 -0800
committerKevin Mitchell <kevmitch@gmail.com>2015-12-21 05:23:26 -0800
commit05b6646d7a56b8cacdf278d57723387d9e76dcd0 (patch)
tree5b5327b2e3029772887a2fff87f0661ef312f1ad /audio/out
parent35296c1f3357cf4ee17f2a6ad58c1ff3e550070d (diff)
downloadmpv-05b6646d7a56b8cacdf278d57723387d9e76dcd0.tar.bz2
mpv-05b6646d7a56b8cacdf278d57723387d9e76dcd0.tar.xz
ao_wasapi: correctly handle audio session display failure
In particular, try and release/null the interface so that it won't be marshalled.
Diffstat (limited to 'audio/out')
-rwxr-xr-xaudio/out/ao_wasapi_utils.c24
1 files changed, 14 insertions, 10 deletions
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) {