[vlc-devel] commit: Cosmetics (create a DecoderWaitDate function). (Laurent Aimar )
git version control
git at videolan.org
Mon Jul 27 22:36:37 CEST 2009
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Mon Jul 27 22:00:46 2009 +0200| [87129938979a8516bc564787ec3b01b98fa7991b] | committer: Laurent Aimar
Cosmetics (create a DecoderWaitDate function).
It also avoid useless mdate() when decoding audio.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=87129938979a8516bc564787ec3b01b98fa7991b
---
src/input/decoder.c | 45 +++++++++++++++++++++++++++++++--------------
1 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 34f8831..7069388 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -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 )
{
More information about the vlc-devel
mailing list