]> git.sesse.net Git - vlc/commitdiff
decoder: process the last block when closing
authorRafaël Carré <funman@videolan.org>
Thu, 8 Sep 2011 10:25:09 +0000 (12:25 +0200)
committerRafaël Carré <funman@videolan.org>
Thu, 8 Sep 2011 17:18:44 +0000 (19:18 +0200)
There might be a buffer still stored in packetizer buffers
refs: #3178

src/input/decoder.c
src/input/decoder.h
src/input/es_out.c
src/input/es_out.h
src/input/es_out_timeshift.c
src/input/input.c

index 4d98e89a599ff17e3387062d7e2dc2151cb90920..efee19449af1831b6ac9c7271509088a5c8316fa 100644 (file)
@@ -924,6 +924,14 @@ static void *DecoderThread( void *p_data )
         {
             int canc = vlc_savecancel();
 
+            if( p_block->i_flags & BLOCK_FLAG_CORE_EOS )
+            {
+                /* calling DecoderProcess() with NULL block will make
+                 * decoders/packetizers flush their buffers */
+                block_Release( p_block );
+                p_block = NULL;
+            }
+
             if( p_dec->b_error )
                 DecoderError( p_dec, p_block );
             else
index 6f2dcb26c38541e3559b2d467134994bd6e675f0..abb9f6679ff7224c3c6d09b7f759860cd53b8a51 100644 (file)
@@ -29,6 +29,7 @@
 #include <vlc_codec.h>
 
 #define BLOCK_FLAG_CORE_FLUSH (1 <<BLOCK_FLAG_CORE_PRIVATE_SHIFT)
+#define BLOCK_FLAG_CORE_EOS   (1 <<(BLOCK_FLAG_CORE_PRIVATE_SHIFT + 1))
 
 decoder_t *input_DecoderNew( input_thread_t *, es_format_t *, input_clock_t *,
                              sout_instance_t * ) VLC_USED;
index 8cb7a3b85bfb8f85a0c56a0d9dcf899f0c4da1d6..dd29f63978615970dbf2862a841248931cee3715 100644 (file)
@@ -2687,6 +2687,22 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
             input_clock_ChangeSystemOrigin( p_pgrm->p_clock, b_absolute, i_system );
             return VLC_SUCCESS;
         }
+        case ES_OUT_SET_EOS:
+        {
+            for (int i = 0; i < p_sys->i_es; i++) {
+                es_out_id_t *id = p_sys->es[i];
+                decoder_t *p_dec = id->p_dec;
+                if (!p_dec)
+                    continue;
+                block_t *p_block = block_Alloc(0);
+                if( !p_block )
+                    break;
+
+                p_block->i_flags |= BLOCK_FLAG_CORE_EOS;
+                input_DecoderDecode(p_dec, p_block, false);
+            }
+            return VLC_SUCCESS;
+        }
 
         default:
             msg_Err( p_sys->p_input, "unknown query in es_out_Control" );
@@ -3026,4 +3042,3 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *
     /* */
     input_Control( p_input, INPUT_REPLACE_INFOS, p_cat );
 }
-
index ddb3c5af44b5ef932fe8b7fb64fe006f1d81f052..f42dbf573a1c380eecb90a1029f1893e0cd49212 100644 (file)
@@ -79,6 +79,9 @@ enum es_out_query_private_e
 
     /* Get forced group */
     ES_OUT_GET_GROUP_FORCED,                        /* arg1=int * res=cannot fail */
+
+    /* Set End Of Stream */
+    ES_OUT_SET_EOS,                                 /* res=cannot fail */
 };
 
 static inline void es_out_SetMode( es_out_t *p_out, int i_mode )
@@ -159,6 +162,11 @@ static inline int es_out_GetGroupForced( es_out_t *p_out )
     assert( !i_ret );
     return i_group;
 }
+static inline void es_out_Eos( es_out_t *p_out )
+{
+    int i_ret = es_out_Control( p_out, ES_OUT_SET_EOS );
+    assert( !i_ret );
+}
 
 es_out_t  *input_EsOutNew( input_thread_t *, int i_rate );
 
index 68947db35d0bafc65c43242d2dfc4c7705b31d98..fc45bd92d529cab5a672c56f14b772edc0b85864 100644 (file)
@@ -606,6 +606,7 @@ static int ControlLocked( es_out_t *p_out, int i_query, va_list args )
     case ES_OUT_SET_ES_FMT:
     case ES_OUT_SET_TIMES:
     case ES_OUT_SET_JITTER:
+    case ES_OUT_SET_EOS:
     {
         ts_cmd_t cmd;
         if( CmdInitControl( &cmd, i_query, args, p_sys->b_delayed ) )
@@ -1327,6 +1328,7 @@ static int CmdInitControl( ts_cmd_t *p_cmd, int i_query, va_list args, bool b_co
         break;
 
     case ES_OUT_RESET_PCR:           /* no arg */
+    case ES_OUT_SET_EOS:
         break;
 
     case ES_OUT_SET_META:        /* arg1=const vlc_meta_t* */
@@ -1462,6 +1464,7 @@ static int CmdExecuteControl( es_out_t *p_out, ts_cmd_t *p_cmd )
                                                p_cmd->u.control.u.int_i64.i_i64 );
 
     case ES_OUT_RESET_PCR:           /* no arg */
+    case ES_OUT_SET_EOS:
         return es_out_Control( p_out, i_query );
 
     case ES_OUT_SET_GROUP_META:  /* arg1=int i_group arg2=const vlc_meta_t* */
index 5839e37f12850cf687d26ede7954cd9047a93a2a..07bb47cf5929cdee0bc940548e6b463e41ea7c7f 100644 (file)
@@ -617,6 +617,7 @@ static void MainLoopDemux( input_thread_t *p_input, bool *pb_changed, bool *pb_d
     {
         msg_Dbg( p_input, "EOF reached" );
         p_input->p->input.b_eof = true;
+        es_out_Eos(p_input->p->p_es_out);
     }
     else if( i_ret < 0 )
     {