[vlc-devel] [PATCH] aout: get the jitter delay from modules
Thomas Guillem
thomas at gllm.fr
Tue Feb 5 11:24:23 CET 2019
On Tue, Feb 5, 2019, at 10:51, Rémi Denis-Courmont wrote:
> Hi,
>
> This seems backward. The period of the output should be no more than half the maximum tolerable delay, and most back-ends support different values. Only if the minimum period length is more than half the maximum delay should the back-end override (increase) the delay.
OK, If I understand correctly: the default delay is MAX_ADVANCE * 2 = 80ms;
Aout modules should configure their period according to this value: that is MAX_ADVANCE = 40ms; Otherwise, they can override this value.
>
> Le 5 février 2019 10:18:07 GMT+02:00, Thomas Guillem <thomas at gllm.fr> a écrit :
>> This value should be 2 times (RFC: or 3 times, Rémi ?) the minimum audio
>> request value.
>>
>> This value will be used by the future new output clock. If the audio ES is the
>> master, audio outputs will be able to set the jitter value of the clock. The
>> first start of all other ESes will be delayed by this value. This will allow to
>> start without any distortion/frame drop. include/vlc_aout.h | 7 ++++++-
>> modules/audio_output/adummy.c | 5 +++--
>> modules/audio_output/alsa.c | 4 +++-
>> modules/audio_output/amem.c | 4 +++-
>> modules/audio_output/audiotrack.c | 6 ++++--
>> modules/audio_output/audiounit_ios.m | 4 +++-
>> modules/audio_output/auhal.c | 4 +++-
>> modules/audio_output/directsound.c | 3 ++-
>> modules/audio_output/file.c | 4 +++-
>> modules/audio_output/jack.c | 4 +++-
>> modules/audio_output/kai.c | 3 ++-
>> modules/audio_output/mmdevice.c | 4 +++-
>> modules/audio_output/opensles_android.c | 4 +++-
>> modules/audio_output/oss.c | 4 +++-
>> modules/audio_output/pulse.c | 4 +++-
>> modules/audio_output/sndio.c | 3 ++-
>> modules/audio_output/tizen_audio.c | 4 +++-
>> modules/audio_output/waveout.c | 4 +++-
>> modules/audio_output/winstore.c | 4 +++-
>> modules/video_output/decklink.cpp | 4 +++-
>> src/audio_output/output.c | 3 ++-
>> 21 files changed, 63 insertions(+), 23 deletions(-)
>>
>> diff --git a/include/vlc_aout.h b/include/vlc_aout.h
>> index 11209ee0ce..cec64a1e61 100644
>> --- a/include/vlc_aout.h
>> +++ b/include/vlc_aout.h
>> @@ -140,7 +140,7 @@ struct audio_output
>>
>> void *sys; /**< Private data for callbacks */
>>
>> - int (*start)(audio_output_t *, audio_sample_format_t *fmt);
>> + int (*start)(audio_output_t *, audio_sample_format_t *fmt, vlc_tick_t *jitter);
>> /**< Starts a new stream (mandatory, cannot be NULL).
>> *
>> * This callback changes the audio output from stopped to playing state
>> @@ -149,6 +149,11 @@ struct audio_output
>> *
>> * \param fmt input stream sample format upon entry,
>> * output stream sample format upon return [IN/OUT]
>> + * \param jitter delay that is needed to start without distortion. The
>> + * first played block date will be 'jitter' us in the future. If the
>> + * module can't handle a late start, the time_get() implementation should
>> + * return a valid value before the first play. [OUT]
>> +
>> * \return VLC_SUCCESS on success, non-zero on failure
>> *
>> * \note This callback can only be called while the audio output is in
>> diff --git a/modules/audio_output/adummy.c b/modules/audio_output/adummy.c
>> index d0889b8c08..894356e527 100644
>> --- a/modules/audio_output/adummy.c
>> +++ b/modules/audio_output/adummy.c
>> @@ -57,9 +57,10 @@ static void Flush(audio_output_t *aout, bool wait)
>> (void) aout; (void) wait;
>> }
>>
>> -static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
>> +static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt,
>> + vlc_tick_t *jitter)
>> {
>> - (void) aout;
>> + (void) aout; (void) jitter;
>>
>> switch (fmt->i_format)
>> {
>> diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
>> index 08067c1338..9ff6c3eb09 100644
>> --- a/modules/audio_output/alsa.c
>> +++ b/modules/audio_output/alsa.c
>> @@ -297,7 +297,8 @@ static void PauseDummy (audio_output_t *, bool, vlc_tick_t);
>> static void Flush (audio_output_t *, bool);
>>
>> /** Initializes an ALSA playback stream */
>> -static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
>> +static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt,
>> + vlc_tick_t *jitter)
>> {
>> aout_sys_t *sys = aout->sys;
>> snd_pcm_format_t pcm_format; /* ALSA sample format */
>> @@ -627,6 +628,7 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
>> error:
>> snd_pcm_close (pcm);
>> return VLC_EGENERIC;
>> + VLC_UNUSED(jitter);
>> }
>>
>> static int TimeGet (audio_output_t *aout, vlc_tick_t *restrict delay)
>> diff --git a/modules/audio_output/amem.c b/modules/audio_output/amem.c
>> index dcba84c32d..098b97b9ac 100644
>> --- a/modules/audio_output/amem.c
>> +++ b/modules/audio_output/amem.c
>> @@ -184,7 +184,8 @@ static void Stop (audio_output_t *aout)
>> vlc_mutex_unlock(&sys->lock);
>> }
>>
>> -static int Start (audio_output_t *aout, audio_sample_format_t *fmt)
>> +static int Start (audio_output_t *aout, audio_sample_format_t *fmt,
>> + vlc_tick_t *jitter)
>> {
>> aout_sys_t *sys = aout->sys;
>> char format[5] = "S16N";
>> @@ -265,6 +266,7 @@ static int Start (audio_output_t *aout, audio_sample_format_t *fmt)
>> fmt->i_format = VLC_CODEC_S16N;
>> fmt->channel_type = AUDIO_CHANNEL_TYPE_BITMAP;
>> return VLC_SUCCESS;
>> + VLC_UNUSED(jitter);
>> }
>>
>> static int Open (vlc_object_t *obj)
>> diff --git a/modules/audio_output/audiotrack.c b/modules/audio_output/audiotrack.c
>> index 8aef4aecfe..ed45d82253 100644
>> --- a/modules/audio_output/audiotrack.c
>> +++ b/modules/audio_output/audiotrack.c
>> @@ -43,7 +43,7 @@
>> static int Open( vlc_object_t * );
>> static void Close( vlc_object_t * );
>> static void Stop( audio_output_t * );
>> -static int Start( audio_output_t *, audio_sample_format_t * );
>> +static int Start( audio_output_t *, audio_sample_format_t *, vlc_tick_t * );
>> static void *AudioTrack_Thread( void * );
>>
>> /* There is an undefined behavior when configuring AudioTrack with SPDIF or
>> @@ -1292,7 +1292,8 @@ StartPCM( JNIEnv *env, audio_output_t *p_aout, unsigned i_max_channels )
>> }
>>
>> static int
>> -Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt )
>> +Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt,
>> + vlc_tick_t *jitter )
>> {
>> aout_sys_t *p_sys = p_aout->sys;
>> JNIEnv *env;
>> @@ -1494,6 +1495,7 @@ Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt )
>> error:
>> Stop( p_aout );
>> return VLC_EGENERIC;
>> + VLC_UNUSED(jitter);
>> }
>>
>> static void
>> diff --git a/modules/audio_output/audiounit_ios.m b/modules/audio_output/audiounit_ios.m
>> index e449f6e2eb..f379c4f70f 100644
>> --- a/modules/audio_output/audiounit_ios.m
>> +++ b/modules/audio_output/audiounit_ios.m
>> @@ -477,7 +477,8 @@ Stop(audio_output_t *p_aout)
>> }
>>
>> static int
>> -Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
>> +Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt,
>> + vlc_tick_t *jitter)
>> {
>> aout_sys_t *p_sys = p_aout->sys;
>> OSStatus err;
>> @@ -580,6 +581,7 @@ error:
>> [[NSNotificationCenter defaultCenter] removeObserver:p_sys->aoutWrapper];
>> msg_Err(p_aout, "opening AudioUnit output failed");
>> return VLC_EGENERIC;
>> + VLC_UNUSED(jitter);
>> }
>>
>> static int DeviceSelect(audio_output_t *p_aout, const char *psz_id)
>> diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
>> index 8005e27954..1bc215a9d5 100644
>> --- a/modules/audio_output/auhal.c
>> +++ b/modules/audio_output/auhal.c
>> @@ -1496,7 +1496,8 @@ Stop(audio_output_t *p_aout)
>> }
>>
>> static int
>> -Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
>> +Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt,
>> + vlc_tick_t *jitter)
>> {
>> UInt32 i_param_size = 0;
>> aout_sys_t *p_sys = NULL;
>> @@ -1627,6 +1628,7 @@ Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
>> kAudioDevicePropertyDeviceIsAlive,
>> kAudioObjectPropertyScopeGlobal);
>> return VLC_EGENERIC;
>> + VLC_UNUSED(jitter);
>> }
>>
>> static void Close(vlc_object_t *obj)
>> diff --git a/modules/audio_output/directsound.c b/modules/audio_output/directsound.c
>> index b3f3b130c5..0752a559d8 100644
>> --- a/modules/audio_output/directsound.c
>> +++ b/modules/audio_output/directsound.c
>> @@ -963,7 +963,7 @@ static int MuteSet( audio_output_t *p_aout, bool mute )
>> }
>>
>> static int OutputStart( audio_output_t *p_aout,
>> - audio_sample_format_t *restrict fmt )
>> + audio_sample_format_t *restrict fmt, vlc_tick_t *jitter )
>> {
>> msg_Dbg( p_aout, "Opening DirectSound Audio Output" );
>>
>> @@ -990,6 +990,7 @@ static int OutputStart( audio_output_t *p_aout,
>> p_aout->flush = OutputFlush;
>>
>> return 0;
>> + VLC_UNUSED(jitter);
>> }
>>
>> typedef struct
>> diff --git a/modules/audio_output/file.c b/modules/audio_output/file.c
>> index fbdf35fcb1..0fab9bdece 100644
>> --- a/modules/audio_output/file.c
>> +++ b/modules/audio_output/file.c
>> @@ -128,7 +128,8 @@ vlc_module_begin ()
>> set_callbacks( Open, NULL )
>> vlc_module_end ()
>>
>> -static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
>> +static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt,
>> + vlc_tick_t *jitter )
>> {
>> char * psz_name, * psz_format;
>> const char * const * ppsz_compare = format_list;
>> @@ -272,6 +273,7 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
>> }
>>
>> return 0;
>> + VLC_UNUSED(jitter);
>> }
>>
>> /*****************************************************************************
>> diff --git a/modules/audio_output/jack.c b/modules/audio_output/jack.c
>> index 59ad013b2f..6dce9f1609 100644
>> --- a/modules/audio_output/jack.c
>> +++ b/modules/audio_output/jack.c
>> @@ -112,7 +112,8 @@ vlc_module_begin ()
>> vlc_module_end ()
>>
>>
>> -static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
>> +static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt,
>> + vlc_tick_t *jitter )
>> {
>> char *psz_name;
>> aout_sys_t *p_sys = p_aout->sys;
>> @@ -280,6 +281,7 @@ error_out:
>> }
>> free( psz_name );
>> return status;
>> + VLC_UNUSED(jitter);
>> }
>>
>> static void Play(audio_output_t * p_aout, block_t * p_block, vlc_tick_t date)
>> diff --git a/modules/audio_output/kai.c b/modules/audio_output/kai.c
>> index 98a2182394..5c87aeb74b 100644
>> --- a/modules/audio_output/kai.c
>> +++ b/modules/audio_output/kai.c
>> @@ -124,7 +124,7 @@ vlc_module_end ()
>> /*****************************************************************************
>> * Open: open the audio device
>> *****************************************************************************/
>> -static int Start ( audio_output_t *p_aout, audio_sample_format_t *fmt )
>> +static int Start ( audio_output_t *p_aout, audio_sample_format_t *fmt, vlc_tick_t *jitter )
>> {
>> aout_sys_t *p_sys = p_aout->sys;
>> char *psz_mode;
>> @@ -228,6 +228,7 @@ exit_kai_done :
>> kaiDone();
>>
>> return VLC_EGENERIC;
>> + VLC_UNUSED( jitter );
>> }
>>
>> /*****************************************************************************
>> diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
>> index 3aded2b9d3..8d6948b285 100644
>> --- a/modules/audio_output/mmdevice.c
>> +++ b/modules/audio_output/mmdevice.c
>> @@ -1117,7 +1117,8 @@ static void aout_stream_Stop(void *func, va_list ap)
>> stop(s);
>> }
>>
>> -static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
>> +static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt,
>> + vlc_tick_t *jitter)
>> {
>> aout_sys_t *sys = aout->sys;
>>
>> @@ -1232,6 +1233,7 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
>> sys->stream = s;
>> aout_GainRequest(aout, sys->gain);
>> return 0;
>> + VLC_UNUSED(jitter);
>> }
>>
>> static void Stop(audio_output_t *aout)
>> diff --git a/modules/audio_output/opensles_android.c b/modules/audio_output/opensles_android.c
>> index f0d7360397..080548b17a 100644
>> --- a/modules/audio_output/opensles_android.c
>> +++ b/modules/audio_output/opensles_android.c
>> @@ -380,7 +380,8 @@ static int aout_get_native_sample_rate(audio_output_t *aout)
>> /*****************************************************************************
>> *
>> *****************************************************************************/
>> -static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
>> +static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt,
>> + vlc_tick_t *jitter)
>> {
>> if (aout_FormatNbChannels(fmt) == 0 || !AOUT_FMT_LINEAR(fmt))
>> return VLC_EGENERIC;
>> @@ -496,6 +497,7 @@ error:
>> }
>>
>> return VLC_EGENERIC;
>> + VLC_UNUSED(jitter);
>> }
>>
>> static void Stop(audio_output_t *aout)
>> diff --git a/modules/audio_output/oss.c b/modules/audio_output/oss.c
>> index 5e16255798..820a3b63c1 100644
>> --- a/modules/audio_output/oss.c
>> +++ b/modules/audio_output/oss.c
>> @@ -92,7 +92,8 @@ static void Play(audio_output_t *, block_t *, vlc_tick_t);
>> static void Pause (audio_output_t *, bool, vlc_tick_t);
>> static void Flush (audio_output_t *, bool);
>>
>> -static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
>> +static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt,
>> + vlc_tick_t *jitter)
>> {
>> aout_sys_t* sys = aout->sys;
>>
>> @@ -248,6 +249,7 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
>> error:
>> vlc_close (fd);
>> return VLC_EGENERIC;
>> + VLC_UNUSED(jitter);
>> }
>>
>> static int TimeGet (audio_output_t *aout, vlc_tick_t *restrict pts)
>> diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
>> index 5075dd92ce..8be4004534 100644
>> --- a/modules/audio_output/pulse.c
>> +++ b/modules/audio_output/pulse.c
>> @@ -696,7 +696,8 @@ static const char *str_map(const char *key, const char *const table[][2],
>> /**
>> * Create a PulseAudio playback stream, a.k.a. a sink input.
>> */
>> -static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
>> +static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt,
>> + vlc_tick_t *jitter)
>> {
>> aout_sys_t *sys = aout->sys;
>>
>> @@ -962,6 +963,7 @@ fail:
>> pa_threaded_mainloop_unlock(sys->mainloop);
>> Stop(aout);
>> return VLC_EGENERIC;
>> + VLC_UNUSED(jitter);
>> }
>>
>> /**
>> diff --git a/modules/audio_output/sndio.c b/modules/audio_output/sndio.c
>> index 6b28772817..54df8a0e96 100644
>> --- a/modules/audio_output/sndio.c
>> +++ b/modules/audio_output/sndio.c
>> @@ -62,7 +62,7 @@ typedef struct
>> } aout_sys_t;
>>
>> /** Initializes an sndio playback stream */
>> -static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
>> +static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt, vlc_tick_t *jitter)
>> {
>> aout_sys_t *sys = aout->sys;
>>
>> @@ -202,6 +202,7 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
>> error:
>> sio_close (sys->hdl);
>> return VLC_EGENERIC;
>> + VLC_UNUSED(jitter);
>> }
>>
>> static void Stop (audio_output_t *aout)
>> diff --git a/modules/audio_output/tizen_audio.c b/modules/audio_output/tizen_audio.c
>> index 6ed34ac3d3..19332417ec 100644
>> --- a/modules/audio_output/tizen_audio.c
>> +++ b/modules/audio_output/tizen_audio.c
>> @@ -193,7 +193,8 @@ AudioIO_Start( audio_output_t *p_aout )
>> }
>>
>> static int
>> -Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt )
>> +Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt,
>> + vlc_tick_t *jitter )
>> {
>> aout_sys_t *p_sys = p_aout->sys;
>>
>> @@ -242,6 +243,7 @@ Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt )
>> aout_FormatPrint( p_aout, "Tizen audio will output:", p_fmt );
>>
>> return VLC_SUCCESS;
>> + VLC_UNUSED(jitter);
>> }
>>
>> static void
>> diff --git a/modules/audio_output/waveout.c b/modules/audio_output/waveout.c
>> index b71fe762bb..74b67d0388 100644
>> --- a/modules/audio_output/waveout.c
>> +++ b/modules/audio_output/waveout.c
>> @@ -168,7 +168,8 @@ vlc_module_end ()
>> *****************************************************************************
>> * This function opens and setups Win32 waveOut
>> *****************************************************************************/
>> -static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
>> +static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt,
>> + vlc_tick_t *jitter )
>> {
>> if( aout_FormatNbChannels( fmt ) == 0 )
>> return VLC_EGENERIC;
>> @@ -334,6 +335,7 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
>> fmt->channel_type = AUDIO_CHANNEL_TYPE_BITMAP;
>>
>> return VLC_SUCCESS;
>> + VLC_UNUSED(jitter);
>> }
>>
>> /*****************************************************************************
>> diff --git a/modules/audio_output/winstore.c b/modules/audio_output/winstore.c
>> index 5dcad97908..afc4224e5c 100644
>> --- a/modules/audio_output/winstore.c
>> +++ b/modules/audio_output/winstore.c
>> @@ -226,7 +226,8 @@ static void aout_stream_Stop(void *func, va_list ap)
>> stop(s);
>> }
>>
>> -static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
>> +static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt,
>> + vlc_tick_t *jitter)
>> {
>> aout_sys_t *sys = aout->sys;
>> HRESULT hr;
>> @@ -252,6 +253,7 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
>> assert (sys->stream == NULL);
>> sys->stream = s;
>> return 0;
>> + VLC_UNUSED(jitter);
>> }
>>
>> static void Stop(audio_output_t *aout)
>> diff --git a/modules/video_output/decklink.cpp b/modules/video_output/decklink.cpp
>> index 597807d163..467dd87d75 100644
>> --- a/modules/video_output/decklink.cpp
>> +++ b/modules/video_output/decklink.cpp
>> @@ -1099,7 +1099,8 @@ static int TimeGet(audio_output_t *, vlc_tick_t* restrict)
>> return -1;
>> }
>>
>> -static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
>> +static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt,
>> + vlc_tick_t *jitter)
>> {
>> decklink_sys_t *sys = (decklink_sys_t *) aout->sys;
>>
>> @@ -1116,6 +1117,7 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
>> fmt->i_frame_length = FRAME_SIZE;
>>
>> return VLC_SUCCESS;
>> + VLC_UNUSED(jitter);
>> }
>>
>> static void PlayAudio(audio_output_t *aout, block_t *audio, vlc_tick_t systempts)
>> diff --git a/src/audio_output/output.c b/src/audio_output/output.c
>> index 7c1f90b6ba..3a29c308e7 100644
>> --- a/src/audio_output/output.c
>> +++ b/src/audio_output/output.c
>> @@ -570,7 +570,8 @@ int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt,
>> aout->current_sink_info.headphones = false;
>>
>> aout_OutputLock(aout);
>> - int ret = aout->start(aout, fmt);
>> + vlc_tick_t jitter = AOUT_MAX_PTS_ADVANCE * 2;
>> + int ret = aout->start(aout, fmt, &jitter);
>> aout_OutputUnlock(aout);
>> if (ret)
>> {
>
> --
> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20190205/f23c14d4/attachment-0001.html>
More information about the vlc-devel
mailing list