<html><head></head><body>Could nul the logger pointer and be done with it (might need to create an intermediate VLC object).<br><br><div class="gmail_quote">Le 21 décembre 2019 05:37:37 GMT+02:00, Marvin Scholz <epirat07@gmail.com> 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">The synchro module should not print messages when the quiet-synchro<br>option is set. To simplify this, add two new helper macros for<br>debug and warning messages (which currently are the only message<br>types used in this code) and use those instead of always explicitly<br>checking the b_quiet variable.<hr> modules/codec/synchro.c | 98 ++++++++++++++++++++++++-----------------<br> 1 file changed, 58 insertions(+), 40 deletions(-)<br><br>diff --git a/modules/codec/synchro.c b/modules/codec/synchro.c<br>index 3d638cf9ed..0a7f6c1014 100644<br>--- a/modules/codec/synchro.c<br>+++ b/modules/codec/synchro.c<br>@@ -101,6 +101,28 @@<br> #include <vlc_codec.h><br> #include "synchro.h"<br> <br>+/*<br>+ * Logging helpers<br>+ */<br>+<br>+/**<br>+ * Print a debug log message if not silenced<br>+ * using the `quiet-synchro` option<br>+ */<br>+#define synchro_msg_Dbg(p_this, ...) do { \<br>+        if( !p_this->b_quiet ) \<br>+            msg_Generic(p_this->p_dec, VLC_MSG_DBG, __VA_ARGS__); \<br>+    } while (0)<br>+<br>+/**<br>+ * Print a warning log message if not silenced<br>+ * using the `quiet-synchro` option<br>+ */<br>+#define synchro_msg_Warn(p_this, ...) do { \<br>+        if( !p_this->b_quiet ) \<br>+            msg_Generic(p_this->p_dec, VLC_MSG_WARN, __VA_ARGS__); \<br>+    } while (0)<br>+<br> /*<br>  * Local prototypes<br>  */<br>@@ -259,10 +281,10 @@ bool decoder_SynchroChoose( decoder_synchro_t * p_synchro, int i_coding_type,<br>         if( pts == VLC_TICK_INVALID )<br>             b_decode = 1;<br> <br>-        if( !b_decode && !p_synchro->b_quiet )<br>+        if( !b_decode )<br>         {<br>-            msg_Warn( p_synchro->p_dec,<br>-                      "synchro trashing I (%"PRId64")", pts - now );<br>+            synchro_msg_Warn( p_synchro,<br>+                "synchro trashing I (%"PRId64")", pts - now );<br>         }<br>         break;<br> <br>@@ -415,10 +437,9 @@ void decoder_SynchroNewPicture( decoder_synchro_t * p_synchro, int i_coding_type<br>         if( p_synchro->i_eta_p && p_synchro->i_eta_p != p_synchro->i_n_p )<br>         {<br> #if 0<br>-            if( !p_synchro->b_quiet )<br>-                msg_Dbg( p_synchro->p_dec,<br>-                         "stream periodicity changed from P[%d] to P[%d]",<br>-                         p_synchro->i_n_p, p_synchro->i_eta_p );<br>+            synchro_msg_Dbg( p_synchro,<br>+                     "stream periodicity changed from P[%d] to P[%d]",<br>+                     p_synchro->i_n_p, p_synchro->i_eta_p );<br> #endif<br>             p_synchro->i_n_p = p_synchro->i_eta_p;<br>         }<br>@@ -430,26 +451,25 @@ void decoder_SynchroNewPicture( decoder_synchro_t * p_synchro, int i_coding_type<br>             p_synchro->i_dec_nb_ref = p_synchro->i_nb_ref;<br> <br> #if 0<br>-        if( !p_synchro->b_quiet )<br>-            msg_Dbg( p_synchro->p_dec, "I(%"PRId64") P(%"PRId64")[%d] B(%"PRId64")"<br>-                  "[%d] YUV(%"PRId64") : trashed %d:%d/%d",<br>-                  p_synchro->p_tau[I_CODING_TYPE],<br>-                  p_synchro->p_tau[P_CODING_TYPE],<br>-                  p_synchro->i_n_p,<br>-                  p_synchro->p_tau[B_CODING_TYPE],<br>-                  p_synchro->i_n_b,<br>-                  p_synchro->i_render_time,<br>-                  p_synchro->i_not_chosen_pic,<br>-                  p_synchro->i_trashed_pic -<br>-                  p_synchro->i_not_chosen_pic,<br>-                  p_synchro->i_pic );<br>+        synchro_msg_Dbg( p_synchro, "I(%"PRId64") P(%"PRId64")[%d] B(%"PRId64")"<br>+              "[%d] YUV(%"PRId64") : trashed %d:%d/%d",<br>+              p_synchro->p_tau[I_CODING_TYPE],<br>+              p_synchro->p_tau[P_CODING_TYPE],<br>+              p_synchro->i_n_p,<br>+              p_synchro->p_tau[B_CODING_TYPE],<br>+              p_synchro->i_n_b,<br>+              p_synchro->i_render_time,<br>+              p_synchro->i_not_chosen_pic,<br>+              p_synchro->i_trashed_pic -<br>+              p_synchro->i_not_chosen_pic,<br>+              p_synchro->i_pic );<br>         p_synchro->i_trashed_pic = p_synchro->i_not_chosen_pic<br>             = p_synchro->i_pic = 0;<br> #else<br>         if( p_synchro->i_pic >= 100 )<br>         {<br>-            if( !p_synchro->b_quiet && p_synchro->i_trashed_pic != 0 )<br>-                msg_Dbg( p_synchro->p_dec, "decoded %d/%d pictures",<br>+            if( p_synchro->i_trashed_pic != 0 )<br>+                synchro_msg_Dbg( p_synchro, "decoded %d/%d pictures",<br>                          p_synchro->i_pic<br>                            - p_synchro->i_trashed_pic,<br>                          p_synchro->i_pic );<br>@@ -465,10 +485,9 @@ void decoder_SynchroNewPicture( decoder_synchro_t * p_synchro, int i_coding_type<br>              && p_synchro->i_eta_b != p_synchro->i_n_b )<br>         {<br> #if 0<br>-            if( !p_synchro->b_quiet )<br>-                msg_Dbg( p_synchro->p_dec,<br>-                         "stream periodicity changed from B[%d] to B[%d]",<br>-                         p_synchro->i_n_b, p_synchro->i_eta_b );<br>+            synchro_msg_Dbg( p_synchro,<br>+                     "stream periodicity changed from B[%d] to B[%d]",<br>+                     p_synchro->i_n_b, p_synchro->i_eta_b );<br> #endif<br>             p_synchro->i_n_b = p_synchro->i_eta_b;<br>         }<br>@@ -497,12 +516,12 @@ void decoder_SynchroNewPicture( decoder_synchro_t * p_synchro, int i_coding_type<br> <br>         if( next_pts != VLC_TICK_INVALID )<br>         {<br>-            if( (next_pts - p_synchro->current_pts<br>+            if( next_pts - p_synchro->current_pts<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">PTS_THRESHOLD<br></blockquote>                   || p_synchro->current_pts - next_pts<br>-                    > PTS_THRESHOLD) && !p_synchro->b_quiet )<br>+                    > PTS_THRESHOLD )<br>             {<br>-                msg_Warn( p_synchro->p_dec, "decoder synchro warning: pts != "<br>+                synchro_msg_Warn( p_synchro, "decoder synchro warning: pts != "<br>                           "current_date (%"PRId64")",<br>                           p_synchro->current_pts<br>                               - next_pts );<br>@@ -521,18 +540,18 @@ void decoder_SynchroNewPicture( decoder_synchro_t * p_synchro, int i_coding_type<br>                 (next_dts - p_synchro->backward_pts<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">PTS_THRESHOLD<br></blockquote>                   || p_synchro->backward_pts - next_dts<br>-                    > PTS_THRESHOLD) && !p_synchro->b_quiet )<br>+                    > PTS_THRESHOLD) )<br>             {<br>-                msg_Warn( p_synchro->p_dec, "backward_pts != dts (%"PRId64")",<br>+                synchro_msg_Warn( p_synchro, "backward_pts != dts (%"PRId64")",<br>                            next_dts<br>                                - p_synchro->backward_pts );<br>             }<br>-            if( (p_synchro->backward_pts - p_synchro->current_pts<br>+            if( p_synchro->backward_pts - p_synchro->current_pts<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">PTS_THRESHOLD<br></blockquote>                   || p_synchro->current_pts - p_synchro->backward_pts<br>-                    > PTS_THRESHOLD) && !p_synchro->b_quiet )<br>+                    > PTS_THRESHOLD )<br>             {<br>-                msg_Warn( p_synchro->p_dec,<br>+                synchro_msg_Warn( p_synchro,<br>                           "backward_pts != current_pts (%"PRId64")",<br>                           p_synchro->current_pts<br>                               - p_synchro->backward_pts );<br>@@ -542,12 +561,12 @@ void decoder_SynchroNewPicture( decoder_synchro_t * p_synchro, int i_coding_type<br>         }<br>         else if( next_dts != VLC_TICK_INVALID )<br>         {<br>-            if( (next_dts - p_synchro->current_pts<br>+            if( next_dts - p_synchro->current_pts<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">PTS_THRESHOLD<br></blockquote>                   || p_synchro->current_pts - next_dts<br>-                    > PTS_THRESHOLD) && !p_synchro->b_quiet )<br>+                    > PTS_THRESHOLD )<br>             {<br>-                msg_Warn( p_synchro->p_dec, "dts != current_pts (%"PRId64")",<br>+                synchro_msg_Warn( p_synchro, "dts != current_pts (%"PRId64")",<br>                           p_synchro->current_pts<br>                               - next_dts );<br>             }<br>@@ -569,9 +588,8 @@ void decoder_SynchroNewPicture( decoder_synchro_t * p_synchro, int i_coding_type<br>     {<br>         /* We cannot be _that_ late, something must have happened, reinit<br>          * the dates. */<br>-        if( !p_synchro->b_quiet )<br>-            msg_Warn( p_synchro->p_dec, "PTS << now (%"PRId64"), resetting",<br>-                      now - p_synchro->current_pts - DEFAULT_PTS_DELAY );<br>+        synchro_msg_Warn( p_synchro, "PTS << now (%"PRId64"), resetting",<br>+                  now - p_synchro->current_pts - DEFAULT_PTS_DELAY );<br>         p_synchro->current_pts = now + DEFAULT_PTS_DELAY;<br>     }<br>     if( p_synchro->backward_pts != VLC_TICK_INVALID</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>