[vlc-commits] mmdevice: fix restart when switching from 0 to 1 device
Thomas Guillem
git at videolan.org
Tue Apr 17 19:24:20 CEST 2018
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Apr 17 19:11:34 2018 +0200| [088533d6d9da13afcca0db855b2ba862e5f48576] | committer: Thomas Guillem
mmdevice: fix restart when switching from 0 to 1 device
- aout_RestartRequest() was not called because of a NULL sys->acquired_device,
- DeviceRestartLocked() was not called from Start() because of the early
sys->dev check,
- sys->acquired_device was not reset to NULL (when switching from 1 to 0
devices).
Reminder: sys->dev and sys->acquired_device are NULL if the aout is opened
without any audio devices plugged.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=088533d6d9da13afcca0db855b2ba862e5f48576
---
modules/audio_output/mmdevice.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index 1e88f0f1f2..50fd440639 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -585,7 +585,7 @@ vlc_MMNotificationClient_OnDefaultDeviceChange(IMMNotificationClient *this,
return S_OK;
EnterCriticalSection(&sys->lock);
- if (sys->acquired_device == default_device)
+ if (sys->acquired_device == NULL || sys->acquired_device == default_device)
{
msg_Dbg(aout, "default device changed: %ls", wid);
sys->request_device_restart = true;
@@ -769,8 +769,8 @@ static int DeviceRestartLocked(audio_output_t *aout)
{
aout_sys_t *sys = aout->sys;
assert(sys->requested_device == NULL);
- assert(sys->acquired_device != NULL);
- sys->requested_device = sys->acquired_device;
+ sys->requested_device = sys->acquired_device ? sys->acquired_device
+ : default_device;
return DeviceRequestLocked(aout);
}
@@ -843,7 +843,10 @@ static HRESULT MMSession(audio_output_t *aout, IMMDeviceEnumerator *it)
hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(it, eRender,
eConsole, &sys->dev);
if (FAILED(hr))
+ {
msg_Err(aout, "cannot get default device (error 0x%lx)", hr);
+ sys->acquired_device = NULL;
+ }
else
sys->acquired_device = default_device;
}
@@ -1116,9 +1119,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)
@@ -1147,8 +1147,11 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
EnterMTA();
EnterCriticalSection(&sys->lock);
- if (sys->request_device_restart && DeviceRestartLocked(aout) != 0)
+ if ((sys->request_device_restart && DeviceRestartLocked(aout) != 0)
+ || sys->dev == NULL)
{
+ /* Error if the device restart failed or if a request previously
+ * failed. */
LeaveCriticalSection(&sys->lock);
LeaveMTA();
vlc_object_release(s);
More information about the vlc-commits
mailing list