[vlc-commits] mmdevice: fix opening of invalid device
Thomas Guillem
git at videolan.org
Fri Feb 9 13:42:30 CET 2018
vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Feb 9 13:29:29 2018 +0100| [3475766f7a58bd7d28402d7184e5110e1fc8b091] | committer: Jean-Baptiste Kempf
mmdevice: fix opening of invalid device
CD 6f95511a-91a2-45de-bd43-735bf52a2185
And check sys->dev locked since it can be written from the MMSession thread.
(cherry picked from commit a715eaa04c611de267022964c59566779539d6e6)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=3475766f7a58bd7d28402d7184e5110e1fc8b091
---
modules/audio_output/mmdevice.c | 40 ++++++++++++++++++++++++----------------
1 file changed, 24 insertions(+), 16 deletions(-)
diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index e225eaab12..fddc9d4eb3 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -1086,9 +1086,6 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
{
aout_sys_t *sys = aout->sys;
- if (sys->dev == NULL)
- return -1;
-
const bool b_spdif = AOUT_FMT_SPDIF(fmt);
const bool b_hdmi = AOUT_FMT_HDMI(fmt);
if (b_spdif || b_hdmi)
@@ -1116,6 +1113,14 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
EnterMTA();
EnterCriticalSection(&sys->lock);
+
+ if (sys->dev == NULL)
+ {
+ LeaveCriticalSection(&sys->lock);
+ LeaveMTA();
+ return -1;
+ }
+
for (;;)
{
HRESULT hr;
@@ -1149,25 +1154,28 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
break;
}
- IPropertyStore *props;
- HRESULT hr = IMMDevice_OpenPropertyStore(sys->dev, STGM_READ, &props);
- if (SUCCEEDED(hr))
+ if (sys->module != NULL)
{
- PROPVARIANT v;
- PropVariantInit(&v);
- hr = IPropertyStore_GetValue(props, &PKEY_AudioEndpoint_FormFactor, &v);
+ IPropertyStore *props;
+ HRESULT hr = IMMDevice_OpenPropertyStore(sys->dev, STGM_READ, &props);
if (SUCCEEDED(hr))
{
- switch (v.uintVal)
+ PROPVARIANT v;
+ PropVariantInit(&v);
+ hr = IPropertyStore_GetValue(props, &PKEY_AudioEndpoint_FormFactor, &v);
+ if (SUCCEEDED(hr))
{
- case Headphones:
- case Headset:
- aout->current_sink_info.headphones = true;
- break;
+ switch (v.uintVal)
+ {
+ case Headphones:
+ case Headset:
+ aout->current_sink_info.headphones = true;
+ break;
+ }
+ PropVariantClear(&v);
}
- PropVariantClear(&v);
+ IPropertyStore_Release(props);
}
- IPropertyStore_Release(props);
}
LeaveCriticalSection(&sys->lock);
More information about the vlc-commits
mailing list