[vlc-devel] commit: Implemented audio flushing. (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:02:52 2008 +0200| [20aa3c15801a8639070a87b5bbe3958e1d6654aa] | committer: Laurent Aimar 

Implemented audio flushing.

It is not perfect as the aout mixer buffers some data too but it is too
late...

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=20aa3c15801a8639070a87b5bbe3958e1d6654aa
---

 src/audio_output/aout_internal.h |    1 +
 src/audio_output/dec.c           |   10 ++++++++++
 src/input/decoder.c              |   23 +++++++++--------------
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h
index c887ab3..9ac4242 100644
--- a/src/audio_output/aout_internal.h
+++ b/src/audio_output/aout_internal.h
@@ -141,6 +141,7 @@ void aout_DecDeleteBuffer( aout_instance_t *, aout_input_t *, aout_buffer_t * );
 int aout_DecPlay( aout_instance_t *, aout_input_t *, aout_buffer_t *, int i_input_rate );
 int aout_DecGetResetLost( aout_instance_t *, aout_input_t * );
 void aout_DecChangePause( aout_instance_t *, aout_input_t *, bool b_paused, mtime_t i_date );
+void aout_DecFlush( aout_instance_t *, aout_input_t * );
 
 /* Helpers */
 
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 9d52bdc..d390d00 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -386,3 +386,13 @@ void aout_DecChangePause( aout_instance_t *p_aout, aout_input_t *p_input, bool b
     }
 }
 
+void aout_DecFlush( aout_instance_t *p_aout, aout_input_t *p_input )
+{
+    aout_lock_input_fifos( p_aout );
+
+    aout_FifoSet( p_aout, &p_input->fifo, 0 );
+    p_input->p_first_byte_to_mix = NULL;
+
+    aout_unlock_input_fifos( p_aout );
+}
+
diff --git a/src/input/decoder.c b/src/input/decoder.c
index a9b80ce..5b54f74 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -292,10 +292,8 @@ void input_DecoderDelete( decoder_t *p_dec )
         }
         vlc_mutex_unlock( &p_owner->lock );
 
-        /* Make sure the thread leaves the function by
-         * sending it an empty block. */
-        block_t *p_block = block_New( p_dec, 0 );
-        input_DecoderDecode( p_dec, p_block );
+        /* Make sure the thread leaves the function */
+        block_FifoWake( p_owner->p_fifo );
 
         vlc_thread_join( p_dec );
 
@@ -696,10 +694,7 @@ static void *DecoderThread( vlc_object_t *p_this )
     while( vlc_object_alive( p_dec ) && !p_dec->b_error )
     {
         if( ( p_block = block_FifoGet( p_owner->p_fifo ) ) == NULL )
-        {
-            p_dec->b_error = true;
-            break;
-        }
+            continue;
 
         if( DecoderProcess( p_dec, p_block ) != VLC_SUCCESS )
             break;
@@ -946,8 +941,10 @@ static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
 
         if( p_owner->i_preroll_end > 0 )
         {
-            /* FIXME TODO flush audio output (don't know how to do that) */
             msg_Dbg( p_dec, "End of audio preroll" );
+            if( p_owner->p_aout && p_owner->p_aout_input )
+                aout_DecFlush( p_owner->p_aout, p_owner->p_aout_input );
+            /* */
             p_owner->i_preroll_end = -1;
         }
 
@@ -1433,11 +1430,6 @@ static void DecoderProcessAudio( decoder_t *p_dec, block_t *p_block, bool b_flus
 {
     decoder_owner_sys_t *p_owner = (decoder_owner_sys_t *)p_dec->p_owner;
 
-    if( b_flush && p_owner->p_aout && p_owner->p_aout_input )
-    {
-        // TODO flush
-    }
-
     if( p_owner->p_packetizer )
     {
         block_t *p_packetized_block;
@@ -1467,6 +1459,9 @@ static void DecoderProcessAudio( decoder_t *p_dec, block_t *p_block, bool b_flus
     {
         DecoderDecodeAudio( p_dec, p_block );
     }
+
+    if( b_flush && p_owner->p_aout && p_owner->p_aout_input )
+        aout_DecFlush( p_owner->p_aout, p_owner->p_aout_input );
 }
 
 /* This function process a subtitle block




More information about the vlc-devel mailing list