From 756948262c8bc596149eda346517e289f914a8a8 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sat, 10 Mar 2012 10:51:44 +0100 Subject: [PATCH] fix template caps refcount --- ext/jpeg/gstjpegdec.c | 8 +++++--- gst/alpha/gstalphacolor.c | 3 ++- gst/audioparsers/gstaacparse.c | 15 ++++++--------- gst/audioparsers/gstac3parse.c | 16 ++++++---------- gst/audioparsers/gstamrparse.c | 14 ++++++-------- gst/audioparsers/gstdcaparse.c | 13 +++++-------- gst/audioparsers/gstflacparse.c | 13 +++++-------- gst/audioparsers/gstmpegaudioparse.c | 13 +++++-------- gst/audioparsers/gstwavpackparse.c | 13 +++++-------- gst/auparse/gstauparse.c | 3 ++- gst/goom2k1/gstgoom.c | 6 ++++-- gst/law/alaw-decode.c | 5 +++-- gst/law/alaw-encode.c | 5 +++-- gst/law/mulaw-decode.c | 5 +++-- gst/law/mulaw-encode.c | 5 +++-- 15 files changed, 63 insertions(+), 74 deletions(-) diff --git a/ext/jpeg/gstjpegdec.c b/ext/jpeg/gstjpegdec.c index 4e071e1..a723f35 100644 --- a/ext/jpeg/gstjpegdec.c +++ b/ext/jpeg/gstjpegdec.c @@ -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; diff --git a/gst/alpha/gstalphacolor.c b/gst/alpha/gstalphacolor.c index 3a79eed..cdacf0a 100644 --- a/gst/alpha/gstalphacolor.c +++ b/gst/alpha/gstalphacolor.c @@ -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); diff --git a/gst/audioparsers/gstaacparse.c b/gst/audioparsers/gstaacparse.c index 79633c4..15a8be7 100644 --- a/gst/audioparsers/gstaacparse.c +++ b/gst/audioparsers/gstaacparse.c @@ -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; diff --git a/gst/audioparsers/gstac3parse.c b/gst/audioparsers/gstac3parse.c index f88972f..d5d8551 100644 --- a/gst/audioparsers/gstac3parse.c +++ b/gst/audioparsers/gstac3parse.c @@ -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; diff --git a/gst/audioparsers/gstamrparse.c b/gst/audioparsers/gstamrparse.c index 28e64db..bf8f37e 100644 --- a/gst/audioparsers/gstamrparse.c +++ b/gst/audioparsers/gstamrparse.c @@ -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; diff --git a/gst/audioparsers/gstdcaparse.c b/gst/audioparsers/gstdcaparse.c index b1e256b..42565c2 100644 --- a/gst/audioparsers/gstdcaparse.c +++ b/gst/audioparsers/gstdcaparse.c @@ -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; diff --git a/gst/audioparsers/gstflacparse.c b/gst/audioparsers/gstflacparse.c index 06a964e..f5ad169 100644 --- a/gst/audioparsers/gstflacparse.c +++ b/gst/audioparsers/gstflacparse.c @@ -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; diff --git a/gst/audioparsers/gstmpegaudioparse.c b/gst/audioparsers/gstmpegaudioparse.c index f8987bf..1d5d276 100644 --- a/gst/audioparsers/gstmpegaudioparse.c +++ b/gst/audioparsers/gstmpegaudioparse.c @@ -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; diff --git a/gst/audioparsers/gstwavpackparse.c b/gst/audioparsers/gstwavpackparse.c index 637198d..875c03a 100644 --- a/gst/audioparsers/gstwavpackparse.c +++ b/gst/audioparsers/gstwavpackparse.c @@ -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; diff --git a/gst/auparse/gstauparse.c b/gst/auparse/gstauparse.c index 5c3170c..91c4f91 100644 --- a/gst/auparse/gstauparse.c +++ b/gst/auparse/gstauparse.c @@ -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", diff --git a/gst/goom2k1/gstgoom.c b/gst/goom2k1/gstgoom.c index 96c11e5..ae78d97 100644 --- a/gst/goom2k1/gstgoom.c +++ b/gst/goom2k1/gstgoom.c @@ -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); diff --git a/gst/law/alaw-decode.c b/gst/law/alaw-decode.c index 8393983..c9a8de4 100644 --- a/gst/law/alaw-decode.c +++ b/gst/law/alaw-decode.c @@ -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; diff --git a/gst/law/alaw-encode.c b/gst/law/alaw-encode.c index 104a896..266f24b 100644 --- a/gst/law/alaw-encode.c +++ b/gst/law/alaw-encode.c @@ -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; diff --git a/gst/law/mulaw-decode.c b/gst/law/mulaw-decode.c index aac2c49..82e5b56 100644 --- a/gst/law/mulaw-decode.c +++ b/gst/law/mulaw-decode.c @@ -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; diff --git a/gst/law/mulaw-encode.c b/gst/law/mulaw-encode.c index 7db18b1..fc228d9 100644 --- a/gst/law/mulaw-encode.c +++ b/gst/law/mulaw-encode.c @@ -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; -- 2.7.4