]> git.sesse.net Git - vlc/commitdiff
Modified vout_*Picture API.
authorLaurent Aimar <fenrir@videolan.org>
Fri, 23 Apr 2010 21:18:56 +0000 (23:18 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Fri, 23 Apr 2010 21:18:56 +0000 (23:18 +0200)
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.

include/vlc_vout.h
modules/visualization/goom.c
modules/visualization/visual/visual.c
src/input/decoder.c
src/libvlccore.sym
src/video_output/vout_control.h
src/video_output/vout_pictures.c

index c7300ae1ebac9b04870e9741d54d438aa912a06f..2f562245fc775afca4ae601bf320d28cf8fb39be 100644 (file)
@@ -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.
index cb847e4e6249c7e853e6862223c92e7221b6927d..427bb75d02b8d4db7e58eb6fc7ea97dfeb370bd9 100644 (file)
@@ -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 );
index cf3c00ff5255b30f057c687ff3cdfe4e8eb2d390..98b4ab3b06c16865197c61d69fa901951f6876f5 100644 (file)
@@ -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;
 }
 
index 5d65be826aaac5709f4a9bb9c0529ff6ca66f6ae..3f36282b89b9ed13af7546ad5c4f813dbe366d12 100644 (file)
@@ -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 )
index 5cb1dd950ede9d065a6b325b7b018d414d5dbe3a..a3cf8614fd4f96fae5c19da9ddbb430c97265099 100644 (file)
@@ -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
index db179a8c785b51b3f61df1526806dad4579985d2..ffb194ed93c125350b053f22f7b385cd721b082a 100644 (file)
@@ -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
  */
index 8bac6e495a5b5bc3b5a78c7fa67019fcde06ad7e..bf598c8deb8aa3c61f727e9712856772f3e3abfe 100644 (file)
 #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 );
 }