From d97dd36ae5b456531ba12ea3c633123ebf74493c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sun, 3 Mar 2013 17:39:13 +0000 Subject: [PATCH] ogg: small GValue optimisation No need to copy buffers we put into the streamheader any more now that we don't put caps on buffers any more, so there's no danger of a refcount cycle. --- ext/ogg/gstoggdemux.c | 7 +++---- ext/ogg/gstoggmux.c | 8 ++------ ext/ogg/gstoggparse.c | 4 +--- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c index 7001f9c103..162cfc5436 100644 --- a/ext/ogg/gstoggdemux.c +++ b/ext/ogg/gstoggdemux.c @@ -147,7 +147,7 @@ static GstFlowReturn gst_ogg_demux_combine_flows (GstOggDemux * ogg, GstOggPad * pad, GstFlowReturn ret); static void gst_ogg_demux_sync_streams (GstOggDemux * ogg); -GstCaps *gst_ogg_demux_set_header_on_caps (GstOggDemux * ogg, +static GstCaps *gst_ogg_demux_set_header_on_caps (GstOggDemux * ogg, GstCaps * caps, GList * headers); static gboolean gst_ogg_demux_send_event (GstOggDemux * ogg, GstEvent * event); static gboolean gst_ogg_demux_perform_seek_push (GstOggDemux * ogg, @@ -2499,7 +2499,7 @@ gst_ogg_demux_deactivate_current_chain (GstOggDemux * ogg) return TRUE; } -GstCaps * +static GstCaps * gst_ogg_demux_set_header_on_caps (GstOggDemux * ogg, GstCaps * caps, GList * headers) { @@ -2534,8 +2534,7 @@ gst_ogg_demux_set_header_on_caps (GstOggDemux * ogg, GstCaps * caps, headers = headers->next; } - gst_structure_set_value (structure, "streamheader", &array); - g_value_unset (&array); + gst_structure_take_value (structure, "streamheader", &array); GST_LOG_OBJECT (ogg, "here are the newly set caps: %" GST_PTR_FORMAT, caps); return caps; diff --git a/ext/ogg/gstoggmux.c b/ext/ogg/gstoggmux.c index 57981f3447..205bcef946 100644 --- a/ext/ogg/gstoggmux.c +++ b/ext/ogg/gstoggmux.c @@ -1117,7 +1117,6 @@ gst_ogg_mux_set_header_on_caps (GstCaps * caps, GList * buffers) while (walk) { GstBuffer *buf = GST_BUFFER (walk->data); - GstBuffer *copy; GValue value = { 0 }; walk = walk->next; @@ -1128,14 +1127,11 @@ gst_ogg_mux_set_header_on_caps (GstCaps * caps, GList * buffers) GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_HEADER); g_value_init (&value, GST_TYPE_BUFFER); - copy = gst_buffer_copy (buf); - gst_value_set_buffer (&value, copy); - gst_buffer_unref (copy); + gst_value_set_buffer (&value, buf); gst_value_array_append_value (&array, &value); g_value_unset (&value); } - gst_structure_set_value (structure, "streamheader", &array); - g_value_unset (&array); + gst_structure_take_value (structure, "streamheader", &array); return caps; } diff --git a/ext/ogg/gstoggparse.c b/ext/ogg/gstoggparse.c index 1d096a5ff0..76f53abfcb 100644 --- a/ext/ogg/gstoggparse.c +++ b/ext/ogg/gstoggparse.c @@ -585,12 +585,10 @@ gst_ogg_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer) caps = gst_caps_make_writable (caps); structure = gst_caps_get_structure (caps, 0); - gst_structure_set_value (structure, "streamheader", &array); + gst_structure_take_value (structure, "streamheader", &array); gst_pad_set_caps (ogg->srcpad, caps); - g_value_unset (&array); - if (ogg->caps) gst_caps_unref (ogg->caps); ogg->caps = caps;