mirror of https://github.com/mpv-player/mpv
ao_wasapi: split exclusive/shared specific ao controls
this avoids having to check if we're exclusive or shared for every control
This commit is contained in:
parent
e15526153e
commit
aa5f04c7a0
|
@ -290,55 +290,78 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
||||||
ao_control_vol_t *vol = arg;
|
ao_control_vol_t *vol = arg;
|
||||||
BOOL mute;
|
BOOL mute;
|
||||||
|
|
||||||
switch (cmd) {
|
if (state->opt_exclusive) {
|
||||||
case AOCONTROL_GET_VOLUME:
|
// exclusive-specific
|
||||||
if (state->opt_exclusive)
|
switch (cmd) {
|
||||||
|
case AOCONTROL_GET_VOLUME:
|
||||||
IAudioEndpointVolume_GetMasterVolumeLevelScalar(state->pEndpointVolumeProxy,
|
IAudioEndpointVolume_GetMasterVolumeLevelScalar(state->pEndpointVolumeProxy,
|
||||||
&state->audio_volume);
|
&state->audio_volume);
|
||||||
else
|
/* check to see if user manually changed volume through mixer;
|
||||||
|
this information is used in exclusive mode for restoring the mixer volume on uninit */
|
||||||
|
if (state->audio_volume != state->previous_volume) {
|
||||||
|
MP_VERBOSE(state, "Mixer difference: %.2g now, expected %.2g\n",
|
||||||
|
state->audio_volume, state->previous_volume);
|
||||||
|
state->initial_volume = state->audio_volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
vol->left = vol->right = 100.0f * state->audio_volume;
|
||||||
|
return CONTROL_OK;
|
||||||
|
case AOCONTROL_SET_VOLUME:
|
||||||
|
state->audio_volume = vol->left / 100.f;
|
||||||
|
IAudioEndpointVolume_SetMasterVolumeLevelScalar(state->pEndpointVolumeProxy,
|
||||||
|
state->audio_volume, NULL);
|
||||||
|
state->previous_volume = state->audio_volume;
|
||||||
|
return CONTROL_OK;
|
||||||
|
case AOCONTROL_GET_MUTE:
|
||||||
|
IAudioEndpointVolume_GetMute(state->pEndpointVolumeProxy, &mute);
|
||||||
|
*(bool*)arg = mute;
|
||||||
|
return CONTROL_OK;
|
||||||
|
case AOCONTROL_SET_MUTE:
|
||||||
|
mute = *(bool*)arg;
|
||||||
|
IAudioEndpointVolume_SetMute(state->pEndpointVolumeProxy, mute, NULL);
|
||||||
|
return CONTROL_OK;
|
||||||
|
case AOCONTROL_HAS_PER_APP_VOLUME:
|
||||||
|
return CONTROL_FALSE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// shared-specific
|
||||||
|
switch (cmd) {
|
||||||
|
case AOCONTROL_GET_VOLUME:
|
||||||
ISimpleAudioVolume_GetMasterVolume(state->pAudioVolumeProxy,
|
ISimpleAudioVolume_GetMasterVolume(state->pAudioVolumeProxy,
|
||||||
&state->audio_volume);
|
&state->audio_volume);
|
||||||
|
|
||||||
/* check to see if user manually changed volume through mixer;
|
/* check to see if user manually changed volume through mixer;
|
||||||
this information is used in exclusive mode for restoring the mixer volume on uninit */
|
this information is used in exclusive mode for restoring the mixer volume on uninit */
|
||||||
if (state->audio_volume != state->previous_volume) {
|
if (state->audio_volume != state->previous_volume) {
|
||||||
MP_VERBOSE(state, "Mixer difference: %.2g now, expected %.2g\n",
|
MP_VERBOSE(state, "Mixer difference: %.2g now, expected %.2g\n",
|
||||||
state->audio_volume, state->previous_volume);
|
state->audio_volume, state->previous_volume);
|
||||||
state->initial_volume = state->audio_volume;
|
state->initial_volume = state->audio_volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
vol->left = vol->right = 100.0f * state->audio_volume;
|
vol->left = vol->right = 100.0f * state->audio_volume;
|
||||||
return CONTROL_OK;
|
return CONTROL_OK;
|
||||||
case AOCONTROL_SET_VOLUME:
|
case AOCONTROL_SET_VOLUME:
|
||||||
state->audio_volume = vol->left / 100.f;
|
state->audio_volume = vol->left / 100.f;
|
||||||
if (state->opt_exclusive)
|
|
||||||
IAudioEndpointVolume_SetMasterVolumeLevelScalar(state->pEndpointVolumeProxy,
|
|
||||||
state->audio_volume, NULL);
|
|
||||||
else
|
|
||||||
ISimpleAudioVolume_SetMasterVolume(state->pAudioVolumeProxy,
|
ISimpleAudioVolume_SetMasterVolume(state->pAudioVolumeProxy,
|
||||||
state->audio_volume, NULL);
|
state->audio_volume, NULL);
|
||||||
|
|
||||||
state->previous_volume = state->audio_volume;
|
state->previous_volume = state->audio_volume;
|
||||||
return CONTROL_OK;
|
return CONTROL_OK;
|
||||||
case AOCONTROL_GET_MUTE:
|
case AOCONTROL_GET_MUTE:
|
||||||
if (state->opt_exclusive)
|
|
||||||
IAudioEndpointVolume_GetMute(state->pEndpointVolumeProxy, &mute);
|
|
||||||
else
|
|
||||||
ISimpleAudioVolume_GetMute(state->pAudioVolumeProxy, &mute);
|
ISimpleAudioVolume_GetMute(state->pAudioVolumeProxy, &mute);
|
||||||
*(bool*)arg = mute;
|
*(bool*)arg = mute;
|
||||||
|
return CONTROL_OK;
|
||||||
return CONTROL_OK;
|
case AOCONTROL_SET_MUTE:
|
||||||
case AOCONTROL_SET_MUTE:
|
mute = *(bool*)arg;
|
||||||
mute = *(bool*)arg;
|
|
||||||
if (state->opt_exclusive)
|
|
||||||
IAudioEndpointVolume_SetMute(state->pEndpointVolumeProxy, mute, NULL);
|
|
||||||
else
|
|
||||||
ISimpleAudioVolume_SetMute(state->pAudioVolumeProxy, mute, NULL);
|
ISimpleAudioVolume_SetMute(state->pAudioVolumeProxy, mute, NULL);
|
||||||
|
return CONTROL_OK;
|
||||||
|
case AOCONTROL_HAS_PER_APP_VOLUME:
|
||||||
|
return CONTROL_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return CONTROL_OK;
|
// common to exclusive and shared
|
||||||
case AOCONTROL_HAS_PER_APP_VOLUME:
|
switch (cmd) {
|
||||||
return state->share_mode == AUDCLNT_SHAREMODE_SHARED ?
|
|
||||||
CONTROL_TRUE : CONTROL_FALSE;
|
|
||||||
case AOCONTROL_UPDATE_STREAM_TITLE: {
|
case AOCONTROL_UPDATE_STREAM_TITLE: {
|
||||||
MP_VERBOSE(state, "Updating stream title to \"%s\"\n", (char*)arg);
|
MP_VERBOSE(state, "Updating stream title to \"%s\"\n", (char*)arg);
|
||||||
wchar_t *title = mp_from_utf8(NULL, (char*)arg);
|
wchar_t *title = mp_from_utf8(NULL, (char*)arg);
|
||||||
|
|
Loading…
Reference in New Issue