[vlc-devel] [PATCH] winstore: handle volume/mute in the winstore audio output
Steve Lhomme
robux4 at videolabs.io
Mon May 16 13:21:31 CEST 2016
--
replaces an old patch that was using the output stream to access the client
---
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 b5a9233..4d17211 100644
--- a/modules/audio_output/winstore.c
+++ b/modules/audio_output/winstore.c
@@ -58,6 +58,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;
@@ -194,6 +258,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;
--
2.8.1
More information about the vlc-devel
mailing list