<html><head></head><body>Sep*a*rate. Also at least ALSA is changed, without explanation. If this is intended, please do it in separate patch.<br><br><div class="gmail_quote">Le 13 mars 2019 16:55:52 GMT+08:00, Thomas Guillem <thomas@gllm.fr> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">This callback is not mandatory. If it is NULL, the core will wait for the delay<br>returned by time_get(). This was already the case for most aout plugins:<br>PulseAudio, coreaudio, Android, DirectSound, Wasapi, and Jack.<hr> include/vlc_aout.h | 12 ++++++--<br> modules/audio_output/adummy.c | 4 +--<br> modules/audio_output/alsa.c | 23 +++++++++------<br> modules/audio_output/amem.c | 17 +++++++++---<br> modules/audio_output/audiotrack.c | 25 ++++-------------<br> modules/audio_output/audiounit_ios.m | 13 ++-------<br> modules/audio_output/coreaudio_common.c | 37 ++++++-------------------<br> modules/audio_output/coreaudio_common.h | 2 +-<br> modules/audio_output/directsound.c | 13 ++-------<br> modules/audio_output/file.c | 5 ++--<br> modules/audio_output/jack.c | 12 ++------<br> modules/audio_output/kai.c | 16 +++--------<br> modules/audio_output/mmdevice.c | 4 +--<br> modules/audio_output/mmdevice.h | 14 ++--------<br> modules/audio_output/opensles_android.c | 32 +++++++++------------<br> modules/audio_output/oss.c | 8 ++----<br> modules/audio_output/pulse.c | 35 +++++++++++++----------<br> modules/audio_output/sndio.c | 5 ++--<br> modules/audio_output/waveout.c | 34 +++++++++++------------<br> modules/audio_output/winstore.c | 4 +--<br> src/audio_output/dec.c | 14 ++++++++--<br> 21 files changed, 138 insertions(+), 191 deletions(-)<br><br>diff --git a/include/vlc_aout.h b/include/vlc_aout.h<br>index a4ae6bc498..a6b8069151 100644<br>--- a/include/vlc_aout.h<br>+++ b/include/vlc_aout.h<br>@@ -212,14 +212,20 @@ struct audio_output<br> * \note This callback cannot be called in stopped state.<br> */<br> <br>- void (*flush)( audio_output_t *, bool wait);<br>- /**< Flushes or drains the playback buffers (mandatory, cannot be NULL).<br>+ void (*flush)( audio_output_t *);<br>+ /**< Flushes the playback buffers (mandatory, cannot be NULL).<br> *<br> * \param wait true to wait for playback of pending buffers (drain),<br> * false to discard pending buffers (flush)<br> *<br> * \note This callback cannot be called in stopped state.<br> */<br>+ void (*drain)(audio_output_t *);<br>+ /**< Drain the playback buffers (can be NULL).<br>+ *<br>+ * If NULL, the caller will wait for the delay returned by time_get before<br>+ * calling stop().<br>+ */<br> <br> int (*volume_set)(audio_output_t *, float volume);<br> /**< Changes playback volume (optional, may be NULL).<br>@@ -456,7 +462,7 @@ static inline void aout_PauseDefault(audio_output_t *aout, bool paused,<br> vlc_tick_t date)<br> {<br> if (paused && aout->flush != NULL)<br>- aout->flush(aout, false);<br>+ aout->flush(aout);<br> (void) date;<br> }<br> <br>diff --git a/modules/audio_output/adummy.c b/modules/audio_output/adummy.c<br>index d0889b8c08..e81a9cb0c8 100644<br>--- a/modules/audio_output/adummy.c<br>+++ b/modules/audio_output/adummy.c<br>@@ -52,9 +52,9 @@ static void Pause(audio_output_t *aout, bool paused, vlc_tick_t date)<br> (void) aout; (void) paused; (void) date;<br> }<br> <br>-static void Flush(audio_output_t *aout, bool wait)<br>+static void Flush(audio_output_t *aout)<br> {<br>- (void) aout; (void) wait;<br>+ (void) aout;<br> }<br> <br> static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)<br>diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c<br>index e507f78241..a99faed3cb 100644<br>--- a/modules/audio_output/alsa.c<br>+++ b/modules/audio_output/alsa.c<br>@@ -294,7 +294,8 @@ static int TimeGet (audio_output_t *aout, vlc_tick_t *);<br> static void Play(audio_output_t *, block_t *, vlc_tick_t);<br> static void Pause (audio_output_t *, bool, vlc_tick_t);<br> static void PauseDummy (audio_output_t *, bool, vlc_tick_t);<br>-static void Flush (audio_output_t *, bool);<br>+static void Flush (audio_output_t *);<br>+static void Drain (audio_output_t *);<br> <br> /** Initializes an ALSA playback stream */<br> static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)<br>@@ -714,20 +715,25 @@ static void PauseDummy (audio_output_t *aout, bool pause, vlc_tick_t date)<br> }<br> <br> /**<br>- * Flushes/drains the audio playback buffer.<br>+ * Flushes the audio playback buffer.<br> */<br>-static void Flush (audio_output_t *aout, bool wait)<br>+static void Flush (audio_output_t *aout)<br> {<br> aout_sys_t *p_sys = aout->sys;<br> snd_pcm_t *pcm = p_sys->pcm;<br>-<br>- if (wait)<br>- snd_pcm_drain (pcm);<br>- else<br>- snd_pcm_drop (pcm);<br>+ snd_pcm_drop (pcm);<br> snd_pcm_prepare (pcm);<br> }<br> <br>+/**<br>+ * Drains the audio playback buffer.<br>+ */<br>+static void Drain (audio_output_t *aout)<br>+{<br>+ aout_sys_t *p_sys = aout->sys;<br>+ snd_pcm_t *pcm = p_sys->pcm;<br>+ snd_pcm_drain (pcm);<br>+}<br> <br> /**<br> * Releases the audio output.<br>@@ -851,6 +857,7 @@ static int Open(vlc_object_t *obj)<br> aout->time_get = TimeGet;<br> aout->play = Play;<br> aout->flush = Flush;<br>+ aout->drain = Drain;<br> <br> return VLC_SUCCESS;<br> error:<br>diff --git a/modules/audio_output/amem.c b/modules/audio_output/amem.c<br>index dcba84c32d..f859a4b10a 100644<br>--- a/modules/audio_output/amem.c<br>+++ b/modules/audio_output/amem.c<br>@@ -104,19 +104,27 @@ static void Pause (audio_output_t *aout, bool paused, vlc_tick_t date)<br> }<br> }<br> <br>-static void Flush (audio_output_t *aout, bool wait)<br>+static void Flush (audio_output_t *aout)<br> {<br> aout_sys_t *sys = aout->sys;<br>- void (*cb) (void *) = wait ? sys->drain : sys->flush;<br> <br>- if (cb != NULL)<br>+ if (sys->flush != NULL)<br> {<br> vlc_mutex_lock(&sys->lock);<br>- cb (sys->opaque);<br>+ sys->flush (sys->opaque);<br> vlc_mutex_unlock(&sys->lock);<br> }<br> }<br> <br>+static void Drain (audio_output_t *aout)<br>+{<br>+ aout_sys_t *sys = aout->sys;<br>+<br>+ vlc_mutex_lock(&sys->lock);<br>+ sys->drain (sys->opaque);<br>+ vlc_mutex_unlock(&sys->lock);<br>+}<br>+<br> static int VolumeSet (audio_output_t *aout, float vol)<br> {<br> aout_sys_t *sys = aout->sys;<br>@@ -313,6 +321,7 @@ static int Open (vlc_object_t *obj)<br> aout->play = Play;<br> aout->pause = Pause;<br> aout->flush = Flush;<br>+ aout->drain = sys->drain ? Drain : NULL;<br> if (sys->set_volume != NULL)<br> {<br> aout->volume_set = VolumeSet;<br>diff --git a/modules/audio_output/audiotrack.c b/modules/audio_output/audiotrack.c<br>index 2dcababe47..1d39852343 100644<br>--- a/modules/audio_output/audiotrack.c<br>+++ b/modules/audio_output/audiotrack.c<br>@@ -2040,7 +2040,7 @@ bailout:<br> }<br> <br> static void<br>-Flush( audio_output_t *p_aout, bool b_wait )<br>+Flush( audio_output_t *p_aout )<br> {<br> aout_sys_t *p_sys = p_aout->sys;<br> JNIEnv *env;<br>@@ -2061,25 +2061,10 @@ Flush( audio_output_t *p_aout, bool b_wait )<br> * that has not been played back will be discarded. No-op if not stopped<br> * or paused, or if the track's creation mode is not MODE_STREAM.<br> */<br>- if( b_wait )<br>- {<br>- /* Wait for the thread to process the circular buffer */<br>- while( !p_sys->b_error<br>- && p_sys->circular.i_read != p_sys->circular.i_write )<br>- vlc_cond_wait( &p_sys->aout_cond, &p_sys->lock );<br>- if( p_sys->b_error )<br>- goto bailout;<br>-<br>- JNI_AT_CALL_VOID( stop );<br>- if( CHECK_AT_EXCEPTION( "stop" ) )<br>- goto bailout;<br>- } else<br>- {<br>- JNI_AT_CALL_VOID( pause );<br>- if( CHECK_AT_EXCEPTION( "pause" ) )<br>- goto bailout;<br>- JNI_AT_CALL_VOID( flush );<br>- }<br>+ JNI_AT_CALL_VOID( pause );<br>+ if( CHECK_AT_EXCEPTION( "pause" ) )<br>+ goto bailout;<br>+ JNI_AT_CALL_VOID( flush );<br> p_sys->circular.i_read = p_sys->circular.i_write = 0;<br> <br> /* HACK: Before Android 4.4, the head position is not reset to zero and is<br>diff --git a/modules/audio_output/audiounit_ios.m b/modules/audio_output/audiounit_ios.m<br>index e449f6e2eb..ea555c0c14 100644<br>--- a/modules/audio_output/audiounit_ios.m<br>+++ b/modules/audio_output/audiounit_ios.m<br>@@ -409,15 +409,7 @@ Pause (audio_output_t *p_aout, bool pause, vlc_tick_t date)<br> * that we loose 1-2 sec of audio when resuming. The order is important<br> * here, ca_Flush need to be called when paused. */<br> if (pause)<br>- ca_Flush(p_aout, false);<br>-}<br>-<br>-static void<br>-Flush(audio_output_t *p_aout, bool wait)<br>-{<br>- aout_sys_t * p_sys = p_aout->sys;<br>-<br>- ca_Flush(p_aout, wait);<br>+ ca_Flush(p_aout);<br> }<br> <br> static int<br>@@ -430,7 +422,7 @@ MuteSet(audio_output_t *p_aout, bool mute)<br> {<br> Pause(p_aout, mute, 0);<br> if (mute)<br>- ca_Flush(p_aout, false);<br>+ ca_Flush(p_aout);<br> }<br> <br> return VLC_SUCCESS;<br>@@ -562,7 +554,6 @@ Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)<br> fmt->channel_type = AUDIO_CHANNEL_TYPE_BITMAP;<br> p_aout->mute_set = MuteSet;<br> p_aout->pause = Pause;<br>- p_aout->flush = Flush;<br> <br> aout_SoftVolumeStart( p_aout );<br> <br>diff --git a/modules/audio_output/coreaudio_common.c b/modules/audio_output/coreaudio_common.c<br>index d790daf1cb..4a714f5411 100644<br>--- a/modules/audio_output/coreaudio_common.c<br>+++ b/modules/audio_output/coreaudio_common.c<br>@@ -230,42 +230,21 @@ ca_TimeGet(audio_output_t *p_aout, vlc_tick_t *delay)<br> }<br> <br> void<br>-ca_Flush(audio_output_t *p_aout, bool wait)<br>+ca_Flush(audio_output_t *p_aout)<br> {<br> struct aout_sys_common *p_sys = (struct aout_sys_common *) p_aout->sys;<br> <br> lock_lock(p_sys);<br>- if (wait)<br>- {<br>- while (p_sys->i_out_size > 0)<br>- {<br>- if (p_sys->b_paused)<br>- {<br>- ca_ClearOutBuffers(p_aout);<br>- break;<br>- }<br> <br>- /* Calculate the duration of the circular buffer, in order to wait<br>- * for the render thread to play it all */<br>- const vlc_tick_t i_frame_us =<br>- FramesToUs(p_sys, BytesToFrames(p_sys, p_sys->i_out_size)) + VLC_TICK_FROM_MS(10);<br>- lock_unlock(p_sys);<br>- vlc_tick_sleep(i_frame_us);<br>- lock_lock(p_sys);<br>- }<br>- }<br>+ assert(!p_sys->b_do_flush);<br>+ if (p_sys->b_paused)<br>+ ca_ClearOutBuffers(p_aout);<br> else<br> {<br>- assert(!p_sys->b_do_flush);<br>- if (p_sys->b_paused)<br>- ca_ClearOutBuffers(p_aout);<br>- else<br>- {<br>- p_sys->b_do_flush = true;<br>- lock_unlock(p_sys);<br>- vlc_sem_wait(&p_sys->flush_sem);<br>- lock_lock(p_sys);<br>- }<br>+ p_sys->b_do_flush = true;<br>+ lock_unlock(p_sys);<br>+ vlc_sem_wait(&p_sys->flush_sem);<br>+ lock_lock(p_sys);<br> }<br> <br> p_sys->i_render_host_time = 0;<br>diff --git a/modules/audio_output/coreaudio_common.h b/modules/audio_output/coreaudio_common.h<br>index ead0c34e9e..a860a9aa51 100644<br>--- a/modules/audio_output/coreaudio_common.h<br>+++ b/modules/audio_output/coreaudio_common.h<br>@@ -89,7 +89,7 @@ void ca_Render(audio_output_t *p_aout, uint32_t i_nb_samples, uint64_t i_host_ti<br> <br> int ca_TimeGet(audio_output_t *p_aout, vlc_tick_t *delay);<br> <br>-void ca_Flush(audio_output_t *p_aout, bool wait);<br>+void ca_Flush(audio_output_t *p_aout);<br> <br> void ca_Pause(audio_output_t * p_aout, bool pause, vlc_tick_t date);<br> <br>diff --git a/modules/audio_output/directsound.c b/modules/audio_output/directsound.c<br>index fb4fe75e32..f93237a93a 100644<br>--- a/modules/audio_output/directsound.c<br>+++ b/modules/audio_output/directsound.c<br>@@ -360,19 +360,10 @@ static HRESULT StreamFlush( aout_stream_t *s )<br> return Flush( s->sys );<br> }<br> <br>-static void OutputFlush( audio_output_t *aout, bool drain )<br>+static void OutputFlush( audio_output_t *aout )<br> {<br> aout_sys_t *sys = aout->sys;<br>- if (drain)<br>- { /* Loosy drain emulation */<br>- vlc_tick_t delay;<br>-<br>- if( OutputTimeGet( aout, &delay ) == 0 &&<br>- delay <= VLC_TICK_FROM_SEC( 5 ) )<br>- Sleep( MS_FROM_VLC_TICK( delay ) + 1 );<br>- }<br>- else<br>- Flush( &sys->s );<br>+ Flush( &sys->s );<br> }<br> <br> /**<br>diff --git a/modules/audio_output/file.c b/modules/audio_output/file.c<br>index fbdf35fcb1..906b228548 100644<br>--- a/modules/audio_output/file.c<br>+++ b/modules/audio_output/file.c<br>@@ -75,7 +75,7 @@ static const int pi_channels_maps[CHANNELS_MAX+1] =<br> static int Open ( vlc_object_t * );<br> static void Play ( audio_output_t *, block_t *, vlc_tick_t );<br> static void Pause ( audio_output_t *, bool, vlc_tick_t );<br>-static void Flush ( audio_output_t *, bool );<br>+static void Flush ( audio_output_t * );<br> <br> /*****************************************************************************<br> * Module descriptor<br>@@ -339,12 +339,11 @@ static void Pause( audio_output_t *aout, bool paused, vlc_tick_t date )<br> (void) aout; (void) paused; (void) date;<br> }<br> <br>-static void Flush( audio_output_t *aout, bool wait )<br>+static void Flush( audio_output_t *aout )<br> {<br> aout_sys_t *p_sys = aout->sys;<br> if( fflush( p_sys->p_file ) )<br> msg_Err( aout, "flush error: %s", vlc_strerror_c(errno) );<br>- (void) wait;<br> }<br> <br> static int Open(vlc_object_t *obj)<br>diff --git a/modules/audio_output/jack.c b/modules/audio_output/jack.c<br>index 59ad013b2f..d21150f2a4 100644<br>--- a/modules/audio_output/jack.c<br>+++ b/modules/audio_output/jack.c<br>@@ -71,7 +71,7 @@ static int Open ( vlc_object_t * );<br> static void Close ( vlc_object_t * );<br> static void Play ( audio_output_t * p_aout, block_t *, vlc_tick_t );<br> static void Pause ( audio_output_t *aout, bool paused, vlc_tick_t date );<br>-static void Flush ( audio_output_t *p_aout, bool wait );<br>+static void Flush ( audio_output_t *p_aout );<br> static int TimeGet ( audio_output_t *, vlc_tick_t * );<br> static int Process ( jack_nframes_t i_frames, void *p_arg );<br> static int GraphChange ( void *p_arg );<br>@@ -328,19 +328,11 @@ static void Pause(audio_output_t *aout, bool paused, vlc_tick_t date)<br> }<br> }<br> <br>-static void Flush(audio_output_t *p_aout, bool wait)<br>+static void Flush(audio_output_t *p_aout)<br> {<br> aout_sys_t * p_sys = p_aout->sys;<br> jack_ringbuffer_t *rb = p_sys->p_jack_ringbuffer;<br> <br>- /* Sleep if wait was requested */<br>- if( wait )<br>- {<br>- vlc_tick_t delay;<br>- if (!TimeGet(p_aout, &delay))<br>- vlc_tick_sleep(delay);<br>- }<br>-<br> /* reset ringbuffer read and write pointers */<br> jack_ringbuffer_reset(rb);<br> }<br>diff --git a/modules/audio_output/kai.c b/modules/audio_output/kai.c<br>index 98a2182394..dd75e367d8 100644<br>--- a/modules/audio_output/kai.c<br>+++ b/modules/audio_output/kai.c<br>@@ -74,7 +74,7 @@ static int Open ( vlc_object_t * );<br> static void Close ( vlc_object_t * );<br> static void Play ( audio_output_t *_p_aout, block_t *block, vlc_tick_t );<br> static void Pause ( audio_output_t *, bool, vlc_tick_t );<br>-static void Flush ( audio_output_t *, bool );<br>+static void Flush ( audio_output_t * );<br> static int TimeGet ( audio_output_t *, vlc_tick_t *restrict );<br> <br> static ULONG APIENTRY KaiCallback ( PVOID, PVOID, ULONG );<br>@@ -310,23 +310,15 @@ static void Pause( audio_output_t *aout, bool pause, vlc_tick_t date )<br> kaiResume( sys->hkai );<br> }<br> <br>-static void Flush( audio_output_t *aout, bool drain )<br>+static void Flush( audio_output_t *aout )<br> {<br> aout_sys_t *sys = aout->sys;<br> audio_buffer_t *buffer = sys->buffer;<br> <br> vlc_mutex_lock( &buffer->mutex );<br> <br>- if( drain )<br>- {<br>- while( buffer->length > 0 )<br>- vlc_cond_wait( &buffer->cond, &buffer->mutex );<br>- }<br>- else<br>- {<br>- buffer->read_pos = buffer->write_pos;<br>- buffer->length = 0;<br>- }<br>+ buffer->read_pos = buffer->write_pos;<br>+ buffer->length = 0;<br> <br> vlc_mutex_unlock( &buffer->mutex );<br> }<br>diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c<br>index 162c8350b7..4c79cabf1d 100644<br>--- a/modules/audio_output/mmdevice.c<br>+++ b/modules/audio_output/mmdevice.c<br>@@ -162,13 +162,13 @@ static void Pause(audio_output_t *aout, bool paused, vlc_tick_t date)<br> (void) date;<br> }<br> <br>-static void Flush(audio_output_t *aout, bool wait)<br>+static void Flush(audio_output_t *aout)<br> {<br> aout_sys_t *sys = aout->sys;<br> HRESULT hr;<br> <br> EnterMTA();<br>- hr = aout_stream_Flush(sys->stream, wait);<br>+ hr = aout_stream_Flush(sys->stream);<br> LeaveMTA();<br> <br> vlc_FromHR(aout, hr);<br>diff --git a/modules/audio_output/mmdevice.h b/modules/audio_output/mmdevice.h<br>index d671f450d3..2e131ab01f 100644<br>--- a/modules/audio_output/mmdevice.h<br>+++ b/modules/audio_output/mmdevice.h<br>@@ -77,19 +77,9 @@ static inline HRESULT aout_stream_Pause(aout_stream_t *s, bool paused)<br> return (s->pause)(s, paused);<br> }<br> <br>-static inline HRESULT aout_stream_Flush(aout_stream_t *s, bool wait)<br>+static inline HRESULT aout_stream_Flush(aout_stream_t *s)<br> {<br>- if (wait)<br>- { /* Loosy drain emulation */<br>- vlc_tick_t delay;<br>-<br>- if (SUCCEEDED(aout_stream_TimeGet(s, &delay)) &&<br>- delay <= VLC_TICK_FROM_SEC(5))<br>- Sleep(MS_FROM_VLC_TICK( delay ) + 1);<br>- return S_OK;<br>- }<br>- else<br>- return (s->flush)(s);<br>+ return (s->flush)(s);<br> }<br> <br> static inline<br>diff --git a/modules/audio_output/opensles_android.c b/modules/audio_output/opensles_android.c<br>index f0d7360397..b1c2a0d985 100644<br>--- a/modules/audio_output/opensles_android.c<br>+++ b/modules/audio_output/opensles_android.c<br>@@ -177,30 +177,24 @@ static int TimeGet(audio_output_t* aout, vlc_tick_t* restrict drift)<br> return 0;<br> }<br> <br>-static void Flush(audio_output_t *aout, bool drain)<br>+static void Flush(audio_output_t *aout)<br> {<br> aout_sys_t *sys = aout->sys;<br> <br>- if (drain) {<br>- vlc_tick_t delay;<br>- if (!TimeGet(aout, &delay))<br>- vlc_tick_sleep(delay);<br>- } else {<br>- vlc_mutex_lock(&sys->lock);<br>- SetPlayState(sys->playerPlay, SL_PLAYSTATE_STOPPED);<br>- Clear(sys->playerBufferQueue);<br>- SetPlayState(sys->playerPlay, SL_PLAYSTATE_PLAYING);<br>-<br>- /* release audio data not yet written to opensles */<br>- block_ChainRelease(sys->p_buffer_chain);<br>- sys->p_buffer_chain = NULL;<br>- sys->pp_buffer_last = &sys->p_buffer_chain;<br>+ vlc_mutex_lock(&sys->lock);<br>+ SetPlayState(sys->playerPlay, SL_PLAYSTATE_STOPPED);<br>+ Clear(sys->playerBufferQueue);<br>+ SetPlayState(sys->playerPlay, SL_PLAYSTATE_PLAYING);<br> <br>- sys->samples = 0;<br>- sys->started = false;<br>+ /* release audio data not yet written to opensles */<br>+ block_ChainRelease(sys->p_buffer_chain);<br>+ sys->p_buffer_chain = NULL;<br>+ sys->pp_buffer_last = &sys->p_buffer_chain;<br> <br>- vlc_mutex_unlock(&sys->lock);<br>- }<br>+ sys->samples = 0;<br>+ sys->started = false;<br>+<br>+ vlc_mutex_unlock(&sys->lock);<br> }<br> <br> static int VolumeSet(audio_output_t *aout, float vol)<br>diff --git a/modules/audio_output/oss.c b/modules/audio_output/oss.c<br>index 5e16255798..5bada6857d 100644<br>--- a/modules/audio_output/oss.c<br>+++ b/modules/audio_output/oss.c<br>@@ -90,7 +90,7 @@ vlc_module_end ()<br> static int TimeGet (audio_output_t *, vlc_tick_t *);<br> static void Play(audio_output_t *, block_t *, vlc_tick_t);<br> static void Pause (audio_output_t *, bool, vlc_tick_t);<br>-static void Flush (audio_output_t *, bool);<br>+static void Flush (audio_output_t *);<br> <br> static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)<br> {<br>@@ -302,15 +302,13 @@ static void Pause (audio_output_t *aout, bool pause, vlc_tick_t date)<br> }<br> <br> /**<br>- * Flushes/drains the audio playback buffer.<br>+ * Flushes the audio playback buffer.<br> */<br>-static void Flush (audio_output_t *aout, bool wait)<br>+static void Flush (audio_output_t *aout)<br> {<br> aout_sys_t *sys = aout->sys;<br> int fd = sys->fd;<br> <br>- if (wait)<br>- return; /* drain is implicit with OSS */<br> ioctl (fd, SNDCTL_DSP_HALT, NULL);<br> }<br> <br>diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c<br>index a76fd6c657..cc4af1e8c0 100644<br>--- a/modules/audio_output/pulse.c<br>+++ b/modules/audio_output/pulse.c<br>@@ -533,26 +533,14 @@ static void Pause(audio_output_t *aout, bool paused, vlc_tick_t date)<br> /**<br> * Flush or drain the playback stream<br> */<br>-static void Flush(audio_output_t *aout, bool wait)<br>+static void Flush(audio_output_t *aout)<br> {<br> aout_sys_t *sys = aout->sys;<br> pa_stream *s = sys->stream;<br>- pa_operation *op;<br> <br> pa_threaded_mainloop_lock(sys->mainloop);<br> <br>- if (wait)<br>- {<br>- op = pa_stream_drain(s, NULL, NULL);<br>-<br>- /* XXX: Loosy drain emulation.<br>- * See #18141: drain callback is never received */<br>- vlc_tick_t delay;<br>- if (TimeGet(aout, &delay) == 0 && delay <= VLC_TICK_FROM_SEC(5))<br>- vlc_tick_sleep(delay);<br>- }<br>- else<br>- op = pa_stream_flush(s, NULL, NULL);<br>+ pa_operation *op = pa_stream_flush(s, NULL, NULL);<br> if (op != NULL)<br> pa_operation_unref(op);<br> sys->last_date = VLC_TICK_INVALID;<br>@@ -561,6 +549,24 @@ static void Flush(audio_output_t *aout, bool wait)<br> pa_threaded_mainloop_unlock(sys->mainloop);<br> }<br> <br>+static void Drain(audio_output_t *aout)<br>+{<br>+ aout_sys_t *sys = aout->sys;<br>+ pa_stream *s = sys->stream;<br>+<br>+ pa_threaded_mainloop_lock(sys->mainloop);<br>+ pa_operation *op = pa_stream_drain(s, NULL, NULL);<br>+ if (op != NULL)<br>+ pa_operation_unref(op);<br>+ pa_threaded_mainloop_unlock(sys->mainloop);<br>+<br>+ /* XXX: Loosy drain emulation.<br>+ * See #18141: drain callback is never received */<br>+ vlc_tick_t delay;<br>+ if (TimeGet(aout, &delay) == 0 && delay <= VLC_TICK_FROM_SEC(5))<br>+ vlc_tick_sleep(delay);<br>+}<br>+<br> static int VolumeSet(audio_output_t *aout, float vol)<br> {<br> aout_sys_t *sys = aout->sys;<br>@@ -1006,6 +1012,7 @@ static int Open(vlc_object_t *obj)<br> aout->play = Play;<br> aout->pause = Pause;<br> aout->flush = Flush;<br>+ aout->drain = Drain;<br> aout->volume_set = VolumeSet;<br> aout->mute_set = MuteSet;<br> aout->device_select = StreamMove;<br>diff --git a/modules/audio_output/sndio.c b/modules/audio_output/sndio.c<br>index 6b28772817..642113a487 100644<br>--- a/modules/audio_output/sndio.c<br>+++ b/modules/audio_output/sndio.c<br>@@ -45,7 +45,7 @@ vlc_module_end ()<br> <br> static int TimeGet (audio_output_t *, vlc_tick_t *);<br> static void Play(audio_output_t *, block_t *, vlc_tick_t);<br>-static void Flush (audio_output_t *, bool);<br>+static void Flush (audio_output_t *);<br> static int VolumeSet (audio_output_t *, float);<br> static int MuteSet (audio_output_t *, bool);<br> static void VolumeChanged (void *, unsigned);<br>@@ -240,7 +240,7 @@ static void Play(audio_output_t *aout, block_t *block, vlc_tick_t date)<br> (void) date;<br> }<br> <br>-static void Flush (audio_output_t *aout, bool wait)<br>+static void Flush (audio_output_t *aout)<br> {<br> aout_sys_t *sys = aout->sys;<br> <br>@@ -248,7 +248,6 @@ static void Flush (audio_output_t *aout, bool wait)<br> sys->started = 0;<br> sys->delay = 0;<br> sio_start (sys->hdl);<br>- (void)wait;<br> }<br> <br> static void VolumeChanged (void *arg, unsigned volume)<br>diff --git a/modules/audio_output/waveout.c b/modules/audio_output/waveout.c<br>index b9be127bb6..3c9884ce01 100644<br>--- a/modules/audio_output/waveout.c<br>+++ b/modules/audio_output/waveout.c<br>@@ -79,7 +79,8 @@ static void WaveOutClearBuffer( HWAVEOUT, WAVEHDR *);<br> static int ReloadWaveoutDevices( const char *, char ***, char *** );<br> static uint32_t findDeviceID(char *);<br> static int WaveOutTimeGet(audio_output_t * , vlc_tick_t *);<br>-static void WaveOutFlush( audio_output_t *, bool);<br>+static void WaveOutFlush( audio_output_t *);<br>+static void WaveOutDrain( audio_output_t *);<br> static void WaveOutPause( audio_output_t *, bool, vlc_tick_t);<br> static int WaveoutVolumeSet(audio_output_t * p_aout, float volume);<br> static int WaveoutMuteSet(audio_output_t * p_aout, bool mute);<br>@@ -177,6 +178,7 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )<br> p_aout->play = Play;<br> p_aout->pause = WaveOutPause;<br> p_aout->flush = WaveOutFlush;<br>+ p_aout->drain = WaveOutDrain;<br> <br> aout_sys_t *sys = p_aout->sys;<br> <br>@@ -393,7 +395,7 @@ static void Stop( audio_output_t *p_aout )<br> MMRESULT result = waveOutReset( p_sys->h_waveout );<br> <br> /* wait for the frames to be queued in cleaning list */<br>- WaveOutFl</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>