Commit 87129938 authored by Laurent Aimar's avatar Laurent Aimar

Cosmetics (create a DecoderWaitDate function).

It also avoid useless mdate() when decoding audio.
parent 6088f39f
......@@ -1078,6 +1078,35 @@ static void DecoderFixTs( decoder_t *p_dec, mtime_t *pi_ts0, mtime_t *pi_ts1,
}
}
/**
* If *pb_reject, it does nothing, otherwise it waits for the given
* deadline or a flush request (in which case it set *pi_reject to true.
*/
static void DecoderWaitDate( decoder_t *p_dec,
bool *pb_reject, mtime_t i_deadline )
{
decoder_owner_sys_t *p_owner = p_dec->p_owner;
if( *pb_reject || i_deadline < 0 )
return;
for( ;; )
{
vlc_mutex_lock( &p_owner->lock );
if( p_owner->b_flushing || p_dec->b_die )
{
*pb_reject = true;
vlc_mutex_unlock( &p_owner->lock );
break;
}
int i_ret = vlc_cond_timedwait( &p_owner->wait_request, &p_owner->lock,
i_deadline );
vlc_mutex_unlock( &p_owner->lock );
if( i_ret )
break;
}
}
static void DecoderPlayAudio( decoder_t *p_dec, aout_buffer_t *p_audio,
int *pi_played_sum, int *pi_lost_sum )
{
......@@ -1153,20 +1182,8 @@ static void DecoderPlayAudio( decoder_t *p_dec, aout_buffer_t *p_audio,
i_rate > INPUT_RATE_DEFAULT*AOUT_MAX_INPUT_RATE )
b_reject = true;
/* Do not wait against unprotected date */
const mtime_t i_deadline = p_audio->start_date - AOUT_MAX_PREPARE_TIME;
while( !b_reject && i_deadline > mdate() )
{
vlc_mutex_lock( &p_owner->lock );
if( p_owner->b_flushing || p_dec->b_die )
{
b_reject = true;
vlc_mutex_unlock( &p_owner->lock );
break;
}
vlc_cond_timedwait( &p_owner->wait_request, &p_owner->lock, i_deadline );
vlc_mutex_unlock( &p_owner->lock );
}
DecoderWaitDate( p_dec, &b_reject,
p_audio->start_date - AOUT_MAX_PREPARE_TIME );
if( !b_reject )
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment