Commit e27889c5 authored by Laurent Aimar's avatar Laurent Aimar

Fixed decoder picture leak detection code.

It workarounds a picture leak in libmpeg2/ffmpeg decoder, fixing the menu for
a few DVDs.
parent 575f49e5
...@@ -1324,7 +1324,7 @@ static picture_t *vout_new_buffer( decoder_t *p_dec ) ...@@ -1324,7 +1324,7 @@ static picture_t *vout_new_buffer( decoder_t *p_dec )
*/ */
for( p_pic = NULL; ; ) for( p_pic = NULL; ; )
{ {
int i_pic, i_ready_pic = 0; int i_pic, i_ready_pic;
if( p_dec->b_die || p_dec->b_error ) if( p_dec->b_die || p_dec->b_error )
return NULL; return NULL;
...@@ -1343,24 +1343,31 @@ static picture_t *vout_new_buffer( decoder_t *p_dec ) ...@@ -1343,24 +1343,31 @@ static picture_t *vout_new_buffer( decoder_t *p_dec )
#define p_pic p_dec->p_owner->p_vout->render.pp_picture[i_pic] #define p_pic p_dec->p_owner->p_vout->render.pp_picture[i_pic]
/* Check the decoder doesn't leak pictures */ /* Check the decoder doesn't leak pictures */
for( i_pic = 0; i_pic < p_dec->p_owner->p_vout->render.i_pictures; for( i_pic = 0, i_ready_pic = 0; i_pic < p_dec->p_owner->p_vout->render.i_pictures; i_pic++ )
i_pic++ )
{ {
if( p_pic->i_status == READY_PICTURE ) if( p_pic->i_status == READY_PICTURE )
{ {
if( i_ready_pic++ > 0 ) break; i_ready_pic++;
else continue; /* If we have at least 2 ready pictures, wait for the vout thread to
} * process one */
if( i_ready_pic >= 2 )
break;
if( p_pic->i_status != DISPLAYED_PICTURE && continue;
p_pic->i_status != RESERVED_PICTURE && }
p_pic->i_status != READY_PICTURE ) break;
if( !p_pic->i_refcount && p_pic->i_status != RESERVED_PICTURE ) if( p_pic->i_status == DISPLAYED_PICTURE )
{
/* If at least one displayed picture is not referenced
* let vout free it */
if( p_pic->i_refcount == 0 )
break; break;
} }
}
if( i_pic == p_dec->p_owner->p_vout->render.i_pictures ) if( i_pic == p_dec->p_owner->p_vout->render.i_pictures )
{ {
/* Too many pictures are still referenced, there is probably a bug
* with the decoder */
msg_Err( p_dec, "decoder is leaking pictures, resetting the heap" ); msg_Err( p_dec, "decoder is leaking pictures, resetting the heap" );
/* Just free all the pictures */ /* Just free all the pictures */
......
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