[vlc-devel] [PATCH V2 2/8] mmdevice: forward exclusive argument to streams
Thomas Guillem
thomas at gllm.fr
Fri Nov 8 18:13:08 CET 2019
---
modules/audio_output/directsound.c | 10 ++++++----
modules/audio_output/mmdevice.c | 11 +++++------
modules/audio_output/mmdevice.h | 3 ++-
modules/audio_output/wasapi.c | 5 ++++-
4 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/modules/audio_output/directsound.c b/modules/audio_output/directsound.c
index 70eebb2efa5..dc748b6b671 100644
--- a/modules/audio_output/directsound.c
+++ b/modules/audio_output/directsound.c
@@ -45,7 +45,7 @@
static int Open( vlc_object_t * );
static void Close( vlc_object_t * );
static HRESULT StreamStart( aout_stream_t *, audio_sample_format_t *,
- const GUID * );
+ bool exclusive, const GUID * );
static void * PlayedDataEraser( void * );
/* Speaker setup override options list */
static const char *const speaker_list[] = { "Windows default", "Mono", "Stereo",
@@ -588,8 +588,7 @@ static void OutputStop( audio_output_t *aout )
}
static HRESULT Start( vlc_object_t *obj, aout_stream_sys_t *sys,
- audio_sample_format_t *restrict pfmt,
- bool exclusive)
+ audio_sample_format_t *restrict pfmt, bool exclusive)
{
if( aout_FormatNbChannels( pfmt ) == 0 || exclusive )
return E_FAIL;
@@ -828,8 +827,11 @@ error:
static HRESULT StreamStart( aout_stream_t *s,
audio_sample_format_t *restrict fmt,
- const GUID *sid )
+ bool exclusive, const GUID *sid )
{
+ if( exclusive )
+ return E_FAIL;
+
aout_stream_sys_t *sys = calloc( 1, sizeof( *sys ) );
if( unlikely(sys == NULL) )
return E_OUTOFMEMORY;
diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index 3c78423845e..1632ee5be7e 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -1094,11 +1094,13 @@ static int aout_stream_Start(void *func, bool forced, va_list ap)
aout_stream_start_t start = func;
aout_stream_t *s = va_arg(ap, aout_stream_t *);
audio_sample_format_t *fmt = va_arg(ap, audio_sample_format_t *);
+ enum vlc_aout_exclusive_mode exclusive =
+ va_arg(ap, enum vlc_aout_exclusive_mode);
HRESULT *hr = va_arg(ap, HRESULT *);
LPCGUID sid = var_InheritBool(s, "volume-save") ? &GUID_VLC_AUD_OUT : NULL;
(void) forced;
- *hr = start(s, fmt, sid);
+ *hr = start(s, fmt, exclusive, sid);
if (*hr == AUDCLNT_E_DEVICE_INVALIDATED)
return VLC_ETIMEOUT;
return SUCCEEDED(*hr) ? VLC_SUCCESS : VLC_EGENERIC;
@@ -1109,9 +1111,6 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt,
{
aout_sys_t *sys = aout->sys;
- if (exclusive)
- return -1;
-
const bool b_spdif = AOUT_FMT_SPDIF(fmt);
const bool b_hdmi = AOUT_FMT_HDMI(fmt);
if (b_spdif || b_hdmi)
@@ -1157,8 +1156,8 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt,
HRESULT hr;
s->owner.device = sys->dev;
- module = vlc_module_load(s, "aout stream", modlist,
- false, aout_stream_Start, s, fmt, &hr);
+ module = vlc_module_load(s, "aout stream", modlist, false,
+ aout_stream_Start, s, fmt, exclusive, &hr);
free(modlist);
int ret = -1;
diff --git a/modules/audio_output/mmdevice.h b/modules/audio_output/mmdevice.h
index 65e41de4d40..46d190b5dbe 100644
--- a/modules/audio_output/mmdevice.h
+++ b/modules/audio_output/mmdevice.h
@@ -56,7 +56,8 @@ struct aout_stream
* \param sid audio output session GUID [IN]
*/
typedef HRESULT (*aout_stream_start_t)(aout_stream_t *s,
- audio_sample_format_t *fmt, const GUID *sid);
+ audio_sample_format_t *fmt, bool exclusive,
+ const GUID *sid);
/**
* Destroys an audio output stream.
diff --git a/modules/audio_output/wasapi.c b/modules/audio_output/wasapi.c
index 66cfee466ca..9c77ce0c5d0 100644
--- a/modules/audio_output/wasapi.c
+++ b/modules/audio_output/wasapi.c
@@ -568,8 +568,11 @@ static void Stop(aout_stream_t *s)
}
static HRESULT Start(aout_stream_t *s, audio_sample_format_t *restrict pfmt,
- const GUID *sid)
+ bool exclusive, const GUID *sid)
{
+ if (exclusive)
+ return E_FAIL;
+
static INIT_ONCE freq_once = INIT_ONCE_STATIC_INIT;
if (!InitOnceExecuteOnce(&freq_once, InitFreq, &freq, NULL))
--
2.20.1
More information about the vlc-devel
mailing list