summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2015-05-19 16:31:38 +0200
committerWim Taymans <wtaymans@redhat.com>2015-05-19 16:31:38 +0200
commit064a18d62b773d801bc0d3e8d4e6aae32afaef97 (patch)
tree5c40d9dea4ae4b8360a6acf04d6da1d92a8d741d
parentd7c2f8603979462869141b0feb62bb10064ebbca (diff)
downloadclutter-gst-064a18d62b773d801bc0d3e8d4e6aae32afaef97.tar.gz
video-sink: clear buffer in flush
We need to release our refs to the buffer in FLUSH_START so that upstream can free and reuse the memory.
-rw-r--r--clutter-gst/clutter-gst-video-sink.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/clutter-gst/clutter-gst-video-sink.c b/clutter-gst/clutter-gst-video-sink.c
index 5ee3f62..9037b94 100644
--- a/clutter-gst/clutter-gst-video-sink.c
+++ b/clutter-gst/clutter-gst-video-sink.c
@@ -2305,6 +2305,31 @@ clutter_gst_video_sink_propose_allocation (GstBaseSink *base_sink, GstQuery *que
return TRUE;
}
+static gboolean
+clutter_gst_video_sink_event (GstBaseSink * basesink, GstEvent * event)
+{
+ ClutterGstVideoSink *sink = CLUTTER_GST_VIDEO_SINK (basesink);
+ ClutterGstVideoSinkPrivate *priv = sink->priv;
+ ClutterGstSource *gst_source = priv->source;
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_FLUSH_START:
+ g_mutex_lock (&gst_source->buffer_lock);
+ if (gst_source->buffer) {
+ GST_DEBUG ("Freeing existing buffer %p", gst_source->buffer);
+ gst_buffer_unref (gst_source->buffer);
+ gst_source->buffer = NULL;
+ }
+ g_mutex_unlock (&gst_source->buffer_lock);
+ break;
+
+ default:
+ break;
+ }
+
+ return GST_BASE_SINK_CLASS (clutter_gst_video_sink_parent_class)->event (basesink, event);
+}
+
static void
clutter_gst_video_sink_class_init (ClutterGstVideoSinkClass *klass)
{
@@ -2346,6 +2371,7 @@ clutter_gst_video_sink_class_init (ClutterGstVideoSinkClass *klass)
gb_class->set_caps = clutter_gst_video_sink_set_caps;
gb_class->get_caps = clutter_gst_video_sink_get_caps;
gb_class->propose_allocation = clutter_gst_video_sink_propose_allocation;
+ gb_class->event = clutter_gst_video_sink_event;
gv_class->show_frame = _clutter_gst_video_sink_show_frame;