Commit 4feb30d6 authored by Gildas Bazin's avatar Gildas Bazin

* src/input/decoder.c: don't let the decoder/packetizer fifo grow too much...

* src/input/decoder.c: don't let the decoder/packetizer fifo grow too much because this leads to a steady increase in memory useage when the data isn't consumed quickly enough. (not the best fix, but should be better than nothing)
parent ada036d0
...@@ -243,6 +243,7 @@ struct block_fifo_t ...@@ -243,6 +243,7 @@ struct block_fifo_t
int i_depth; int i_depth;
block_t *p_first; block_t *p_first;
block_t **pp_last; block_t **pp_last;
int i_size;
}; };
......
...@@ -207,8 +207,6 @@ void input_DecoderDecode( decoder_t * p_dec, block_t *p_block ) ...@@ -207,8 +207,6 @@ void input_DecoderDecode( decoder_t * p_dec, block_t *p_block )
{ {
if( p_dec->p_owner->b_own_thread ) if( p_dec->p_owner->b_own_thread )
{ {
block_FifoPut( p_dec->p_owner->p_fifo, p_block );
if( p_dec->p_owner->p_input->b_out_pace_control ) if( p_dec->p_owner->p_input->b_out_pace_control )
{ {
/* FIXME !!!!! */ /* FIXME !!!!! */
...@@ -218,6 +216,16 @@ void input_DecoderDecode( decoder_t * p_dec, block_t *p_block ) ...@@ -218,6 +216,16 @@ void input_DecoderDecode( decoder_t * p_dec, block_t *p_block )
msleep( 1000 ); msleep( 1000 );
} }
} }
else if( p_dec->p_owner->p_fifo->i_size > 50000000 /* 50 MB */ )
{
/* FIXME: ideally we would check the time amount of data
* in the fifo instead of its size. */
msg_Warn( p_dec, "decoder/packetizer fifo full (data not "
"consummed quickly enough), resetting fifo!" );
block_FifoEmpty( p_dec->p_owner->p_fifo );
}
block_FifoPut( p_dec->p_owner->p_fifo, p_block );
} }
else else
{ {
......
...@@ -147,7 +147,7 @@ block_fifo_t *__block_FifoNew( vlc_object_t *p_obj ) ...@@ -147,7 +147,7 @@ block_fifo_t *__block_FifoNew( vlc_object_t *p_obj )
p_fifo = malloc( sizeof( vlc_object_t ) ); p_fifo = malloc( sizeof( vlc_object_t ) );
vlc_mutex_init( p_obj, &p_fifo->lock ); vlc_mutex_init( p_obj, &p_fifo->lock );
vlc_cond_init( p_obj, &p_fifo->wait ); vlc_cond_init( p_obj, &p_fifo->wait );
p_fifo->i_depth = 0; p_fifo->i_depth = p_fifo->i_size = 0;
p_fifo->p_first = NULL; p_fifo->p_first = NULL;
p_fifo->pp_last = &p_fifo->p_first; p_fifo->pp_last = &p_fifo->p_first;
...@@ -176,7 +176,7 @@ void block_FifoEmpty( block_fifo_t *p_fifo ) ...@@ -176,7 +176,7 @@ void block_FifoEmpty( block_fifo_t *p_fifo )
b = p_next; b = p_next;
} }
p_fifo->i_depth = 0; p_fifo->i_depth = p_fifo->i_size = 0;
p_fifo->p_first = NULL; p_fifo->p_first = NULL;
p_fifo->pp_last = &p_fifo->p_first; p_fifo->pp_last = &p_fifo->p_first;
vlc_mutex_unlock( &p_fifo->lock ); vlc_mutex_unlock( &p_fifo->lock );
...@@ -194,6 +194,7 @@ int block_FifoPut( block_fifo_t *p_fifo, block_t *p_block ) ...@@ -194,6 +194,7 @@ int block_FifoPut( block_fifo_t *p_fifo, block_t *p_block )
*p_fifo->pp_last = p_block; *p_fifo->pp_last = p_block;
p_fifo->pp_last = &p_block->p_next; p_fifo->pp_last = &p_block->p_next;
p_fifo->i_depth++; p_fifo->i_depth++;
p_fifo->i_size += p_block->i_buffer;
p_block = p_block->p_next; p_block = p_block->p_next;
...@@ -224,6 +225,7 @@ block_t *block_FifoGet( block_fifo_t *p_fifo ) ...@@ -224,6 +225,7 @@ block_t *block_FifoGet( block_fifo_t *p_fifo )
p_fifo->p_first = b->p_next; p_fifo->p_first = b->p_next;
p_fifo->i_depth--; p_fifo->i_depth--;
p_fifo->i_size -= b->i_buffer;
if( p_fifo->p_first == NULL ) if( p_fifo->p_first == NULL )
{ {
...@@ -233,7 +235,7 @@ block_t *block_FifoGet( block_fifo_t *p_fifo ) ...@@ -233,7 +235,7 @@ block_t *block_FifoGet( block_fifo_t *p_fifo )
vlc_mutex_unlock( &p_fifo->lock ); vlc_mutex_unlock( &p_fifo->lock );
b->p_next = NULL; b->p_next = NULL;
return( b ); return b;
} }
block_t *block_FifoShow( block_fifo_t *p_fifo ) block_t *block_FifoShow( block_fifo_t *p_fifo )
......
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