vlc | branch: master | Steve Lhomme <[email protected]> | Mon May 16 13:21:31 2016 +0200| [1e0bedf62b378320d7fa305157dd2b64482a4f96] | committer: Jean-Baptiste Kempf
winstore: handle volume/mute in the winstore audio output Signed-off-by: Jean-Baptiste Kempf <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1e0bedf62b378320d7fa305157dd2b64482a4f96 --- modules/audio_output/winstore.c | 66 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/modules/audio_output/winstore.c b/modules/audio_output/winstore.c index 4734f39..a292841 100644 --- a/modules/audio_output/winstore.c +++ b/modules/audio_output/winstore.c @@ -57,6 +57,70 @@ struct aout_sys_t IAudioClient *client; }; + +static int VolumeSet(audio_output_t *aout, float vol) +{ + aout_sys_t *sys = aout->sys; + HRESULT hr; + ISimpleAudioVolume *pc_AudioVolume = NULL; + float gain = 1.f; + + vol = vol * vol * vol; /* ISimpleAudioVolume is tapered linearly. */ + + if (vol > 1.f) + { + gain = vol; + vol = 1.f; + } + + aout_GainRequest(aout, gain); + + hr = IAudioClient_GetService(sys->client, &IID_ISimpleAudioVolume, &pc_AudioVolume); + if (FAILED(hr)) + { + msg_Err(aout, "cannot get volume service (error 0x%lx)", hr); + goto done; + } + + hr = ISimpleAudioVolume_SetMasterVolume(pc_AudioVolume, vol, NULL); + if (FAILED(hr)) + { + msg_Err(aout, "cannot set volume (error 0x%lx)", hr); + goto done; + } + +done: + ISimpleAudioVolume_Release(pc_AudioVolume); + + return SUCCEEDED(hr) ? 0 : -1; +} + +static int MuteSet(audio_output_t *aout, bool mute) +{ + aout_sys_t *sys = aout->sys; + HRESULT hr; + ISimpleAudioVolume *pc_AudioVolume = NULL; + + hr = IAudioClient_GetService(sys->client, &IID_ISimpleAudioVolume, &pc_AudioVolume); + if (FAILED(hr)) + { + msg_Err(aout, "cannot get volume service (error 0x%lx)", hr); + goto done; + } + + hr = ISimpleAudioVolume_SetMute(pc_AudioVolume, mute, NULL); + if (FAILED(hr)) + { + msg_Err(aout, "cannot set mute (error 0x%lx)", hr); + goto done; + } + +done: + ISimpleAudioVolume_Release(pc_AudioVolume); + + return SUCCEEDED(hr) ? 0 : -1; +} + static int TimeGet(audio_output_t *aout, mtime_t *restrict delay) { aout_sys_t *sys = aout->sys; @@ -193,6 +257,8 @@ static int Open(vlc_object_t *obj) aout->start = Start; aout->stop = Stop; aout->time_get = TimeGet; + aout->volume_set = VolumeSet; + aout->mute_set = MuteSet; aout->play = Play; aout->pause = Pause; aout->flush = Flush; _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
