[vlc-devel] commit: Cosmetics (create a DecoderWaitDate function). (Laurent Aimar )
git version control
git at videolan.org
Wed Jul 29 22:48:00 CEST 2009
vlc | branch: 1.0-bugfix | Laurent Aimar <fenrir at videolan.org> | Mon Jul 27 22:00:46 2009 +0200| [a75df43c8b747cef654631bb212abb1dffea01da] | committer: Laurent Aimar
Cosmetics (create a DecoderWaitDate function).
It also avoid useless mdate() when decoding audio.
(cherry picked from commit 87129938979a8516bc564787ec3b01b98fa7991b)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a75df43c8b747cef654631bb212abb1dffea01da
---
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 514ef73..e36f759 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1084,6 +1084,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 )
{
@@ -1159,20 +1188,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