Commit 350e328a authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

wasapi: fix corner (error) case and simplify a little

parent 5d837145
...@@ -83,10 +83,6 @@ struct aout_sys_t ...@@ -83,10 +83,6 @@ struct aout_sys_t
IAudioRenderClient *render; IAudioRenderClient *render;
IAudioClock *clock; IAudioClock *clock;
union
{
ISimpleAudioVolume *simple;
} volume;
IAudioSessionControl *control; IAudioSessionControl *control;
struct IAudioSessionEvents events; struct IAudioSessionEvents events;
LONG refs; LONG refs;
...@@ -207,30 +203,50 @@ static void Flush(audio_output_t *aout, bool wait) ...@@ -207,30 +203,50 @@ static void Flush(audio_output_t *aout, bool wait)
static int SimpleVolumeSet(audio_output_t *aout, float vol) static int SimpleVolumeSet(audio_output_t *aout, float vol)
{ {
aout_sys_t *sys = aout->sys; ISimpleAudioVolume *simple;
HRESULT hr; HRESULT hr;
if (TryEnter(aout)) if (TryEnter(aout))
return -1; return -1;
hr = ISimpleAudioVolume_SetMasterVolume(sys->volume.simple, vol, NULL); hr = IAudioClient_GetService(aout->sys->client, &IID_ISimpleAudioVolume,
if (FAILED(hr)) (void **)&simple);
msg_Warn(aout, "cannot set session volume (error 0x%lx)", hr); if (SUCCEEDED(hr))
{
hr = ISimpleAudioVolume_SetMasterVolume(simple, vol, NULL);
ISimpleAudioVolume_Release(simple);
}
Leave(); Leave();
return FAILED(hr) ? -1 : 0;
if (FAILED(hr))
{
msg_Err(aout, "cannot set volume (error 0x%lx)", hr);
return -1;
}
return 0;
} }
static int SimpleMuteSet(audio_output_t *aout, bool mute) static int SimpleMuteSet(audio_output_t *aout, bool mute)
{ {
aout_sys_t *sys = aout->sys; ISimpleAudioVolume *simple;
HRESULT hr; HRESULT hr;
if (TryEnter(aout)) if (TryEnter(aout))
return -1; return -1;
hr = ISimpleAudioVolume_SetMute(sys->volume.simple, mute, NULL); hr = IAudioClient_GetService(aout->sys->client, &IID_ISimpleAudioVolume,
if (FAILED(hr)) (void **)&simple);
msg_Warn(aout, "cannot mute session (error 0x%lx)", hr); if (SUCCEEDED(hr))
{
hr = ISimpleAudioVolume_SetMute(simple, mute, NULL);
ISimpleAudioVolume_Release(simple);
}
Leave(); Leave();
return FAILED(hr) ? -1 : 0;
if (FAILED(hr))
{
msg_Err(aout, "cannot set mute (error 0x%lx)", hr);
return -1;
}
return 0;
} }
...@@ -576,12 +592,6 @@ static void MTAThread(void *data) ...@@ -576,12 +592,6 @@ static void MTAThread(void *data)
if (FAILED(hr)) if (FAILED(hr))
msg_Warn(aout, "cannot get audio clock (error 0x%lx)", hr); msg_Warn(aout, "cannot get audio clock (error 0x%lx)", hr);
/*if (AOUT_FMT_LINEAR(&format) && !exclusive)*/
{
hr = IAudioClient_GetService(sys->client, &IID_ISimpleAudioVolume,
(void **)&sys->volume.simple);
}
hr = IAudioClient_GetService(sys->client, &IID_IAudioSessionControl, hr = IAudioClient_GetService(sys->client, &IID_IAudioSessionControl,
(void **)&sys->control); (void **)&sys->control);
if (FAILED(hr)) if (FAILED(hr))
...@@ -599,11 +609,6 @@ static void MTAThread(void *data) ...@@ -599,11 +609,6 @@ static void MTAThread(void *data)
if (sys->control != NULL) if (sys->control != NULL)
IAudioSessionControl_Release(sys->control); IAudioSessionControl_Release(sys->control);
/*if (AOUT_FMT_LINEAR(&format) && !exclusive)*/
{
if (sys->volume.simple != NULL)
ISimpleAudioVolume_Release(sys->volume.simple);
}
if (sys->clock != NULL) if (sys->clock != NULL)
IAudioClock_Release(sys->clock); IAudioClock_Release(sys->clock);
IAudioRenderClient_Release(sys->render); IAudioRenderClient_Release(sys->render);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment