From: Wim T. <wt...@us...> - 2002-07-08 19:49:18
|
CVS Root: /cvsroot/gstreamer Module: gst-plugins Changes by: wtay Date: Mon Jul 08 2002 12:49:17 PDT Log message: - Fix bufferpools in xvideosink - don't use a black pixel in the xwindow for smoother resize Modified files: sys/xvideo : gstxwindow.c xvideosink.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/sys/xvideo/gstxwindow.c.diff?r1=1.4&r2=1.5 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/sys/xvideo/xvideosink.c.diff?r1=1.16&r2=1.17 ====Begin Diffs==== Index: gstxwindow.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/sys/xvideo/gstxwindow.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- gstxwindow.c 8 May 2002 20:20:01 -0000 1.4 +++ gstxwindow.c 8 Jul 2002 19:49:05 -0000 1.5 @@ -30,7 +30,6 @@ { XGCValues values; GstXWindow *new; - XSetWindowAttributes attrib; new = g_new0 (GstXWindow, 1); @@ -50,10 +49,9 @@ new->root = DefaultRootWindow (new->disp); - attrib.background_pixel = XBlackPixel (new->disp, DefaultScreen (new->disp)); new->win = XCreateWindow (new->disp, DefaultRootWindow (new->disp), 0, 0, new->width, new->height, 0, CopyFromParent, - CopyFromParent, CopyFromParent, CWBackPixel, &attrib); + CopyFromParent, CopyFromParent, 0, NULL); if (!new->win) { Index: xvideosink.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/sys/xvideo/xvideosink.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- xvideosink.c 19 Jun 2002 19:25:23 -0000 1.16 +++ xvideosink.c 8 Jul 2002 19:49:05 -0000 1.17 @@ -165,7 +165,7 @@ static GstBuffer* -gst_xvideosink_buffer_new (GstBufferPool *pool, gint64 location, gint size, gpointer user_data) +gst_xvideosink_buffer_new (GstBufferPool *pool, guint64 location, guint size, gpointer user_data) { GstXVideoSink *xvideosink; GstBuffer *buffer; @@ -191,7 +191,6 @@ xvideosink->image_pool = g_slist_delete_link (xvideosink->image_pool, xvideosink->image_pool); g_mutex_unlock (xvideosink->pool_lock); } - buffer = gst_buffer_new (); GST_BUFFER_POOL_PRIVATE (buffer) = ximage; GST_BUFFER_DATA (buffer) = GST_XIMAGE_DATA (ximage); @@ -217,7 +216,6 @@ xvideosink->image_pool = g_slist_delete_link (xvideosink->image_pool, xvideosink->image_pool); g_mutex_unlock (xvideosink->pool_lock); } - buffer = gst_buffer_new (); GST_BUFFER_POOL_PRIVATE (buffer) = xvimage; GST_BUFFER_DATA (buffer) = GST_XVIMAGE_DATA (xvimage); @@ -230,15 +228,19 @@ } static void -gst_xvideosink_buffer_free (GstBuffer *buffer) +gst_xvideosink_buffer_free (GstBufferPool *pool, GstBuffer *buffer, gpointer user_data) { GstXVideoSink *xvideosink; - xvideosink = GST_XVIDEOSINK (gst_buffer_pool_get_user_data (GST_BUFFER_BUFFERPOOL (buffer))); + xvideosink = GST_XVIDEOSINK (user_data); g_mutex_lock (xvideosink->pool_lock); xvideosink->image_pool = g_slist_prepend (xvideosink->image_pool, GST_BUFFER_POOL_PRIVATE (buffer)); g_mutex_unlock (xvideosink->pool_lock); + + GST_BUFFER_DATA (buffer) = NULL; + + _gst_buffer_free (buffer); } static GstBufferPool* @@ -248,35 +250,25 @@ xvideosink = GST_XVIDEOSINK (gst_pad_get_parent (pad)); - switch (xvideosink->format) { - case GST_MAKE_FOURCC ('R','G','B',' '): - if (!xvideosink->bufferpool) { + if (!xvideosink->bufferpool) { + switch (xvideosink->format) { + case GST_MAKE_FOURCC ('R','G','B',' '): GST_DEBUG (0, "xvideosink: creating RGB XImage bufferpool"); - - xvideosink->bufferpool = gst_buffer_pool_new (); - gst_buffer_pool_set_buffer_new_function (xvideosink->bufferpool, - gst_xvideosink_buffer_new); - gst_buffer_pool_set_buffer_free_function (xvideosink->bufferpool, - gst_xvideosink_buffer_free); - gst_buffer_pool_set_user_data (xvideosink->bufferpool, xvideosink); - xvideosink->image_pool = NULL; - } - break; - default: - if (!xvideosink->bufferpool) { + default: GST_DEBUG (0, "xvideosink: creating YUV XvImage bufferpool"); + } - xvideosink->bufferpool = gst_buffer_pool_new (); - gst_buffer_pool_set_buffer_new_function (xvideosink->bufferpool, - gst_xvideosink_buffer_new); - gst_buffer_pool_set_buffer_free_function (xvideosink->bufferpool, - gst_xvideosink_buffer_free); - gst_buffer_pool_set_user_data (xvideosink->bufferpool, xvideosink); - xvideosink->image_pool = NULL; - } - break; + xvideosink->bufferpool = gst_buffer_pool_new ( + NULL, /* free */ + NULL, /* copy */ + gst_xvideosink_buffer_new, + NULL, + gst_xvideosink_buffer_free, + xvideosink); + xvideosink->image_pool = NULL; } + gst_buffer_pool_ref (xvideosink->bufferpool); return xvideosink->bufferpool; } @@ -298,8 +290,6 @@ "height", &xvideosink->height, NULL); - xvideosink->bufferpool = NULL; - print_format = GULONG_FROM_LE (xvideosink->format); GST_DEBUG (0, "xvideosink: setting %08x (%4.4s) %dx%d\n", @@ -420,7 +410,7 @@ GST_OBJECT_NAME (xvideosink->clock), time, GST_BUFFER_SIZE (buf)); ret = gst_element_clock_wait (GST_ELEMENT (xvideosink), - xvideosink->clock, time - xvideosink->correction, NULL); + xvideosink->clock, time - xvideosink->correction, &jitter); } if (xvideosink->clock) @@ -458,6 +448,7 @@ jitter = gst_clock_get_time (xvideosink->clock) - time; xvideosink->correction = (xvideosink->correction + jitter) >> 1; + xvideosink->correction = 0; } //g_print ("jitter %lld %lld\n", jitter, xvideosink->correction); @@ -654,6 +645,9 @@ case GST_STATE_PAUSED_TO_READY: break; case GST_STATE_READY_TO_NULL: + if (xvideosink->bufferpool) + gst_buffer_pool_unref (xvideosink->bufferpool); + xvideosink->bufferpool = NULL; if (xvideosink->window) { if (xvideosink->ximage) { _gst_ximage_destroy (xvideosink->ximage); |