[vlc-devel] commit: Correctly flush video/audio decoder in all cases. (Laurent Aimar )

git version control git at videolan.org
Mon Feb 9 21:09:08 CET 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sun Feb  8 16:39:49 2009 +0100| [9e6e2eeb638d4bc7cac3178ac838f53e716f35f2] | committer: Laurent Aimar 

Correctly flush video/audio decoder in all cases.

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

 src/input/decoder.c |   39 +++++++++++++++++++++++++++++++--------
 1 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 76dba45..9c2e271 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -888,10 +888,23 @@ static void *DecoderThread( vlc_object_t *p_this )
     return NULL;
 }
 
+static block_t *DecoderBlockFlushNew()
+{
+    block_t *p_null = block_Alloc( 128 );
+    if( !p_null )
+        return NULL;
+
+    p_null->i_flags |= BLOCK_FLAG_DISCONTINUITY |
+                       BLOCK_FLAG_CORRUPTED |
+                       BLOCK_FLAG_CORE_FLUSH;
+    memset( p_null->p_buffer, 0, p_null->i_buffer );
+
+    return p_null;
+}
+
 static void DecoderFlush( decoder_t *p_dec )
 {
     decoder_owner_sys_t *p_owner = p_dec->p_owner;
-    block_t *p_null;
 
     vlc_assert_locked( &p_owner->lock );
 
@@ -903,15 +916,9 @@ static void DecoderFlush( decoder_t *p_dec )
     vlc_cond_signal( &p_owner->wait );
 
     /* Send a special block */
-    p_null = block_New( p_dec, 128 );
+    block_t *p_null = DecoderBlockFlushNew();
     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 );
 
     /* */
@@ -1796,6 +1803,14 @@ static void DecoderProcessVideo( decoder_t *p_dec, block_t *p_block, bool b_flus
                 p_packetized_block = p_next;
             }
         }
+        /* The packetizer does not output a block that tell the decoder to flush
+         * do it ourself */
+        if( b_flush )
+        {
+            block_t *p_null = DecoderBlockFlushNew();
+            if( p_null )
+                DecoderDecodeVideo( p_dec, p_null );
+        }
     }
     else if( p_block )
     {
@@ -1836,6 +1851,14 @@ static void DecoderProcessAudio( decoder_t *p_dec, block_t *p_block, bool b_flus
                 p_packetized_block = p_next;
             }
         }
+        /* The packetizer does not output a block that tell the decoder to flush
+         * do it ourself */
+        if( b_flush )
+        {
+            block_t *p_null = DecoderBlockFlushNew();
+            if( p_null )
+                DecoderDecodeAudio( p_dec, p_null );
+        }
     }
     else if( p_block )
     {




More information about the vlc-devel mailing list