[vlc-devel] [PATCH 12/13] decoder: use defines for the unset/forced preroll values

Steve Lhomme robux4 at ycbcr.xyz
Mon Sep 2 16:20:19 CEST 2019


---
 src/input/decoder.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 45cc4e3024..88a17d25d2 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -109,6 +109,10 @@ struct decoder_owner
     /* -- Theses variables need locking on read *and* write -- */
     /* Preroll */
     vlc_tick_t i_preroll_end;
+
+#define PREROLL_NONE    INT64_MIN // vlc_tick_t
+#define PREROLL_FORCED  INT64_MAX // vlc_tick_t
+
     /* Pause & Rate */
     bool reset_out_state;
     vlc_tick_t pause_date;
@@ -773,11 +777,11 @@ static void DecoderWaitUnblock_internal( struct decoder_owner *p_owner )
 static inline void DecoderUpdatePreroll( vlc_tick_t *pi_preroll, const block_t *p )
 {
     if( p->i_flags & BLOCK_FLAG_PREROLL )
-        *pi_preroll = (vlc_tick_t)INT64_MAX;
+        *pi_preroll = PREROLL_FORCED;
     /* Check if we can use the packet for end of preroll */
     else if( (p->i_flags & BLOCK_FLAG_DISCONTINUITY) &&
              (p->i_buffer == 0 || (p->i_flags & BLOCK_FLAG_CORRUPTED)) )
-        *pi_preroll = (vlc_tick_t)INT64_MAX;
+        *pi_preroll = PREROLL_FORCED;
     else if( p->i_dts != VLC_TICK_INVALID )
         *pi_preroll = __MIN( *pi_preroll, p->i_dts );
     else if( p->i_pts != VLC_TICK_INVALID )
@@ -986,7 +990,7 @@ static int DecoderPlayVideo_internal( struct decoder_owner *p_owner, picture_t *
     }
 
     vlc_mutex_lock( &p_owner->lock );
-    bool prerolled = p_owner->i_preroll_end != (vlc_tick_t)INT64_MIN;
+    bool prerolled = p_owner->i_preroll_end != PREROLL_NONE;
     if( prerolled && p_owner->i_preroll_end > p_picture->date )
     {
         vlc_mutex_unlock( &p_owner->lock );
@@ -994,7 +998,7 @@ static int DecoderPlayVideo_internal( struct decoder_owner *p_owner, picture_t *
         return VLC_SUCCESS;
     }
 
-    p_owner->i_preroll_end = (vlc_tick_t)INT64_MIN;
+    p_owner->i_preroll_end = PREROLL_NONE;
 
     if( unlikely(prerolled) )
     {
@@ -1116,7 +1120,7 @@ static int DecoderPlayAudio_internal( struct decoder_owner *p_owner, block_t *p_
     }
 
     vlc_mutex_lock( &p_owner->lock );
-    bool prerolled = p_owner->i_preroll_end != (vlc_tick_t)INT64_MIN;
+    bool prerolled = p_owner->i_preroll_end != PREROLL_NONE;
     if( prerolled && p_owner->i_preroll_end > p_audio->i_pts )
     {
         vlc_mutex_unlock( &p_owner->lock );
@@ -1124,7 +1128,7 @@ static int DecoderPlayAudio_internal( struct decoder_owner *p_owner, block_t *p_
         return VLC_SUCCESS;
     }
 
-    p_owner->i_preroll_end = (vlc_tick_t)INT64_MIN;
+    p_owner->i_preroll_end = PREROLL_NONE;
 
     if( unlikely(prerolled) )
     {
@@ -1446,7 +1450,7 @@ static void DecoderProcessFlush_internal( struct decoder_owner *p_owner )
         }
     }
 
-    p_owner->i_preroll_end = (vlc_tick_t)INT64_MIN;
+    p_owner->i_preroll_end = PREROLL_NONE;
     vlc_mutex_unlock( &p_owner->lock );
 }
 
@@ -1744,7 +1748,7 @@ static struct decoder_owner * CreateDecoder( vlc_object_t *p_parent,
     p_dec = &p_owner->dec;
 
     p_owner->p_clock = p_clock;
-    p_owner->i_preroll_end = (vlc_tick_t)INT64_MIN;
+    p_owner->i_preroll_end = PREROLL_NONE;
     p_owner->p_resource = p_resource;
     p_owner->cbs = cbs;
     p_owner->cbs_userdata = cbs_userdata;
-- 
2.17.1



More information about the vlc-devel mailing list