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.
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.
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 );
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 );
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) )
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;
}
{
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 );
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
{
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;
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;
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;
}
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 )
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;
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 )
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
vout_Request
vout_ShowTextAbsolute
vout_ShowTextRelative
-vout_UnlinkPicture
vout_window_New
vout_window_Control
vout_window_Delete
*/
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
*/
#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);
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 );
}