[vlc-commits] [Git][videolan/vlc][master] 4 commits: aout: vlc_aout_stream_New: use a cfg struct

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Fri May 6 06:47:54 UTC 2022



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
0a9a3316 by Thomas Guillem at 2022-05-06T06:24:07+00:00
aout: vlc_aout_stream_New: use a cfg struct

- - - - -
99b2870d by Thomas Guillem at 2022-05-06T06:24:07+00:00
tracer: add an helper to trace events

- - - - -
8f2a2093 by Thomas Guillem at 2022-05-06T06:24:07+00:00
vout: trace more events

Specially late and toolate.

- - - - -
dc83b0a2 by Thomas Guillem at 2022-05-06T06:24:07+00:00
aout: trace more events

Specially late/early events.

- - - - -


6 changed files:

- include/vlc_tracer.h
- src/audio_output/aout_internal.h
- src/audio_output/dec.c
- src/input/decoder.c
- src/video_output/video_output.c
- src/video_output/vout_internal.h


Changes:

=====================================
include/vlc_tracer.h
=====================================
@@ -172,6 +172,13 @@ static inline void vlc_tracer_TraceRender(struct vlc_tracer *tracer, const char
                      VLC_TRACE("render_ts", NS_FROM_VLC_TICK(now)), VLC_TRACE_END);
 }
 
+static inline void vlc_tracer_TraceEvent(struct vlc_tracer *tracer, const char *type,
+                                         const char *id, const char *event)
+{
+    vlc_tracer_Trace(tracer, VLC_TRACE("type", type), VLC_TRACE("id", id),
+                     VLC_TRACE("event", event), VLC_TRACE_END);
+}
+
 static inline void vlc_tracer_TracePCR( struct vlc_tracer *tracer, const char *type,
                                     const char *id, vlc_tick_t pcr)
 {


=====================================
src/audio_output/aout_internal.h
=====================================
@@ -132,10 +132,17 @@ void aout_FormatsPrint(vlc_object_t *, const char *,
 #define AOUT_DEC_CHANGED 1
 #define AOUT_DEC_FAILED VLC_EGENERIC
 
+struct vlc_aout_stream_cfg
+{
+    const audio_sample_format_t *fmt;
+    int profile;
+    struct vlc_clock_t *clock;
+    const char *str_id;
+    const audio_replay_gain_t *replay_gain;
+};
+
 vlc_aout_stream *vlc_aout_stream_New(audio_output_t *p_aout,
-                                     const audio_sample_format_t *p_format,
-                                     int profile, struct vlc_clock_t *clock,
-                                     const audio_replay_gain_t *p_replay_gain);
+                                     const struct vlc_aout_stream_cfg *cfg);
 void vlc_aout_stream_Delete(vlc_aout_stream *);
 int vlc_aout_stream_Play(vlc_aout_stream *stream, block_t *block);
 void vlc_aout_stream_GetResetStats(vlc_aout_stream *stream, unsigned *, unsigned *);


=====================================
src/audio_output/dec.c
=====================================
@@ -33,6 +33,7 @@
 
 #include <vlc_common.h>
 #include <vlc_aout.h>
+#include <vlc_tracer.h>
 
 #include "aout_internal.h"
 #include "clock/clock.h"
@@ -60,6 +61,8 @@ struct vlc_aout_stream
     } sync;
     vlc_tick_t original_pts;
 
+    const char *str_id;
+
     /* Original input format and profile, won't change for the lifetime of a
      * stream (between vlc_aout_stream_New() and vlc_aout_stream_Delete()). */
     int                   input_profile;
@@ -90,6 +93,12 @@ static inline audio_output_t *aout_stream_aout(vlc_aout_stream *stream)
     return &stream->instance->output;
 }
 
+static inline struct vlc_tracer *aout_stream_tracer(vlc_aout_stream *stream)
+{
+    return stream->str_id == NULL ? NULL :
+        vlc_object_get_tracer(VLC_OBJECT(aout_stream_aout(stream)));
+}
+
 static void stream_Reset(vlc_aout_stream *stream)
 {
     aout_owner_t *owner = aout_stream_owner(stream);
@@ -133,13 +142,13 @@ static void stream_Reset(vlc_aout_stream *stream)
  * Creates an audio output
  */
 vlc_aout_stream * vlc_aout_stream_New(audio_output_t *p_aout,
-                                      const audio_sample_format_t *p_format,
-                                      int profile, vlc_clock_t *clock,
-                                      const audio_replay_gain_t *p_replay_gain)
+                                      const struct vlc_aout_stream_cfg *cfg)
 {
     assert(p_aout);
-    assert(p_format);
-    assert(clock);
+    assert(cfg->fmt);
+    assert(cfg->clock);
+    const audio_sample_format_t *p_format = cfg->fmt;
+
     if( p_format->i_bitspersample > 0 )
     {
         /* Sanitize audio format, input need to have a valid physical channels
@@ -175,13 +184,14 @@ vlc_aout_stream * vlc_aout_stream_New(audio_output_t *p_aout,
 
     stream->volume = NULL;
     if (!owner->bitexact)
-        stream->volume = aout_volume_New (p_aout, p_replay_gain);
+        stream->volume = aout_volume_New (p_aout, cfg->replay_gain);
 
     atomic_init(&stream->restart, 0);
-    stream->input_profile = profile;
+    stream->input_profile = cfg->profile;
     stream->filter_format = stream->mixer_format = stream->input_format = *p_format;
 
-    stream->sync.clock = clock;
+    stream->sync.clock = cfg->clock;
+    stream->str_id = cfg->str_id;
 
     stream->filters = NULL;
     stream->filters_cfg = AOUT_FILTERS_CFG_INIT;
@@ -197,7 +207,7 @@ vlc_aout_stream * vlc_aout_stream_New(audio_output_t *p_aout,
             aout_volume_SetFormat(stream->volume, stream->mixer_format.i_format);
 
         /* Create the audio filtering "input" pipeline */
-        stream->filters = aout_FiltersNewWithClock(VLC_OBJECT(p_aout), clock,
+        stream->filters = aout_FiltersNewWithClock(VLC_OBJECT(p_aout), cfg->clock,
                                                    &stream->filter_format,
                                                    &stream->mixer_format,
                                                    &stream->filters_cfg);
@@ -267,8 +277,13 @@ static int stream_CheckReady (vlc_aout_stream *stream)
             stream->filters = NULL;
         }
 
+        struct vlc_tracer *tracer = aout_stream_tracer(stream);
+
         if (restart & AOUT_RESTART_OUTPUT)
         {   /* Reinitializes the output */
+            if (tracer != NULL)
+                vlc_tracer_TraceEvent(tracer, "RENDER", stream->str_id, "restart");
+
             msg_Dbg (aout, "restarting output...");
             if (stream->mixer_format.i_format)
                 aout_OutputDelete (aout);
@@ -288,6 +303,8 @@ static int stream_CheckReady (vlc_aout_stream *stream)
             if (restart == AOUT_RESTART_OUTPUT)
                 status = AOUT_DEC_CHANGED;
         }
+        else if (tracer != NULL)
+            vlc_tracer_TraceEvent(tracer, "RENDER", stream->str_id, "filters_restart");
 
         msg_Dbg (aout, "restarting filters...");
         stream->sync.resamp_type = AOUT_RESAMPLING_NONE;
@@ -378,6 +395,8 @@ static void stream_RequestRetiming(vlc_aout_stream *stream, vlc_tick_t system_ts
     if (unlikely(drift == VLC_TICK_MAX) || owner->bitexact)
         return; /* cf. VLC_TICK_MAX comment in vlc_aout_stream_Play() */
 
+    struct vlc_tracer *tracer = aout_stream_tracer(stream);
+
     /* Following calculations expect an opposite drift. Indeed,
      * vlc_clock_Update() returns a positive relative time, corresponding to
      * the time when audio_ts is expected to be played (in the future when not
@@ -393,6 +412,9 @@ static void stream_RequestRetiming(vlc_aout_stream *stream, vlc_tick_t system_ts
     if (drift > (stream->sync.discontinuity ? 0
                 : lroundf(+3 * AOUT_MAX_PTS_DELAY / rate)))
     {
+        if (tracer != NULL)
+            vlc_tracer_TraceEvent(tracer, "RENDER", stream->str_id, "late_flush");
+
         if (!stream->sync.discontinuity)
             msg_Warn (aout, "playback way too late (%"PRId64"): "
                       "flushing buffers", drift);
@@ -411,8 +433,13 @@ static void stream_RequestRetiming(vlc_aout_stream *stream, vlc_tick_t system_ts
                 : lroundf(-3 * AOUT_MAX_PTS_ADVANCE / rate)))
     {
         if (!stream->sync.discontinuity)
+        {
+            if (tracer != NULL)
+                vlc_tracer_TraceEvent(tracer, "RENDER", stream->str_id, "early_silence");
+
             msg_Warn (aout, "playback way too early (%"PRId64"): "
                       "playing silence", drift);
+        }
         stream_Silence(stream, -drift, audio_ts);
 
         stream_StopResampling(stream);
@@ -427,6 +454,8 @@ static void stream_RequestRetiming(vlc_aout_stream *stream, vlc_tick_t system_ts
     if (drift > +AOUT_MAX_PTS_DELAY
      && stream->sync.resamp_type != AOUT_RESAMPLING_UP)
     {
+        if (tracer != NULL)
+            vlc_tracer_TraceEvent(tracer, "RENDER", stream->str_id, "late_upsampling");
         msg_Warn (aout, "playback too late (%"PRId64"): up-sampling",
                   drift);
         stream->sync.resamp_type = AOUT_RESAMPLING_UP;
@@ -435,6 +464,8 @@ static void stream_RequestRetiming(vlc_aout_stream *stream, vlc_tick_t system_ts
     if (drift < -AOUT_MAX_PTS_ADVANCE
      && stream->sync.resamp_type != AOUT_RESAMPLING_DOWN)
     {
+        if (tracer != NULL)
+            vlc_tracer_TraceEvent(tracer, "RENDER", stream->str_id, "early_downsampling");
         msg_Warn (aout, "playback too early (%"PRId64"): down-sampling",
                   drift);
         stream->sync.resamp_type = AOUT_RESAMPLING_DOWN;
@@ -447,6 +478,9 @@ static void stream_RequestRetiming(vlc_aout_stream *stream, vlc_tick_t system_ts
     if (llabs (drift) > 2 * stream->sync.resamp_start_drift)
     {   /* If the drift is ever increasing, then something is seriously wrong.
          * Cease resampling and hope for the best. */
+        if (tracer != NULL)
+            vlc_tracer_TraceEvent(tracer, "RENDER", stream->str_id, "timing_screwed");
+
         msg_Warn (aout, "timing screwed (drift: %"PRId64" us): "
                   "stopping resampling", drift);
         stream_StopResampling(stream);
@@ -466,6 +500,9 @@ static void stream_RequestRetiming(vlc_aout_stream *stream, vlc_tick_t system_ts
     if (!aout_FiltersAdjustResampling (stream->filters, adj))
     {   /* Everything is back to normal: stop resampling. */
         stream->sync.resamp_type = AOUT_RESAMPLING_NONE;
+
+        if (tracer != NULL)
+            vlc_tracer_TraceEvent(tracer, "RENDER", stream->str_id, "stop_resampling");
         msg_Dbg (aout, "resampling stopped (drift: %"PRId64" us)", drift);
     }
 }
@@ -632,6 +669,11 @@ void vlc_aout_stream_ChangePause(vlc_aout_stream *stream, bool paused, vlc_tick_
 
     if (stream->mixer_format.i_format)
     {
+        struct vlc_tracer *tracer = aout_stream_tracer(stream);
+        if (tracer != NULL)
+            vlc_tracer_TraceEvent(tracer, "RENDER", stream->str_id,
+                                  paused ? "paused" : "resumed");
+
         if (aout->pause != NULL)
             aout->pause(aout, paused, date);
         else if (paused)
@@ -653,6 +695,10 @@ void vlc_aout_stream_Flush(vlc_aout_stream *stream)
 {
     audio_output_t *aout = aout_stream_aout(stream);
 
+    struct vlc_tracer *tracer = aout_stream_tracer(stream);
+    if (tracer != NULL)
+        vlc_tracer_TraceEvent(tracer, "RENDER", stream->str_id, "flushed");
+
     stream_Reset(stream);
     if (stream->mixer_format.i_format)
         aout->flush(aout);
@@ -691,6 +737,11 @@ void vlc_aout_stream_Drain(vlc_aout_stream *stream)
     if (!stream->mixer_format.i_format)
         return;
 
+    struct vlc_tracer *tracer = aout_stream_tracer(stream);
+
+    if (tracer != NULL)
+        vlc_tracer_TraceEvent(tracer, "RENDER", stream->str_id, "drain");
+
     if (stream->filters)
     {
         block_t *block = aout_FiltersDrain (stream->filters);


=====================================
src/input/decoder.c
=====================================
@@ -383,10 +383,14 @@ static int ModuleThread_UpdateAudioFormat( decoder_t *p_dec )
         p_aout = input_resource_GetAout( p_owner->p_resource );
         if( p_aout )
         {
-            p_astream = vlc_aout_stream_New( p_aout, &format,
-                                             p_dec->fmt_out.i_profile,
-                                             p_owner->p_clock,
-                                             &p_dec->fmt_out.audio_replay_gain );
+            const struct vlc_aout_stream_cfg cfg = {
+                .fmt = &format,
+                .profile = p_dec->fmt_out.i_profile,
+                .clock = p_owner->p_clock,
+                .str_id = p_owner->psz_id,
+                .replay_gain = &p_dec->fmt_out.audio_replay_gain
+            };
+            p_astream = vlc_aout_stream_New( p_aout, &cfg );
             if( p_astream == NULL )
             {
                 input_resource_PutAout( p_owner->p_resource, p_aout );
@@ -485,7 +489,9 @@ static int ModuleThread_UpdateVideoFormat( decoder_t *p_dec, vlc_video_context *
     }
 
     vout_configuration_t cfg = {
-        .vout = p_owner->p_vout, .clock = p_owner->p_clock, .fmt = &p_dec->fmt_out.video,
+        .vout = p_owner->p_vout, .clock = p_owner->p_clock,
+        .str_id = p_owner->psz_id,
+        .fmt = &p_dec->fmt_out.video,
         .mouse_event = MouseEvent, .mouse_opaque = p_dec,
     };
     enum input_resource_vout_state vout_state;


=====================================
src/video_output/video_output.c
=====================================
@@ -48,6 +48,7 @@
 #include <vlc_image.h>
 #include <vlc_plugin.h>
 #include <vlc_codec.h>
+#include <vlc_tracer.h>
 #include <vlc_atomic.h>
 
 #include <libvlc.h>
@@ -73,6 +74,7 @@ typedef struct vout_thread_sys_t
     /* Splitter module if used */
     char            *splitter_name;
 
+    const char      *str_id;
     vlc_clock_t     *clock;
     float           rate;
     vlc_tick_t      delay;
@@ -186,6 +188,12 @@ typedef struct vout_thread_sys_t
 #define VOUT_MWAIT_TOLERANCE VLC_TICK_FROM_MS(4)
 
 /* */
+static inline struct vlc_tracer *GetTracer(vout_thread_sys_t *sys)
+{
+    return sys->str_id == NULL ? NULL :
+        vlc_object_get_tracer(VLC_OBJECT(&sys->obj));
+}
+
 static bool VoutCheckFormat(const video_format_t *src)
 {
     if (src->i_width == 0  || src->i_width  > 8192 ||
@@ -902,6 +910,10 @@ static bool IsPictureLate(vout_thread_sys_t *vout, picture_t *decoded,
     else
         late_threshold = VOUT_DISPLAY_LATE_THRESHOLD;
     if (late > late_threshold) {
+        struct vlc_tracer *tracer = GetTracer(vout);
+        if (tracer != NULL)
+            vlc_tracer_TraceEvent(tracer, "RENDER", sys->str_id, "toolate");
+
         msg_Warn(&vout->obj, "picture is too late to be displayed (missing %"PRId64" ms)", MS_FROM_VLC_TICK(late));
         return true;
     }
@@ -1276,6 +1288,9 @@ static int RenderPicture(vout_thread_sys_t *sys, bool render_now)
         const vlc_tick_t late = system_now - system_pts;
         if (unlikely(late > 0))
         {
+            struct vlc_tracer *tracer = GetTracer(sys);
+            if (tracer != NULL)
+                vlc_tracer_TraceEvent(tracer, "RENDER", sys->str_id, "late");
             msg_Dbg(vd, "picture displayed late (missing %"PRId64" ms)", MS_FROM_VLC_TICK(late));
             vout_statistic_AddLate(&sys->statistic, 1);
 
@@ -1478,6 +1493,11 @@ void vout_ChangePause(vout_thread_t *vout, bool is_paused, vlc_tick_t date)
     sys->pause.date  = date;
     vout_control_Release(&sys->control);
 
+    struct vlc_tracer *tracer = GetTracer(sys);
+    if (tracer != NULL)
+        vlc_tracer_TraceEvent(tracer, "RENDER", sys->str_id,
+                              is_paused ? "paused" : "resumed");
+
     vlc_mutex_lock(&sys->window_lock);
     vout_window_SetInhibition(sys->display_cfg.window, !is_paused);
     vlc_mutex_unlock(&sys->window_lock);
@@ -1528,6 +1548,10 @@ void vout_Flush(vout_thread_t *vout, vlc_tick_t date)
     vout_control_Hold(&sys->control);
     vout_FlushUnlocked(sys, false, date);
     vout_control_Release(&sys->control);
+
+    struct vlc_tracer *tracer = GetTracer(sys);
+    if (tracer != NULL)
+        vlc_tracer_TraceEvent(tracer, "RENDER", sys->str_id, "flushed");
 }
 
 void vout_NextPicture(vout_thread_t *vout, vlc_tick_t *duration)
@@ -1787,6 +1811,7 @@ static void vout_ReleaseDisplay(vout_thread_sys_t *vout)
     if (sys->spu)
         spu_Detach(sys->spu);
     sys->clock = NULL;
+    sys->str_id = NULL;
 }
 
 void vout_StopDisplay(vout_thread_t *vout)
@@ -2099,6 +2124,7 @@ int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input
 
     sys->delay = 0;
     sys->rate = 1.f;
+    sys->str_id = cfg->str_id;
     sys->clock = cfg->clock;
     sys->delay = 0;
 


=====================================
src/video_output/vout_internal.h
=====================================
@@ -43,6 +43,7 @@ typedef struct vlc_clock_t vlc_clock_t;
 typedef struct {
     vout_thread_t        *vout;
     vlc_clock_t          *clock;
+    const char           *str_id;
     const video_format_t *fmt;
     vlc_mouse_event      mouse_event;
     void                 *mouse_opaque;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f8326cf47c8f896790fd16b3e8d2448647df58ce...dc83b0a2b99f4c536d6a83e06cd1404102416959

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f8326cf47c8f896790fd16b3e8d2448647df58ce...dc83b0a2b99f4c536d6a83e06cd1404102416959
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list