[vlc-devel] commit: Cosmetics (decoder) (Laurent Aimar )
git version control
git at videolan.org
Thu Oct 9 00:14:23 CEST 2008
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Tue Oct 7 19:27:28 2008 +0200| [7eb92928842ba98dedd7803b03a038ab799595eb] | committer: Laurent Aimar
Cosmetics (decoder)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7eb92928842ba98dedd7803b03a038ab799595eb
---
src/input/decoder.c | 80 ++++++++++++++++++++++++++------------------
src/input/es_out.c | 8 +++-
src/input/input_decoder.h | 9 ++++-
3 files changed, 60 insertions(+), 37 deletions(-)
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 5b54f74..c7d1ec8 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -53,8 +53,9 @@ static decoder_t *CreateDecoder( input_thread_t *, es_format_t *, int, sout_inst
static void DeleteDecoder( decoder_t * );
static void *DecoderThread( vlc_object_t * );
-static int DecoderProcess( decoder_t * p_dec, block_t *p_block );
-static void DecoderOutputChangePause( decoder_t *p_dec, bool b_paused, mtime_t i_date );
+static int DecoderProcess( decoder_t *, block_t * );
+static void DecoderOutputChangePause( decoder_t *, bool b_paused, mtime_t i_date );
+static void DecoderFlush( decoder_t * );
/* Buffers allocation callbacks for the decoders */
static aout_buffer_t *aout_new_buffer( decoder_t *, int );
@@ -489,43 +490,19 @@ void input_DecoderChangeDelay( decoder_t *p_dec, mtime_t i_delay )
vlc_mutex_unlock( &p_owner->lock );
}
-void input_DecoderFlush( decoder_t *p_dec )
+void input_DecoderStartBuffering( decoder_t *p_dec )
{
decoder_owner_sys_t *p_owner = p_dec->p_owner;
- block_t *p_null;
- if( p_owner->b_own_thread )
- {
- /* Empty the fifo */
- block_FifoEmpty( p_owner->p_fifo );
+ vlc_mutex_lock( &p_owner->lock );
- /* Monitor for flush end */
- vlc_mutex_lock( &p_owner->lock );
- p_owner->b_flushing = true;
- vlc_cond_signal( &p_owner->wait );
- vlc_mutex_unlock( &p_owner->lock );
- }
+ DecoderFlush( p_dec );
- /* Send a special block */
- p_null = block_New( p_dec, 128 );
- if( !p_null )
- return;
- p_null->i_flags |= BLOCK_FLAG_DISCONTINUITY;
- p_null->i_flags |= BLOCK_FLAG_CORE_FLUSH;
- if( !p_dec->fmt_in.b_packetized )
- p_null->i_flags |= BLOCK_FLAG_CORRUPTED;
- memset( p_null->p_buffer, 0, p_null->i_buffer );
-
- input_DecoderDecode( p_dec, p_null );
+ vlc_mutex_unlock( &p_owner->lock );
+}
- /* */
- if( p_owner->b_own_thread )
- {
- vlc_mutex_lock( &p_owner->lock );
- while( p_owner->b_flushing )
- vlc_cond_wait( &p_owner->wait, &p_owner->lock );
- vlc_mutex_unlock( &p_owner->lock );
- }
+void input_DecoderStopBuffering( decoder_t *p_dec )
+{
}
/**
@@ -715,6 +692,43 @@ static void *DecoderThread( vlc_object_t *p_this )
return NULL;
}
+static void DecoderFlush( decoder_t *p_dec )
+{
+ decoder_owner_sys_t *p_owner = p_dec->p_owner;
+ block_t *p_null;
+
+ if( p_owner->b_own_thread )
+ {
+ vlc_assert_locked( &p_owner->lock );
+
+ /* Empty the fifo */
+ block_FifoEmpty( p_owner->p_fifo );
+
+ /* Monitor for flush end */
+ p_owner->b_flushing = true;
+ vlc_cond_signal( &p_owner->wait );
+ }
+
+ /* Send a special block */
+ p_null = block_New( p_dec, 128 );
+ if( !p_null )
+ return;
+ p_null->i_flags |= BLOCK_FLAG_DISCONTINUITY;
+ p_null->i_flags |= BLOCK_FLAG_CORE_FLUSH;
+ if( !p_dec->fmt_in.b_packetized )
+ p_null->i_flags |= BLOCK_FLAG_CORRUPTED;
+ memset( p_null->p_buffer, 0, p_null->i_buffer );
+
+ input_DecoderDecode( p_dec, p_null );
+
+ /* */
+ if( p_owner->b_own_thread )
+ {
+ while( p_owner->b_flushing )
+ vlc_cond_wait( &p_owner->wait, &p_owner->lock );
+ }
+}
+
static void DecoderWaitUnpause( decoder_t *p_dec, bool *pb_reject )
{
decoder_owner_sys_t *p_owner = p_dec->p_owner;
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 7b6ceb7..6265d95 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -533,9 +533,13 @@ void input_EsOutChangePosition( es_out_t *out )
* there is a discontinuity */
if( es->p_dec )
{
- input_DecoderFlush( es->p_dec );
+ input_DecoderStartBuffering( es->p_dec );
+ input_DecoderStopBuffering( es->p_dec );
if( es->p_dec_record )
- input_DecoderFlush( es->p_dec_record );
+ {
+ input_DecoderStartBuffering( es->p_dec_record );
+ input_DecoderStopBuffering( es->p_dec_record );
+ }
}
}
diff --git a/src/input/input_decoder.h b/src/input/input_decoder.h
index d498b94..ea176d2 100644
--- a/src/input/input_decoder.h
+++ b/src/input/input_decoder.h
@@ -47,9 +47,14 @@ void input_DecoderChangePause( decoder_t *, bool b_paused, mtime_t i_date );
void input_DecoderChangeDelay( decoder_t *, mtime_t i_delay );
/**
- * This function will cause a flush of the decoder.
+ * This function starts the buffering mode.
*/
-void input_DecoderFlush( decoder_t * );
+void input_DecoderStartBuffering( decoder_t * );
+
+/**
+ * This function stops the buffering mode.
+ */
+void input_DecoderStopBuffering( decoder_t * );
/**
* This function returns true if the decoder fifo is empty and false otherwise.
More information about the vlc-devel
mailing list