fix template caps refcount
authorWim Taymans <wim.taymans@collabora.co.uk>
Sat, 10 Mar 2012 09:51:44 +0000 (10:51 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Sat, 10 Mar 2012 09:52:01 +0000 (10:52 +0100)
15 files changed:
ext/jpeg/gstjpegdec.c
gst/alpha/gstalphacolor.c
gst/audioparsers/gstaacparse.c
gst/audioparsers/gstac3parse.c
gst/audioparsers/gstamrparse.c
gst/audioparsers/gstdcaparse.c
gst/audioparsers/gstflacparse.c
gst/audioparsers/gstmpegaudioparse.c
gst/audioparsers/gstwavpackparse.c
gst/auparse/gstauparse.c
gst/goom2k1/gstgoom.c
gst/law/alaw-decode.c
gst/law/alaw-encode.c
gst/law/mulaw-decode.c
gst/law/mulaw-encode.c

index 4e071e1..a723f35 100644 (file)
@@ -733,6 +733,7 @@ gst_jpeg_dec_getcaps (GstPad * pad, GstCaps * filter)
   GstJpegDec *dec;
   GstCaps *caps;
   GstPad *peer;
+  GstCaps *templ_caps;
 
   dec = GST_JPEG_DEC (GST_OBJECT_PARENT (pad));
 
@@ -741,9 +742,10 @@ gst_jpeg_dec_getcaps (GstPad * pad, GstCaps * filter)
 
   peer = gst_pad_get_peer (dec->srcpad);
 
+  templ_caps = gst_pad_get_pad_template_caps (pad);
+
   if (peer) {
     GstCaps *peer_caps;
-    const GstCaps *templ_caps;
     GstStructure *s;
     guint i, n;
 
@@ -758,13 +760,13 @@ gst_jpeg_dec_getcaps (GstPad * pad, GstCaps * filter)
       gst_structure_set_name (s, "image/jpeg");
     }
 
-    templ_caps = gst_pad_get_pad_template_caps (pad);
     caps = gst_caps_intersect_full (peer_caps, templ_caps,
         GST_CAPS_INTERSECT_FIRST);
     gst_caps_unref (peer_caps);
+    gst_caps_unref (templ_caps);
     gst_object_unref (peer);
   } else {
-    caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
+    caps = templ_caps;
   }
 
   return caps;
index 3a79eed..cdacf0a 100644 (file)
@@ -110,7 +110,7 @@ static GstCaps *
 gst_alpha_color_transform_caps (GstBaseTransform * btrans,
     GstPadDirection direction, GstCaps * caps, GstCaps * filter)
 {
-  const GstCaps *tmpl_caps = NULL;
+  GstCaps *tmpl_caps = NULL;
   GstCaps *result = NULL, *local_caps = NULL;
   guint i;
 
@@ -138,6 +138,7 @@ gst_alpha_color_transform_caps (GstBaseTransform * btrans,
 
   /* Intersect with our template caps */
   result = gst_caps_intersect (local_caps, tmpl_caps);
+  gst_caps_unref (tmpl_caps);
 
   gst_caps_unref (local_caps);
   gst_caps_do_simplify (result);
index 79633c4..15a8be7 100644 (file)
@@ -1088,12 +1088,13 @@ gst_aac_parse_stop (GstBaseParse * parse)
 static GstCaps *
 gst_aac_parse_sink_getcaps (GstBaseParse * parse, GstCaps * filter)
 {
-  GstCaps *peercaps;
+  GstCaps *peercaps, *templ;
   GstCaps *res;
 
   /* FIXME: handle filter caps */
 
-  peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
+  templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD (parse)),
+      peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
   if (peercaps) {
     guint i, n;
 
@@ -1106,15 +1107,11 @@ gst_aac_parse_sink_getcaps (GstBaseParse * parse, GstCaps * filter)
       gst_structure_remove_field (s, "framed");
     }
 
-    res =
-        gst_caps_intersect_full (peercaps,
-        gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD (parse)),
-        GST_CAPS_INTERSECT_FIRST);
+    res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
     gst_caps_unref (peercaps);
+    gst_caps_unref (templ);
   } else {
-    res =
-        gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD
-            (parse)));
+    res = templ;
   }
 
   return res;
index f88972f..d5d8551 100644 (file)
@@ -693,12 +693,12 @@ gst_ac3_parse_src_event (GstBaseParse * parse, GstEvent * event)
 static GstCaps *
 gst_ac3_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
 {
-  GstCaps *peercaps;
+  GstCaps *peercaps, *templ;
   GstCaps *res;
 
   /* FIXME: handle filter */
-
-  peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
+  templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD (parse)),
+      peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
   if (peercaps) {
     guint i, n;
 
@@ -713,15 +713,11 @@ gst_ac3_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
       gst_structure_remove_field (s, "alignment");
     }
 
-    res =
-        gst_caps_intersect_full (peercaps,
-        gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD (parse)),
-        GST_CAPS_INTERSECT_FIRST);
+    res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
     gst_caps_unref (peercaps);
+    gst_caps_unref (templ);
   } else {
-    res =
-        gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD
-            (parse)));
+    res = templ;
   }
 
   return res;
index 28e64db..bf8f37e 100644 (file)
@@ -365,11 +365,13 @@ gst_amr_parse_stop (GstBaseParse * parse)
 static GstCaps *
 gst_amr_parse_sink_getcaps (GstBaseParse * parse, GstCaps * filter)
 {
-  GstCaps *peercaps;
+  GstCaps *peercaps, *templ;
   GstCaps *res;
 
   /* FIXME: handle filter caps */
 
+  templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD (parse));
+
   peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
   if (peercaps) {
     guint i, n;
@@ -386,15 +388,11 @@ gst_amr_parse_sink_getcaps (GstBaseParse * parse, GstCaps * filter)
         gst_structure_set_name (s, "audio/x-amr-wb-sh");
     }
 
-    res =
-        gst_caps_intersect_full (peercaps,
-        gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD (parse)),
-        GST_CAPS_INTERSECT_FIRST);
+    res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
     gst_caps_unref (peercaps);
+    gst_caps_unref (templ);
   } else {
-    res =
-        gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD
-            (parse)));
+    res = templ;
   }
 
   return res;
index b1e256b..42565c2 100644 (file)
@@ -443,10 +443,11 @@ cleanup:
 static GstCaps *
 gst_dca_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
 {
-  GstCaps *peercaps;
+  GstCaps *peercaps, *templ;
   GstCaps *res;
 
   /* FIXME: handle filter caps */
+  templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD (parse));
 
   peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
   if (peercaps) {
@@ -461,15 +462,11 @@ gst_dca_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
       gst_structure_remove_field (s, "framed");
     }
 
-    res =
-        gst_caps_intersect_full (peercaps,
-        gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD (parse)),
-        GST_CAPS_INTERSECT_FIRST);
+    res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
     gst_caps_unref (peercaps);
+    gst_caps_unref (templ);
   } else {
-    res =
-        gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD
-            (parse)));
+    res = templ;
   }
 
   return res;
index 06a964e..f5ad169 100644 (file)
@@ -1526,10 +1526,11 @@ gst_flac_parse_convert (GstBaseParse * parse,
 static GstCaps *
 gst_flac_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
 {
-  GstCaps *peercaps;
+  GstCaps *peercaps, *templ;
   GstCaps *res;
 
   /* FIXME: handle filter caps */
+  templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD (parse));
 
   peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
   if (peercaps) {
@@ -1544,15 +1545,11 @@ gst_flac_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
       gst_structure_remove_field (s, "framed");
     }
 
-    res =
-        gst_caps_intersect_full (peercaps,
-        gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD (parse)),
-        GST_CAPS_INTERSECT_FIRST);
+    res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
     gst_caps_unref (peercaps);
+    gst_caps_unref (templ);
   } else {
-    res =
-        gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD
-            (parse)));
+    res = templ;
   }
 
   return res;
index f8987bf..1d5d276 100644 (file)
@@ -1401,10 +1401,11 @@ gst_mpeg_audio_parse_pre_push_frame (GstBaseParse * parse,
 static GstCaps *
 gst_mpeg_audio_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
 {
-  GstCaps *peercaps;
+  GstCaps *peercaps, *templ;
   GstCaps *res;
 
   /* FIXME: handle filter caps */
+  templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD (parse));
 
   peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
   if (peercaps) {
@@ -1419,15 +1420,11 @@ gst_mpeg_audio_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
       gst_structure_remove_field (s, "parsed");
     }
 
-    res =
-        gst_caps_intersect_full (peercaps,
-        gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD (parse)),
-        GST_CAPS_INTERSECT_FIRST);
+    res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
     gst_caps_unref (peercaps);
+    gst_caps_unref (templ);
   } else {
-    res =
-        gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD
-            (parse)));
+    res = templ;
   }
 
   return res;
index 637198d..875c03a 100644 (file)
@@ -607,10 +607,11 @@ more:
 static GstCaps *
 gst_wavpack_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
 {
-  GstCaps *peercaps;
+  GstCaps *peercaps, *templ;
   GstCaps *res;
 
   /* FIXME: handle filter caps */
+  templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD (parse));
 
   peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
   if (peercaps) {
@@ -625,15 +626,11 @@ gst_wavpack_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
       gst_structure_remove_field (s, "framed");
     }
 
-    res =
-        gst_caps_intersect_full (peercaps,
-        gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD (parse)),
-        GST_CAPS_INTERSECT_FIRST);
+    res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
     gst_caps_unref (peercaps);
+    gst_caps_unref (templ);
   } else {
-    res =
-        gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD
-            (parse)));
+    res = templ;
   }
 
   return res;
index 5c3170c..91c4f91 100644 (file)
@@ -348,7 +348,7 @@ gst_au_parse_parse_header (GstAuParse * auparse)
         "channels", G_TYPE_INT, auparse->channels, NULL);
     auparse->sample_size = auparse->channels;
   } else if (format != GST_AUDIO_FORMAT_UNKNOWN) {
-    const GstCaps *templ_caps = gst_pad_get_pad_template_caps (auparse->srcpad);
+    GstCaps *templ_caps = gst_pad_get_pad_template_caps (auparse->srcpad);
     GstCaps *intersection;
 
     tempcaps = gst_caps_new_simple ("audio/x-raw",
@@ -358,6 +358,7 @@ gst_au_parse_parse_header (GstAuParse * auparse)
 
     intersection = gst_caps_intersect (tempcaps, templ_caps);
     gst_caps_unref (tempcaps);
+    gst_caps_unref (templ_caps);
     tempcaps = intersection;
   } else if (layout[0]) {
     tempcaps = gst_caps_new_simple ("audio/x-adpcm",
index 96c11e5..ae78d97 100644 (file)
@@ -249,7 +249,7 @@ gst_goom_src_negotiate (GstGoom * goom)
 {
   GstCaps *othercaps, *target;
   GstStructure *structure;
-  const GstCaps *templ;
+  GstCaps *templ;
   GstQuery *query;
   GstBufferPool *pool = NULL;
   guint size, min, max, prefix, alignment;
@@ -262,14 +262,16 @@ gst_goom_src_negotiate (GstGoom * goom)
   othercaps = gst_pad_peer_query_caps (goom->srcpad, NULL);
   if (othercaps) {
     target = gst_caps_intersect (othercaps, templ);
+    gst_caps_unref (templ);
     gst_caps_unref (othercaps);
 
     if (gst_caps_is_empty (target))
       goto no_format;
 
+    target = gst_caps_make_writable (target);
     gst_caps_truncate (target);
   } else {
-    target = gst_caps_ref ((GstCaps *) templ);
+    target = gst_caps_copy (templ);
   }
 
   structure = gst_caps_get_structure (target, 0);
index 8393983..c9a8de4 100644 (file)
@@ -150,7 +150,7 @@ gst_alaw_dec_getcaps (GstPad * pad, GstCaps * filter)
   GstALawDec *alawdec;
   GstPad *otherpad;
   GstCaps *othercaps, *result;
-  const GstCaps *templ;
+  GstCaps *templ;
   const gchar *name;
   gint i;
 
@@ -195,9 +195,10 @@ gst_alaw_dec_getcaps (GstPad * pad, GstCaps * filter)
     /* filter against the allowed caps of the pad to return our result */
     result = gst_caps_intersect (othercaps, templ);
     gst_caps_unref (othercaps);
+    gst_caps_unref (templ);
   } else {
     /* there was no peer, return the template caps */
-    result = gst_caps_copy (templ);
+    result = templ;
   }
   if (filter && result) {
     GstCaps *temp;
index 104a896..266f24b 100644 (file)
@@ -306,7 +306,7 @@ gst_alaw_enc_getcaps (GstPad * pad, GstCaps * filter)
   GstALawEnc *alawenc;
   GstPad *otherpad;
   GstCaps *othercaps, *result;
-  const GstCaps *templ;
+  GstCaps *templ;
   const gchar *name;
   gint i;
 
@@ -350,10 +350,11 @@ gst_alaw_enc_getcaps (GstPad * pad, GstCaps * filter)
     }
     /* filter against the allowed caps of the pad to return our result */
     result = gst_caps_intersect (othercaps, templ);
+    gst_caps_unref (templ);
     gst_caps_unref (othercaps);
   } else {
     /* there was no peer, return the template caps */
-    result = gst_caps_copy (templ);
+    result = templ;
   }
   if (filter && result) {
     GstCaps *temp;
index aac2c49..82e5b56 100644 (file)
@@ -91,7 +91,7 @@ mulawdec_getcaps (GstPad * pad, GstCaps * filter)
   GstMuLawDec *mulawdec;
   GstPad *otherpad;
   GstCaps *othercaps, *result;
-  const GstCaps *templ;
+  GstCaps *templ;
   const gchar *name;
   gint i;
 
@@ -136,9 +136,10 @@ mulawdec_getcaps (GstPad * pad, GstCaps * filter)
     /* filter against the allowed caps of the pad to return our result */
     result = gst_caps_intersect (othercaps, templ);
     gst_caps_unref (othercaps);
+    gst_caps_unref (templ);
   } else {
     /* there was no peer, return the template caps */
-    result = gst_caps_copy (templ);
+    result = templ;
   }
   if (filter && result) {
     GstCaps *temp;
index 7db18b1..fc228d9 100644 (file)
@@ -62,7 +62,7 @@ mulawenc_getcaps (GstPad * pad, GstCaps * filter)
   GstMuLawEnc *mulawenc;
   GstPad *otherpad;
   GstCaps *othercaps, *result;
-  const GstCaps *templ;
+  GstCaps *templ;
   const gchar *name;
   gint i;
 
@@ -107,9 +107,10 @@ mulawenc_getcaps (GstPad * pad, GstCaps * filter)
     /* filter against the allowed caps of the pad to return our result */
     result = gst_caps_intersect (othercaps, templ);
     gst_caps_unref (othercaps);
+    gst_caps_unref (templ);
   } else {
     /* there was no peer, return the template caps */
-    result = gst_caps_copy (templ);
+    result = templ;
   }
   if (filter && result) {
     GstCaps *temp;