mirror of
https://code.videolan.org/videolan/vlc
synced 2024-09-08 11:26:59 +02:00
mmdevice: deal with invalidated device in Start()
This commit is contained in:
parent
c242a51512
commit
7697d8b299
@ -597,16 +597,25 @@ static void CloseDevice(audio_output_t *aout)
|
||||
static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
|
||||
{
|
||||
aout_sys_t *sys = aout->sys;
|
||||
HRESULT hr;
|
||||
|
||||
assert (sys->stream == NULL);
|
||||
if (sys->dev == NULL)
|
||||
return -1;
|
||||
|
||||
aout_stream_t *s = vlc_object_create(aout, sizeof (*s));
|
||||
if (unlikely(s == NULL))
|
||||
return -1;
|
||||
|
||||
EnterMTA();
|
||||
sys->stream = aout_stream_Start(aout, fmt, sys->dev, &GUID_VLC_AUD_OUT);
|
||||
hr = aout_stream_Start(s, fmt, sys->dev, &GUID_VLC_AUD_OUT);
|
||||
if (SUCCEEDED(hr))
|
||||
sys->stream = s;
|
||||
else
|
||||
vlc_object_release(s);
|
||||
LeaveMTA();
|
||||
|
||||
return (sys->stream != NULL) ? 0 : -1;
|
||||
return vlc_FromHR(aout, hr);
|
||||
}
|
||||
|
||||
static void Stop(audio_output_t *aout)
|
||||
@ -619,6 +628,7 @@ static void Stop(audio_output_t *aout)
|
||||
aout_stream_Stop(sys->stream);
|
||||
LeaveMTA();
|
||||
|
||||
vlc_object_release(sys->stream);
|
||||
sys->stream = NULL;
|
||||
}
|
||||
|
||||
|
@ -39,15 +39,13 @@ struct aout_stream
|
||||
|
||||
/**
|
||||
* Creates an audio output stream on a given Windows multimedia device.
|
||||
* \param parent parent VLC object
|
||||
* \param s audio output stream object to be initialized
|
||||
* \param fmt audio output sample format [IN/OUT]
|
||||
* \param dev audio output device
|
||||
* \param dev MMDevice API output device
|
||||
* \param sid audio output session GUID [IN]
|
||||
*/
|
||||
aout_stream_t *aout_stream_Start(vlc_object_t *parent,
|
||||
audio_sample_format_t *fmt,
|
||||
IMMDevice *dev, const GUID *sid);
|
||||
#define aout_stream_Start(o,f,d,s) aout_stream_Start(VLC_OBJECT(o),f,d,s)
|
||||
HRESULT aout_stream_Start(aout_stream_t *s, audio_sample_format_t *fmt,
|
||||
IMMDevice *dev, const GUID *sid);
|
||||
|
||||
/**
|
||||
* Destroys an audio output stream.
|
||||
|
@ -403,26 +403,14 @@ static void Stop(aout_stream_t *s)
|
||||
IAudioClient_Release(sys->client);
|
||||
}
|
||||
|
||||
#undef aout_stream_Start
|
||||
aout_stream_t *aout_stream_Start(vlc_object_t *parent,
|
||||
audio_sample_format_t *restrict fmt,
|
||||
IMMDevice *dev, const GUID *sid)
|
||||
HRESULT aout_stream_Start(aout_stream_t *s,
|
||||
audio_sample_format_t *restrict fmt,
|
||||
IMMDevice *dev, const GUID *sid)
|
||||
{
|
||||
aout_stream_t *s = vlc_object_create(parent, sizeof (*s));
|
||||
if (unlikely(s == NULL))
|
||||
return NULL;
|
||||
|
||||
HRESULT hr = Start(s, fmt, dev, sid);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
vlc_object_release(s);
|
||||
s = NULL;
|
||||
}
|
||||
return s;
|
||||
return Start(s, fmt, dev, sid);
|
||||
}
|
||||
|
||||
void aout_stream_Stop(aout_stream_t *s)
|
||||
{
|
||||
Stop(s);
|
||||
vlc_object_release(s);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user