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

Steve Lhomme robux4 at ycbcr.xyz
Mon Sep 2 11:11:59 CEST 2019


On 2019-09-02 10:04, Thomas Guillem wrote:
> 
> 
> On Fri, Aug 30, 2019, at 08:27, Steve Lhomme wrote:
>> ---
>>   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 4170e942e2..86ef7efae6 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   ((vlc_tick_t) INT64_MIN)
>> +#define PREROLL_FORCED ((vlc_tick_t) INT64_MAX)
> 
> I think RĂ©mi said that the cast were useless. Why are you keeping them ?

The casts are useless for the compiler but I think it's more readable 
what the defines are and where they can be used.

>> +
>>       /* Pause & Rate */
>>       bool reset_out_state;
>>       vlc_tick_t pause_date;
>> @@ -773,11 +777,11 @@ static void DecoderWaitUnblock( 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( struct decoder_owner
>> *p_owner, picture_t *p_picture
>>       }
>>   
>>       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( struct decoder_owner
>> *p_owner, picture_t *p_picture
>>           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( struct decoder_owner
>> *p_owner, block_t *p_audio )
>>       }
>>   
>>       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( struct decoder_owner
>> *p_owner, block_t *p_audio )
>>           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( 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
>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
> 


More information about the vlc-devel mailing list