[vlc-devel] [RFC PATCH 8/9] pulse: request timing asynchronously

Rémi Denis-Courmont remi at remlab.net
Thu Dec 10 19:51:54 CET 2020


Le jeudi 10 décembre 2020, 19:10:14 EET Thomas Guillem a écrit :
> ---
>  modules/audio_output/pulse.c | 40 +++++++++++++++---------------------
>  1 file changed, 16 insertions(+), 24 deletions(-)
> 
> diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
> index 709f085c6f..49de51b5ed 100644
> --- a/modules/audio_output/pulse.c
> +++ b/modules/audio_output/pulse.c
> @@ -69,6 +69,7 @@ typedef struct
>      pa_time_event *trigger; /**< Deferred stream trigger */
>      pa_cvolume cvolume; /**< actual sink input volume */
>      vlc_tick_t last_date; /**< Play system timestamp of last buffer */
> +    vlc_tick_t last_pts; /**< PTS or last buffer */
> 
>      pa_volume_t volume_force; /**< Forced volume (stream must be NULL) */
>      pa_stream_flags_t flags_force; /**< Forced flags (stream must be NULL)

This all patch seems eerily familiar. Is this some kind of revert-revert?

> */ @@ -261,6 +262,16 @@ static void stream_latency_cb(pa_stream *s, void
> *userdata) return; /* nothing to do if buffers are (still) empty */
>      if (pa_stream_is_corked(s) > 0)
>          stream_start(s, aout, sys->last_date);
> +
> +    if (sys->last_pts == VLC_TICK_INVALID)
> +        return;
> +
> +    vlc_tick_t latency = vlc_pa_get_latency(aout, sys->context, s);
> +    if (latency != VLC_TICK_INVALID)
> +    {
> +        vlc_tick_t now = vlc_tick_now();
> +        aout_TimingReport(aout, now + latency, sys->last_pts);
> +    }
>  }
> 
> 
> @@ -334,6 +345,7 @@ static void stream_overflow_cb(pa_stream *s, void
> *userdata) return;
>      pa_operation_unref(op);
>      sys->last_date = VLC_TICK_INVALID;
> +    sys->last_pts = VLC_TICK_INVALID;
>  }
> 
>  static void stream_started_cb(pa_stream *s, void *userdata)
> @@ -438,29 +450,6 @@ static void context_cb(pa_context *ctx,
> pa_subscription_event_type_t type, }
>  }
> 
> -
> -/*** VLC audio output callbacks ***/
> -
> -static int TimeGet(audio_output_t *aout, vlc_tick_t *restrict delay)
> -{
> -    aout_sys_t *sys = aout->sys;
> -    pa_stream *s = sys->stream;
> -    int ret = -1;
> -
> -    pa_threaded_mainloop_lock(sys->mainloop);
> -    if (pa_stream_is_corked(s) <= 0)
> -    {   /* latency is relevant only if not corked */
> -        vlc_tick_t delta = vlc_pa_get_latency(aout, sys->context, s);
> -        if (delta != VLC_TICK_INVALID)
> -        {
> -            *delay = delta;
> -            ret = 0;
> -        }
> -    }
> -    pa_threaded_mainloop_unlock(sys->mainloop);
> -    return ret;
> -}
> -
>  /**
>   * Queue one audio frame to the playback stream
>   */
> @@ -505,6 +494,7 @@ static void Play(audio_output_t *aout, block_t *block,
> vlc_tick_t date) vlc_pa_error(aout, "cannot write", sys->context);
>      }
> 
> +    sys->last_pts = block->i_pts;
>      block_Release(block);
> 
>      pa_threaded_mainloop_unlock(sys->mainloop);
> @@ -547,6 +537,7 @@ static void Flush(audio_output_t *aout)
>      if (op != NULL)
>          pa_operation_unref(op);
>      sys->last_date = VLC_TICK_INVALID;
> +    sys->last_pts = VLC_TICK_INVALID;
>      stream_stop(s, aout);
> 
>      pa_threaded_mainloop_unlock(sys->mainloop);
> @@ -577,6 +568,7 @@ static void Drain(audio_output_t *aout)
>      if (op != NULL)
>          pa_operation_unref(op);
>      sys->last_date = VLC_TICK_INVALID;
> +    sys->last_pts = VLC_TICK_INVALID;
> 
>      /* XXX: Loosy drain emulation.
>       * See #18141: drain callback is never received */
> @@ -818,6 +810,7 @@ static int Start(audio_output_t *aout,
> audio_sample_format_t *restrict fmt) sys->trigger = NULL;
>      pa_cvolume_init(&sys->cvolume);
>      sys->last_date = VLC_TICK_INVALID;
> +    sys->last_pts = VLC_TICK_INVALID;
> 
>      pa_format_info *formatv = pa_format_info_new();
>      formatv->encoding = encoding;
> @@ -1033,7 +1026,6 @@ static int Open(vlc_object_t *obj)
>      aout->sys = sys;
>      aout->start = Start;
>      aout->stop = Stop;
> -    aout->time_get = TimeGet;
>      aout->play = Play;
>      aout->pause = Pause;
>      aout->flush = Flush;


-- 
Rémi Denis-Courmont




More information about the vlc-devel mailing list