<html><head></head><body>You need to start with the PTS of the first block in queue, not the last block. This does not look right.<br><br><div class="gmail_quote">Le 2 juillet 2018 17:31:59 GMT+03: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">If I understand correctly, stream_latency_cb() is needed to re-calculate the<br>new derrered time (or start late in the worst case scenario) when the audio<br>device latency changes.<br><br>This callback called stream_start() with the first played system date. The<br>problem is that the delta calculated from stream_start was always late. Using<br>the last system date seems more logical. Indeed, the delta need to be<br>calculated from values using the same reference point (and vlc_pa_get_latency()<br>is calculated from the amount of buffers played).<br><br>This issue can be reproduced when the first played date is more than 100ms in<br>the future.<br>---<br> modules/audio_output/pulse.c | 22 +++++++++-------------<br> 1 file changed, 9 insertions(+), 13 deletions(-)<br><br>diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c<br>index f999eb534b..a275c9f5e6 100644<br>--- a/modules/audio_output/pulse.c<br>+++ b/modules/audio_output/pulse.c<br>@@ -68,8 +68,7 @@ typedef struct<br> pa_threaded_mainloop *mainloop; /**< PulseAudio thread */<br> pa_time_event *trigger; /**< Deferred stream trigger */<br> pa_cvolume cvolume; /**< actual sink input volume */<br>- vlc_tick_t first_pts; /**< Play stream timestamp of buffer start */<br>- vlc_tick_t first_date; /**< Play system timestamp of buffer start */<br>+ vlc_tick_t last_date; /**< Play system timestamp of last buffer */<br> <br> pa_volume_t volume_force; /**< Forced volume (stream must be NULL) */<br> pa_stream_flags_t flags_force; /**< Forced flags (stream must be NULL) */<br>@@ -227,7 +226,7 @@ static void stream_start(pa_stream *s, audio_output_t *aout, vlc_tick_t date)<br> aout_sys_t *sys = aout->sys;<br> vlc_tick_t delta;<br> <br>- assert (sys->first_pts != VLC_TS_INVALID);<br>+ assert (sys->last_date != VLC_TS_INVALID);<br> <br> if (sys->trigger != NULL) {<br> vlc_pa_rttime_free(sys->mainloop, sys->trigger);<br>@@ -258,10 +257,10 @@ static void stream_latency_cb(pa_stream *s, void *userdata)<br> aout_sys_t *sys = aout->sys;<br> <br> /* This callback is _never_ called while paused. */<br>- if (sys->first_pts == VLC_TS_INVALID)<br>+ if (sys->last_date == VLC_TS_INVALID)<br> return; /* nothing to do if buffers are (still) empty */<br> if (pa_stream_is_corked(s) > 0)<br>- stream_start(s, aout, sys->first_date);<br>+ stream_start(s, aout, sys->last_date);<br> }<br> <br> <br>@@ -331,7 +330,7 @@ static void stream_overflow_cb(pa_stream *s, void *userdata)<br> if (unlikely(op == NULL))<br> return;<br> pa_operation_unref(op);<br>- sys->first_pts = VLC_TS_INVALID;<br>+ sys->last_date = VLC_TS_INVALID;<br> }<br> <br> static void stream_started_cb(pa_stream *s, void *userdata)<br>@@ -504,10 +503,7 @@ static void Play(audio_output_t *aout, block_t *block, vlc_tick_t date)<br> * will take place, and sooner or later a deadlock. */<br> pa_threaded_mainloop_lock(sys->mainloop);<br> <br>- if (sys->first_pts == VLC_TS_INVALID) {<br>- sys->first_pts = block->i_pts;<br>- sys->first_date = date;<br>- }<br>+ sys->last_date = date;<br> <br> if (pa_stream_is_corked(s) > 0)<br> stream_start(s, aout, date);<br>@@ -543,7 +539,7 @@ static void Pause(audio_output_t *aout, bool paused, vlc_tick_t date)<br> stream_stop(s, aout);<br> } else {<br> pa_stream_set_latency_update_callback(s, stream_latency_cb, aout);<br>- if (likely(sys->first_pts != VLC_TS_INVALID))<br>+ if (likely(sys->last_date != VLC_TS_INVALID))<br> stream_start_now(s, aout);<br> }<br> <br>@@ -576,7 +572,7 @@ static void Flush(audio_output_t *aout, bool wait)<br> op = pa_stream_flush(s, NULL, NULL);<br> if (op != NULL)<br> pa_operation_unref(op);<br>- sys->first_pts = VLC_TS_INVALID;<br>+ sys->last_date = VLC_TS_INVALID;<br> stream_stop(s, aout);<br> <br> pa_threaded_mainloop_unlock(sys->mainloop);<br>@@ -807,7 +803,7 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)<br> <br> sys->trigger = NULL;<br> pa_cvolume_init(&sys->cvolume);<br>- sys->first_pts = VLC_TS_INVALID;<br>+ sys->last_date = VLC_TS_INVALID;<br> <br> pa_format_info *formatv = pa_format_info_new();<br> formatv->encoding = encoding;</pre></blockquote></div><br>
-- <br>
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>