From 824a8fc80c04cff1b2843fe34a9ec1471398d391 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 31 Jul 2008 12:58:44 +0000 Subject: [PATCH] gst/videotestsrc/gstvideotestsrc.c: Discard buffers of the wrong size after renegotiation, this is perfectly possible... Original commit message from CVS: * gst/videotestsrc/gstvideotestsrc.c: (gst_video_test_src_getcaps), (gst_video_test_src_create): Discard buffers of the wrong size after renegotiation, this is perfectly possible with things like capsfilter that could suggest caps changes upstream without knowing the size of the buffer. --- ChangeLog | 8 ++++++++ gst/videotestsrc/gstvideotestsrc.c | 23 +++++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index d7b7854d23..d6fe04a325 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-07-31 Wim Taymans + + * gst/videotestsrc/gstvideotestsrc.c: (gst_video_test_src_getcaps), + (gst_video_test_src_create): + Discard buffers of the wrong size after renegotiation, this is perfectly + possible with things like capsfilter that could suggest caps changes + upstream without knowing the size of the buffer. + 2008-07-31 Wim Taymans * tests/icles/.cvsignore: diff --git a/gst/videotestsrc/gstvideotestsrc.c b/gst/videotestsrc/gstvideotestsrc.c index 954c7c5650..f1256fc463 100644 --- a/gst/videotestsrc/gstvideotestsrc.c +++ b/gst/videotestsrc/gstvideotestsrc.c @@ -310,9 +310,12 @@ gst_video_test_src_get_property (GObject * object, guint prop_id, /* threadsafe because this gets called as the plugin is loaded */ static GstCaps * -gst_video_test_src_getcaps (GstBaseSrc * unused) +gst_video_test_src_getcaps (GstBaseSrc * bsrc) { static GstCaps *capslist = NULL; + GstVideoTestSrc *videotestsrc; + + videotestsrc = GST_VIDEO_TEST_SRC (bsrc); if (!capslist) { GstCaps *caps; @@ -544,8 +547,8 @@ static GstFlowReturn gst_video_test_src_create (GstPushSrc * psrc, GstBuffer ** buffer) { GstVideoTestSrc *src; - gulong newsize; - GstBuffer *outbuf; + gulong newsize, size; + GstBuffer *outbuf = NULL; GstFlowReturn res; GstClockTime next_time; @@ -573,7 +576,19 @@ gst_video_test_src_create (GstPushSrc * psrc, GstBuffer ** buffer) &outbuf); if (res != GST_FLOW_OK) goto no_buffer; - } else { + + /* the buffer could have renegotiated, we need to discard any buffers of the + * wrong size. */ + size = GST_BUFFER_SIZE (outbuf); + newsize = gst_video_test_src_get_size (src, src->width, src->height); + + if (size != newsize) { + gst_buffer_unref (outbuf); + outbuf = NULL; + } + } + + if (outbuf == NULL) { outbuf = gst_buffer_new_and_alloc (newsize); gst_buffer_set_caps (outbuf, GST_PAD_CAPS (GST_BASE_SRC_PAD (psrc))); }