Commit 7a574861 authored by Rafaël Carré's avatar Rafaël Carré
Browse files

decoder: process the last block when closing

There might be a buffer still stored in packetizer buffers
refs: #3178
parent 8c01ae6d
......@@ -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
......
......@@ -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;
......
......@@ -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 );
}
......@@ -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 );
......
......@@ -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* */
......
......@@ -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 )
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment