Commit 0c5adb0e authored by Laurent Aimar's avatar Laurent Aimar

Modified vout_*Picture API.

It is a bit simpler and cleaner.
I plan to remove the need for specific vout
vout_HoldPicture/ReleasePicture functions, but it is not yet possible.
parent 11ac4b09
......@@ -161,11 +161,11 @@ VLC_EXPORT( int, vout_GetSnapshot, ( vout_thread_t *p_vout,
const char *psz_format, mtime_t i_timeout ) );
/* */
VLC_EXPORT( picture_t *, vout_CreatePicture, ( vout_thread_t *, bool, bool, unsigned int ) );
VLC_EXPORT( void, vout_DestroyPicture, ( vout_thread_t *, picture_t * ) );
VLC_EXPORT( void, vout_DisplayPicture, ( vout_thread_t *, picture_t * ) );
VLC_EXPORT( void, vout_LinkPicture, ( vout_thread_t *, picture_t * ) );
VLC_EXPORT( void, vout_UnlinkPicture, ( vout_thread_t *, picture_t * ) );
VLC_EXPORT( picture_t *, vout_GetPicture, ( vout_thread_t * ) );
VLC_EXPORT( void, vout_PutPicture, ( vout_thread_t *, picture_t * ) );
VLC_EXPORT( void, vout_HoldPicture, ( vout_thread_t *, picture_t * ) );
VLC_EXPORT( void, vout_ReleasePicture, ( vout_thread_t *, picture_t * ) );
/**
* Return the spu_t object associated to a vout_thread_t.
......
......@@ -353,7 +353,7 @@ static void* Thread( vlc_object_t *p_this )
free( p_thread->psz_title );
p_thread->psz_title = NULL;
while( !( p_pic = vout_CreatePicture( p_thread->p_vout, 0, 0, 0 ) ) &&
while( !( p_pic = vout_GetPicture( p_thread->p_vout ) ) &&
vlc_object_alive (p_thread) )
{
msleep( VOUT_OUTMEM_SLEEP );
......@@ -364,7 +364,7 @@ static void* Thread( vlc_object_t *p_this )
memcpy( p_pic->p[0].p_pixels, plane, width * height * 4 );
p_pic->date = date_Get( &i_pts ) + GOOM_DELAY;
vout_DisplayPicture( p_thread->p_vout, p_pic );
vout_PutPicture( p_thread->p_vout, p_pic );
}
goom_close( p_plugin_info );
......
......@@ -336,7 +336,7 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
int i;
/* First, get a new picture */
while( ( p_outpic = vout_CreatePicture( p_sys->p_vout, 0, 0, 3 ) ) == NULL)
while( ( p_outpic = vout_GetPicture( p_sys->p_vout ) ) == NULL)
{ /* XXX: This looks like a bad idea. Don't run to me for sympathy if it
* dead locks... */
if( !vlc_object_alive (p_sys->p_vout) )
......@@ -365,7 +365,7 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
p_outpic->date = p_in_buf->i_pts + (p_in_buf->i_length / 2);
vout_DisplayPicture( p_sys->p_vout, p_outpic );
vout_PutPicture( p_sys->p_vout, p_outpic );
return p_in_buf;
}
......
......@@ -1339,10 +1339,10 @@ static void DecoderPlayVideo( decoder_t *p_dec, picture_t *p_picture,
{
msg_Warn( p_vout, "non-dated video buffer received" );
*pi_lost_sum += 1;
vout_DropPicture( p_vout, p_picture );
vout_ReleasePicture( p_vout, p_picture );
return;
}
vout_LinkPicture( p_vout, p_picture );
vout_HoldPicture( p_vout, p_picture );
/* */
vlc_mutex_lock( &p_owner->lock );
......@@ -1421,8 +1421,8 @@ static void DecoderPlayVideo( decoder_t *p_dec, picture_t *p_picture,
vout_Flush( p_vout, p_picture->date );
p_owner->i_last_rate = i_rate;
}
vout_DisplayPicture( p_vout, p_picture );
vout_UnlinkPicture( p_vout, p_picture );
vout_PutPicture( p_vout, p_picture );
vout_ReleasePicture( p_vout, p_picture );
}
else
{
......@@ -1432,8 +1432,8 @@ static void DecoderPlayVideo( decoder_t *p_dec, picture_t *p_picture,
msg_Warn( p_vout, "non-dated video buffer received" );
*pi_lost_sum += 1;
vout_UnlinkPicture( p_vout, p_picture );
vout_DropPicture( p_vout, p_picture );
vout_ReleasePicture( p_vout, p_picture );
vout_ReleasePicture( p_vout, p_picture );
}
int i_tmp_display;
int i_tmp_lost;
......@@ -1469,7 +1469,7 @@ static void DecoderDecodeVideo( decoder_t *p_dec, block_t *p_block )
if( p_dec->b_die )
{
/* It prevent freezing VLC in case of broken decoder */
vout_DropPicture( p_vout, p_pic );
vout_ReleasePicture( p_vout, p_pic );
if( p_block )
block_Release( p_block );
break;
......@@ -1479,7 +1479,7 @@ static void DecoderDecodeVideo( decoder_t *p_dec, block_t *p_block )
if( p_owner->i_preroll_end > VLC_TS_INVALID && p_pic->date < p_owner->i_preroll_end )
{
vout_DropPicture( p_vout, p_pic );
vout_ReleasePicture( p_vout, p_pic );
continue;
}
......@@ -1687,8 +1687,8 @@ static void DecoderFlushBuffering( decoder_t *p_dec )
if( p_owner->p_vout )
{
vout_UnlinkPicture( p_owner->p_vout, p_picture );
vout_DropPicture( p_owner->p_vout, p_picture );
vout_ReleasePicture( p_owner->p_vout, p_picture );
vout_ReleasePicture( p_owner->p_vout, p_picture );
}
if( !p_owner->buffer.p_picture )
......@@ -2353,7 +2353,7 @@ static picture_t *vout_new_buffer( decoder_t *p_dec )
if( p_dec->b_die || p_dec->b_error )
return NULL;
picture_t *p_picture = vout_CreatePicture( p_owner->p_vout, 0, 0, 0 );
picture_t *p_picture = vout_GetPicture( p_owner->p_vout );
if( p_picture )
return p_picture;
......@@ -2373,17 +2373,17 @@ static picture_t *vout_new_buffer( decoder_t *p_dec )
static void vout_del_buffer( decoder_t *p_dec, picture_t *p_pic )
{
vout_DropPicture( p_dec->p_owner->p_vout, p_pic );
vout_ReleasePicture( p_dec->p_owner->p_vout, p_pic );
}
static void vout_link_picture( decoder_t *p_dec, picture_t *p_pic )
{
vout_LinkPicture( p_dec->p_owner->p_vout, p_pic );
vout_HoldPicture( p_dec->p_owner->p_vout, p_pic );
}
static void vout_unlink_picture( decoder_t *p_dec, picture_t *p_pic )
{
vout_UnlinkPicture( p_dec->p_owner->p_vout, p_pic );
vout_ReleasePicture( p_dec->p_owner->p_vout, p_pic );
}
static subpicture_t *spu_new_buffer( decoder_t *p_dec )
......
......@@ -609,13 +609,13 @@ vlm_MessageSimpleNew
vlm_New
vout_Close
vout_Create
vout_CreatePicture
vout_DestroyPicture
vout_DisplayPicture
vout_GetPicture
vout_PutPicture
vout_HoldPicture
vout_ReleasePicture
vout_EnableFilter
vout_GetSnapshot
vout_GetSpu
vout_LinkPicture
vout_OSDIcon
vout_OSDMessage
vout_OSDEpg
......@@ -623,7 +623,6 @@ vout_OSDSlider
vout_Request
vout_ShowTextAbsolute
vout_ShowTextRelative
vout_UnlinkPicture
vout_window_New
vout_window_Control
vout_window_Delete
......
......@@ -65,11 +65,6 @@ void vout_FixLeaks( vout_thread_t *p_vout );
*/
void vout_Reset( vout_thread_t *p_vout );
/**
* This functions will drop a picture retreived by vout_CreatePicture.
*/
void vout_DropPicture( vout_thread_t *p_vout, picture_t * );
/**
* This function will force to display the next picture while paused
*/
......
......@@ -45,37 +45,16 @@
#include "vout_internal.h"
/**
* Display a picture
* It retreives a picture from the vout or NULL if no pictures are
* available yet.
*
* Remove the reservation flag of a picture, which will cause it to be ready
* for display.
*/
void vout_DisplayPicture( vout_thread_t *p_vout, picture_t *p_pic )
{
vlc_mutex_lock( &p_vout->p->picture_lock );
p_pic->p_next = NULL;
picture_fifo_Push(p_vout->p->decoder_fifo, p_pic);
vlc_cond_signal( &p_vout->p->picture_wait );
vlc_mutex_unlock( &p_vout->p->picture_lock );
}
/**
* Allocate a picture in the video output heap.
* You MUST call vout_PutPicture or vout_ReleasePicture on it.
*
* This function creates a reserved image in the video output heap.
* A null pointer is returned if the function fails. This method provides an
* already allocated zone of memory in the picture data fields.
* It needs locking since several pictures can be created by several producers
* threads.
* You may use vout_HoldPicture(paired with vout_ReleasePicture) to keep a
* read-only reference.
*/
picture_t *vout_CreatePicture( vout_thread_t *p_vout,
bool b_progressive,
bool b_top_field_first,
unsigned int i_nb_fields )
picture_t *vout_GetPicture( vout_thread_t *p_vout )
{
#warning "TODO remove unused vout_CreatePicture parameters"
/* Get lock */
vlc_mutex_lock( &p_vout->p->picture_lock );
picture_t *p_pic = picture_pool_Get(p_vout->p->decoder_pool);
......@@ -88,47 +67,48 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout,
return p_pic;
}
/* */
void vout_DropPicture( vout_thread_t *p_vout, picture_t *p_pic )
/**
* It gives to the vout a picture to be displayed.
*
* The given picture MUST comes from vout_GetPicture.
*
* Becareful, after vout_PutPicture is called, picture_t::p_next cannot be
* read/used.
*/
void vout_PutPicture( vout_thread_t *p_vout, picture_t *p_pic )
{
vlc_mutex_lock( &p_vout->p->picture_lock );
picture_Release( p_pic );
p_pic->p_next = NULL;
picture_fifo_Push(p_vout->p->decoder_fifo, p_pic);
vlc_cond_signal( &p_vout->p->picture_wait );
vlc_mutex_unlock( &p_vout->p->picture_lock );
}
void vout_DestroyPicture( vout_thread_t *p_vout, picture_t *p_pic )
{
vout_DropPicture( p_vout, p_pic );
}
/**
* Increment reference counter of a picture
*
* This function increments the reference counter of a picture in the video
* heap. It needs a lock since several producer threads can access the picture.
* It releases a picture retreived by vout_GetPicture.
*/
void vout_LinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
void vout_ReleasePicture( vout_thread_t *p_vout, picture_t *p_pic )
{
vlc_mutex_lock( &p_vout->p->picture_lock );
picture_Hold( p_pic );
picture_Release( p_pic );
vlc_cond_signal( &p_vout->p->picture_wait );
vlc_mutex_unlock( &p_vout->p->picture_lock );
}
/**
* Decrement reference counter of a picture
*
* This function decrement the reference counter of a picture in the video heap
* It increment the reference counter of a picture retreived by
* vout_GetPicture.
*/
void vout_UnlinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
void vout_HoldPicture( vout_thread_t *p_vout, picture_t *p_pic )
{
vlc_mutex_lock( &p_vout->p->picture_lock );
picture_Release( p_pic );
vlc_cond_signal( &p_vout->p->picture_wait );
picture_Hold( p_pic );
vlc_mutex_unlock( &p_vout->p->picture_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