summaryrefslogtreecommitdiffstats
path: root/audio/out
diff options
context:
space:
mode:
authorKevin Mitchell <kevmitch@gmail.com>2015-12-18 23:45:25 -0800
committerKevin Mitchell <kevmitch@gmail.com>2015-12-20 03:30:28 -0800
commit517a35da948e2515c1d203c9215f67f2c5105688 (patch)
treee38aef802619ea6c8c1449cb645ca3bcf9c17ee7 /audio/out
parent821e8fb9d04c593a041fae10876db9ffb1fe2ce2 (diff)
downloadmpv-517a35da948e2515c1d203c9215f67f2c5105688.tar.bz2
mpv-517a35da948e2515c1d203c9215f67f2c5105688.tar.xz
ao_wasapi: check for proxy availability in control
Make sure that the proxy has been created before using it. This will be used when a future commit makes proxy setup optional.
Diffstat (limited to 'audio/out')
-rw-r--r--audio/out/ao_wasapi.c59
1 files changed, 37 insertions, 22 deletions
diff --git a/audio/out/ao_wasapi.c b/audio/out/ao_wasapi.c
index f819f1fcbd..52c2536d5c 100644
--- a/audio/out/ao_wasapi.c
+++ b/audio/out/ao_wasapi.c
@@ -295,8 +295,10 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
switch (cmd) {
case AOCONTROL_GET_VOLUME:
case AOCONTROL_SET_VOLUME:
- if (!(state->vol_hw_support & ENDPOINT_HARDWARE_SUPPORT_VOLUME))
+ if (!state->pEndpointVolumeProxy ||
+ !(state->vol_hw_support & ENDPOINT_HARDWARE_SUPPORT_VOLUME)) {
return CONTROL_FALSE;
+ }
switch (cmd) {
case AOCONTROL_GET_VOLUME:
IAudioEndpointVolume_GetMasterVolumeLevelScalar(state->pEndpointVolumeProxy,
@@ -314,8 +316,10 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
}
case AOCONTROL_GET_MUTE:
case AOCONTROL_SET_MUTE:
- if (!(state->vol_hw_support & ENDPOINT_HARDWARE_SUPPORT_MUTE))
+ if (!state->pEndpointVolumeProxy ||
+ !(state->vol_hw_support & ENDPOINT_HARDWARE_SUPPORT_MUTE)) {
return CONTROL_FALSE;
+ }
switch (cmd) {
case AOCONTROL_GET_MUTE:
IAudioEndpointVolume_GetMute(state->pEndpointVolumeProxy, &mute);
@@ -333,34 +337,46 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
// shared-specific
switch (cmd) {
case AOCONTROL_GET_VOLUME:
- ISimpleAudioVolume_GetMasterVolume(state->pAudioVolumeProxy,
- &volume);
- *(ao_control_vol_t *)arg = (ao_control_vol_t){
- .left = 100.0f * volume,
- .right = 100.0f * volume,
- };
- return CONTROL_OK;
case AOCONTROL_SET_VOLUME:
- volume = ((ao_control_vol_t *)arg)->left / 100.f;
- ISimpleAudioVolume_SetMasterVolume(state->pAudioVolumeProxy,
- volume, NULL);
- return CONTROL_OK;
case AOCONTROL_GET_MUTE:
- ISimpleAudioVolume_GetMute(state->pAudioVolumeProxy, &mute);
- *(bool *)arg = mute;
- return CONTROL_OK;
case AOCONTROL_SET_MUTE:
- mute = *(bool *)arg;
- ISimpleAudioVolume_SetMute(state->pAudioVolumeProxy, mute, NULL);
- return CONTROL_OK;
case AOCONTROL_HAS_PER_APP_VOLUME:
- return CONTROL_TRUE;
+ if (!state->pAudioVolumeProxy)
+ return CONTROL_FALSE;
+ switch(cmd) {
+ case AOCONTROL_GET_VOLUME:
+ ISimpleAudioVolume_GetMasterVolume(state->pAudioVolumeProxy,
+ &volume);
+ *(ao_control_vol_t *)arg = (ao_control_vol_t){
+ .left = 100.0f * volume,
+ .right = 100.0f * volume,
+ };
+ return CONTROL_OK;
+ case AOCONTROL_SET_VOLUME:
+ volume = ((ao_control_vol_t *)arg)->left / 100.f;
+ ISimpleAudioVolume_SetMasterVolume(state->pAudioVolumeProxy,
+ volume, NULL);
+ return CONTROL_OK;
+ case AOCONTROL_GET_MUTE:
+ ISimpleAudioVolume_GetMute(state->pAudioVolumeProxy, &mute);
+ *(bool *)arg = mute;
+ return CONTROL_OK;
+ case AOCONTROL_SET_MUTE:
+ mute = *(bool *)arg;
+ ISimpleAudioVolume_SetMute(state->pAudioVolumeProxy, mute, NULL);
+ return CONTROL_OK;
+ case AOCONTROL_HAS_PER_APP_VOLUME:
+ return CONTROL_TRUE;
+ }
}
}
// common to exclusive and shared
switch (cmd) {
- case AOCONTROL_UPDATE_STREAM_TITLE: {
+ case AOCONTROL_UPDATE_STREAM_TITLE:
+ if (!state->pSessionControlProxy)
+ return CONTROL_FALSE;
+
MP_VERBOSE(state, "Updating stream title to \"%s\"\n", (char*)arg);
wchar_t *title = mp_from_utf8(NULL, (char*)arg);
@@ -379,7 +395,6 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
talloc_free(title);
return CONTROL_OK;
- }
default:
return CONTROL_UNKNOWN;
}