diff options
author | Kevin Mitchell <kevmitch@gmail.com> | 2015-12-21 03:34:25 -0800 |
---|---|---|
committer | Kevin Mitchell <kevmitch@gmail.com> | 2015-12-21 05:23:26 -0800 |
commit | 0afb1acab3691dfed8585f9438b34b05e8094ca0 (patch) | |
tree | 628a986a0b5688a953455a6ed35355d3df5a7e0c /audio/out | |
parent | 05b6646d7a56b8cacdf278d57723387d9e76dcd0 (diff) | |
download | mpv-0afb1acab3691dfed8585f9438b34b05e8094ca0.tar.bz2 mpv-0afb1acab3691dfed8585f9438b34b05e8094ca0.tar.xz |
ao_wasapi: move volume control init to it's own function
also make failure non-fatal
Diffstat (limited to 'audio/out')
-rwxr-xr-x | audio/out/ao_wasapi_utils.c | 55 |
1 files changed, 34 insertions, 21 deletions
diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c index c30c4c7375..d465c17eaf 100755 --- a/audio/out/ao_wasapi_utils.c +++ b/audio/out/ao_wasapi_utils.c @@ -636,6 +636,39 @@ exit_label: return; } +static void init_volume_control(struct wasapi_state *state) +{ + HRESULT hr; + if (state->share_mode == AUDCLNT_SHAREMODE_EXCLUSIVE) { + MP_DBG(state, "Activating pEndpointVolume interface\n"); + hr = IMMDeviceActivator_Activate(state->pDevice, + &IID_IAudioEndpointVolume, + CLSCTX_ALL, NULL, + (void **)&state->pEndpointVolume); + EXIT_ON_ERROR(hr); + + MP_DBG(state, "IAudioEndpointVolume::QueryHardwareSupport\n"); + hr = IAudioEndpointVolume_QueryHardwareSupport(state->pEndpointVolume, + &state->vol_hw_support); + EXIT_ON_ERROR(hr); + } else { + MP_DBG(state, "IAudioClient::Initialize pAudioVolume\n"); + hr = IAudioClient_GetService(state->pAudioClient, + &IID_ISimpleAudioVolume, + (void **)&state->pAudioVolume); + EXIT_ON_ERROR(hr); + } + return; +exit_label: + state->vol_hw_support = 0; + SAFE_RELEASE(state->pEndpointVolume, + IAudioEndpointVolume_Release(state->pEndpointVolume)); + SAFE_RELEASE(state->pAudioVolume, + ISimpleAudioVolume_Release(state->pAudioVolume)); + MP_WARN(state, "Error setting up volume control: %s\n", + mp_HRESULT_to_str(hr)); +} + static HRESULT fix_format(struct ao *ao) { struct wasapi_state *state = ao->priv; @@ -699,12 +732,6 @@ reinit: (void **)&state->pRenderClient); EXIT_ON_ERROR(hr); - MP_DBG(state, "IAudioClient::Initialize pAudioVolume\n"); - hr = IAudioClient_GetService(state->pAudioClient, - &IID_ISimpleAudioVolume, - (void **)&state->pAudioVolume); - EXIT_ON_ERROR(hr); - MP_DBG(state, "IAudioClient::Initialize IAudioClient_SetEventHandle\n"); hr = IAudioClient_SetEventHandle(state->pAudioClient, state->hWake); EXIT_ON_ERROR(hr); @@ -725,6 +752,7 @@ reinit: EXIT_ON_ERROR(hr); init_session_display(state); + init_volume_control(state); state->hTask = AvSetMmThreadCharacteristics(L"Pro Audio", &(DWORD){0}); if (!state->hTask) { @@ -1132,21 +1160,6 @@ retry: ; (void **)&state->pAudioClient); EXIT_ON_ERROR(hr); - MP_DBG(ao, "Activating pEndpointVolume interface\n"); - hr = IMMDeviceActivator_Activate(state->pDevice, &IID_IAudioEndpointVolume, - CLSCTX_ALL, NULL, - (void **)&state->pEndpointVolume); - EXIT_ON_ERROR(hr); - - MP_DBG(ao, "Query hardware volume support\n"); - hr = IAudioEndpointVolume_QueryHardwareSupport(state->pEndpointVolume, - &state->vol_hw_support); - if (hr != S_OK) { - MP_WARN(ao, "Error querying hardware volume control: %s\n", - mp_HRESULT_to_str(hr)); - state->vol_hw_support = 0; - } - MP_DBG(ao, "Probing formats\n"); if (!find_formats(ao)) { hr = E_FAIL; |