From e7f910e0fc3601e40e2fba2d09f7d7389d08d4b4 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 2 Feb 2009 13:30:42 +0100 Subject: [PATCH] Fix buffer_alloc in ximagesink Remove some useless debug info that reported wrong image sizes. When upstream does not accept out suggested size, fall back to allocating an image of the requested width/height instead of the currently configured size. The problem is that an image is reused from the pool because the width/height match but the caps on the new buffer are the requested caps with possibly different height/width resulting in errors. --- sys/ximage/ximagesink.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/sys/ximage/ximagesink.c b/sys/ximage/ximagesink.c index de2b015f45..7ba00c0217 100644 --- a/sys/ximage/ximagesink.c +++ b/sys/ximage/ximagesink.c @@ -231,8 +231,8 @@ gst_ximage_buffer_finalize (GstXImageBuffer * ximage) } if (!recycled) - GST_MINI_OBJECT_CLASS (ximage_buffer_parent_class)-> - finalize (GST_MINI_OBJECT (ximage)); + GST_MINI_OBJECT_CLASS (ximage_buffer_parent_class)->finalize + (GST_MINI_OBJECT (ximage)); beach: return; @@ -1364,8 +1364,8 @@ gst_ximagesink_getcaps (GstBaseSink * bsink) /* get a template copy and add the pixel aspect ratio */ caps = - gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SINK (ximagesink)-> - sinkpad)); + gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SINK + (ximagesink)->sinkpad)); for (i = 0; i < gst_caps_get_size (caps); ++i) { GstStructure *structure = gst_caps_get_structure (caps, i); @@ -1742,24 +1742,19 @@ gst_ximagesink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size, * function returns true. */ if (gst_pad_peer_accept_caps (GST_VIDEO_SINK_PAD (ximagesink), desired_caps)) { - gint bpp; - - bpp = size / height / width; /* we will not alloc a buffer of the new suggested caps. Make sure * we also unref this new caps after we set it on the buffer. */ alloc_caps = desired_caps; alloc_unref = TRUE; width = result.w; height = result.h; - size = bpp * width * height; - GST_DEBUG ("peer pad accepts our desired caps %" GST_PTR_FORMAT - " buffer size is now %d bytes", desired_caps, size); + GST_DEBUG ("peer pad accepts our desired caps %" GST_PTR_FORMAT, + desired_caps); } else { GST_DEBUG ("peer pad does not accept our desired caps %" GST_PTR_FORMAT, desired_caps); - /* we alloc a buffer with the original incomming caps */ - width = GST_VIDEO_SINK_WIDTH (ximagesink); - height = GST_VIDEO_SINK_HEIGHT (ximagesink); + /* we alloc a buffer with the original incomming caps already in the + * width and height variables */ } } }