Commit 1bfc4975 authored by Christophe Massiot's avatar Christophe Massiot

* modules/video_output/picture.c: Changed the order of the commands to avoid

  holding p_picture_vout->lock for too long.
parent 15060644
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* picture.c: * picture.c:
***************************************************************************** *****************************************************************************
* Copyright (C) 2004-2005 VideoLAN * Copyright (C) 2004-2005 VideoLAN
* $Id: $ * $Id: picture.c 10081 2005-03-01 15:33:51Z dionoea $
* *
* Authors: Antoine Cellerier <dionoea@videolan.org> * Authors: Antoine Cellerier <dionoea@videolan.org>
* *
...@@ -85,7 +85,8 @@ static int Open ( vlc_object_t *p_this ) ...@@ -85,7 +85,8 @@ static int Open ( vlc_object_t *p_this )
return VLC_ENOMEM; return VLC_ENOMEM;
} }
if( var_Get( p_libvlc, "p_picture_vout", &val ) != VLC_SUCCESS ){ if( var_Get( p_libvlc, "p_picture_vout", &val ) != VLC_SUCCESS )
{
msg_Dbg( p_vout, "p_picture_vout not found" ); msg_Dbg( p_vout, "p_picture_vout not found" );
p_picture_vout = malloc( sizeof( struct picture_vout_t ) ); p_picture_vout = malloc( sizeof( struct picture_vout_t ) );
if( p_vout->p_sys == NULL ) if( p_vout->p_sys == NULL )
...@@ -102,7 +103,9 @@ static int Open ( vlc_object_t *p_this ) ...@@ -102,7 +103,9 @@ static int Open ( vlc_object_t *p_this )
p_picture_vout->i_picture_num = 0; p_picture_vout->i_picture_num = 0;
p_picture_vout->p_pic = NULL; p_picture_vout->p_pic = NULL;
} else { }
else
{
p_picture_vout = val.p_address; p_picture_vout = val.p_address;
msg_Dbg( p_vout, "p_picture_vout found" ); msg_Dbg( p_vout, "p_picture_vout found" );
vlc_mutex_lock( &p_picture_vout->lock ); vlc_mutex_lock( &p_picture_vout->lock );
...@@ -214,7 +217,7 @@ static void Close ( vlc_object_t *p_this ) ...@@ -214,7 +217,7 @@ static void Close ( vlc_object_t *p_this )
if( p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture ) if( p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture )
{ {
/* FIXME */ /* FIXME */
free( p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture ); free( p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture );
} }
p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].i_status p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].i_status
...@@ -222,15 +225,19 @@ static void Close ( vlc_object_t *p_this ) ...@@ -222,15 +225,19 @@ static void Close ( vlc_object_t *p_this )
for( i = 0; i < p_picture_vout->i_picture_num; i ++) for( i = 0; i < p_picture_vout->i_picture_num; i ++)
{ {
if( p_picture_vout->p_pic[i].i_status == PICTURE_VOUT_E_OCCUPIED ) { if( p_picture_vout->p_pic[i].i_status == PICTURE_VOUT_E_OCCUPIED )
{
i_flag = 1; i_flag = 1;
break; break;
} }
} }
if( i_flag == 1 ){ if( i_flag == 1 )
{
vlc_mutex_unlock( &p_picture_vout->lock ); vlc_mutex_unlock( &p_picture_vout->lock );
} else { }
else
{
free( p_picture_vout->p_pic ); free( p_picture_vout->p_pic );
vlc_mutex_unlock( &p_picture_vout->lock ); vlc_mutex_unlock( &p_picture_vout->lock );
vlc_mutex_destroy( &p_picture_vout->lock ); vlc_mutex_destroy( &p_picture_vout->lock );
...@@ -256,41 +263,35 @@ static void Display( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -256,41 +263,35 @@ static void Display( vout_thread_t *p_vout, picture_t *p_pic )
libvlc_t *p_libvlc = p_vout->p_libvlc; libvlc_t *p_libvlc = p_vout->p_libvlc;
vlc_value_t val; vlc_value_t val;
struct picture_vout_t *p_picture_vout; struct picture_vout_t *p_picture_vout;
picture_t *p_new_pic;
var_Get( p_libvlc, "p_picture_vout", &val ); var_Get( p_libvlc, "p_picture_vout", &val );
p_picture_vout = val.p_address; p_picture_vout = val.p_address;
/* p_new_pic = (picture_t*)malloc( sizeof(picture_t) );
src : p_pic
dest : p_picture_pout->p_pic[p_vout->p_sys.i_picture_pos]->p_picture
*/
vlc_mutex_lock( &p_picture_vout->lock );
if( p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture )
{
if( p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture->p_data_orig )
{
free( p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos]
.p_picture->p_data_orig );
}
free( p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture );
}
p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture
= (picture_t*)malloc( sizeof( picture_t )) ;
vout_AllocatePicture( p_vout, vout_AllocatePicture( p_vout,
p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture, p_new_pic,
p_pic->format.i_chroma, p_pic->format.i_chroma,
p_pic->format.i_width, p_pic->format.i_width,
p_pic->format.i_height, p_pic->format.i_height,
VOUT_ASPECT_FACTOR * p_pic->format.i_height / p_pic->format.i_width ); VOUT_ASPECT_FACTOR * p_pic->format.i_height / p_pic->format.i_width );
p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture->i_status = DESTROYED_PICTURE; p_new_pic->i_status = DESTROYED_PICTURE;
p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture->i_type = DIRECT_PICTURE; p_new_pic->i_type = DIRECT_PICTURE;
vout_CopyPicture( p_vout, p_new_pic, p_pic );
vout_CopyPicture( p_vout, vlc_mutex_lock( &p_picture_vout->lock );
p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture, if( p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture )
p_pic); {
if( p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture->p_data_orig )
{
free( p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos]
.p_picture->p_data_orig );
}
free( p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture );
}
p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture = p_new_pic;
vlc_mutex_unlock( &p_picture_vout->lock ); vlc_mutex_unlock( &p_picture_vout->lock );
} }
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