[vlc-devel] [PATCH 1/2] aout: send the preferred period delay to modules

Thomas Guillem thomas at gllm.fr
Fri Feb 8 08:09:14 CET 2019


---
 include/vlc_aout.h                      | 10 +++++++++-
 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, 66 insertions(+), 23 deletions(-)

diff --git a/include/vlc_aout.h b/include/vlc_aout.h
index 11209ee0ce..59f930221f 100644
--- a/include/vlc_aout.h
+++ b/include/vlc_aout.h
@@ -140,7 +140,8 @@ 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 *period_hint);
     /**< Starts a new stream (mandatory, cannot be NULL).
       *
       * This callback changes the audio output from stopped to playing state
@@ -149,6 +150,13 @@ struct audio_output
       *
       * \param fmt input stream sample format upon entry,
       *            output stream sample format upon return [IN/OUT]
+      *
+      * \param period_hint wanted period by the core. This value can be
+      * overwritten by the implementation if it's not possible to configure
+      * such period. A period corresponds to the amount of time the audio
+      * server will wait until the buffer is free enough to request more data
+      * [IN/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..64fce9a1b0 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 *period_hint)
 {
-    (void) aout;
+    (void) aout; (void) period;
 
     switch (fmt->i_format)
     {
diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index 08067c1338..23b4e8d03a 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 *period_hint)
 {
     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(period_hint);
 }
 
 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..c4106d7b82 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 *period_hint)
 {
     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(period_hint);
 }
 
 static int Open (vlc_object_t *obj)
diff --git a/modules/audio_output/audiotrack.c b/modules/audio_output/audiotrack.c
index 8aef4aecfe..d0ddbda33d 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 *period_hint )
 {
     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(period_hint);
 }
 
 static void
diff --git a/modules/audio_output/audiounit_ios.m b/modules/audio_output/audiounit_ios.m
index e449f6e2eb..9f621564a2 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 *period_hint)
 {
     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(period_hint);
 }
 
 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..8e4fdb7098 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 *period_hint)
 {
     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(period_hint);
 }
 
 static void Close(vlc_object_t *obj)
diff --git a/modules/audio_output/directsound.c b/modules/audio_output/directsound.c
index b3f3b130c5..103fb008a9 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 *period_hint )
 {
     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(period_hint);
 }
 
 typedef struct
diff --git a/modules/audio_output/file.c b/modules/audio_output/file.c
index fbdf35fcb1..274b6a6f15 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 *period_hint )
 {
     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(period_hint);
 }
 
 /*****************************************************************************
diff --git a/modules/audio_output/jack.c b/modules/audio_output/jack.c
index 59ad013b2f..0b0b772f8e 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 *period_hint )
 {
     char *psz_name;
     aout_sys_t *p_sys = p_aout->sys;
@@ -280,6 +281,7 @@ error_out:
     }
     free( psz_name );
     return status;
+    VLC_UNUSED(period_hint);
 }
 
 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..2afcc7f18b 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 *period_hint )
 {
     aout_sys_t *p_sys = p_aout->sys;
     char *psz_mode;
@@ -228,6 +228,7 @@ exit_kai_done :
     kaiDone();
 
     return VLC_EGENERIC;
+    VLC_UNUSED( period );
 }
 
 /*****************************************************************************
diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index 3aded2b9d3..ad00606639 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 *period_hint)
 {
     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(period_hint);
 }
 
 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..dd0d67f0fe 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 *period_hint)
 {
     if (aout_FormatNbChannels(fmt) == 0 || !AOUT_FMT_LINEAR(fmt))
         return VLC_EGENERIC;
@@ -496,6 +497,7 @@ error:
     }
 
     return VLC_EGENERIC;
+    VLC_UNUSED(period_hint);
 }
 
 static void Stop(audio_output_t *aout)
diff --git a/modules/audio_output/oss.c b/modules/audio_output/oss.c
index 5e16255798..b905aee239 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 *period_hint)
 {
     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(period_hint);
 }
 
 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..eb53a1e2f3 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 *period_hint)
 {
     aout_sys_t *sys = aout->sys;
 
@@ -962,6 +963,7 @@ fail:
     pa_threaded_mainloop_unlock(sys->mainloop);
     Stop(aout);
     return VLC_EGENERIC;
+    VLC_UNUSED(period_hint);
 }
 
 /**
diff --git a/modules/audio_output/sndio.c b/modules/audio_output/sndio.c
index 6b28772817..37fbee968e 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 *period_hint)
 {
     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(period_hint);
 }
 
 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..1b64afa826 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 *period_hint )
 {
     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(period_hint);
 }
 
 static void
diff --git a/modules/audio_output/waveout.c b/modules/audio_output/waveout.c
index b71fe762bb..9c2ab98cf2 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 *period_hint )
 {
     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(period_hint);
 }
 
 /*****************************************************************************
diff --git a/modules/audio_output/winstore.c b/modules/audio_output/winstore.c
index 5dcad97908..e419b60ae2 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 *period_hint)
 {
     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(period_hint);
 }
 
 static void Stop(audio_output_t *aout)
diff --git a/modules/video_output/decklink.cpp b/modules/video_output/decklink.cpp
index 597807d163..424dc65bbf 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 *period_hint)
 {
     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(period_hint);
 }
 
 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..f7a684c57d 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 period_hint = AOUT_MAX_PTS_ADVANCE;
+    int ret = aout->start(aout, fmt, &period_hint);
     aout_OutputUnlock(aout);
     if (ret)
     {
-- 
2.20.1



More information about the vlc-devel mailing list