[vlc-devel] [PATCH 2/2] Wait-free snapshot handling in the vout thread
Laurent Aimar
fenrir at via.ecp.fr
Wed Mar 11 12:04:29 CET 2009
Hi,
On Wed, Mar 11, 2009, basos g wrote:
> Nice though.
> Why lock twice , though ?
> Couldn't we write something like :
>
> /*
> * Take a snapshot if requested
> */
>
> if( p_directbuffer &&
> vlc_mutex_trylock( &p_vout->p->snapshot.lock ) )
> {
> if ( p_vout->p->snapshot.i_request > 0 )
> {
> while( p_vout->p->snapshot.i_request > 0 )
> {
> picture_t *p_pic = picture_New( p_vout->fmt_out.i_chroma,
> p_vout->fmt_out.i_width,
> p_vout->fmt_out.i_height,
> p_vout->fmt_out.i_aspect );
> if( !p_pic )
> break;
>
> picture_Copy( p_pic, p_directbuffer );
>
> p_pic->p_next = p_vout->p->snapshot.p_picture;
> p_vout->p->snapshot.p_picture = p_pic;
> p_vout->p->snapshot.i_request--;
> } //end while
> vlc_cond_broadcast( &p_vout->p->snapshot.wait );
> } //end if i_request>0
> vlc_mutex_unlock( &p_vout->p->snapshot.lock );
> } //end if mutext try lock
No, you cannot, spu_SortSubpictures must be call with the snapshot request
information.
And it is better to not lock around spu_SortSubpictures with the snapshot lock.
--
fenrir
More information about the vlc-devel
mailing list