Commit 8e6d3a5c authored by Christophe Fergeau's avatar Christophe Fergeau Committed by Tim-Philipp Müller
Browse files

Don't leak references returned by gst_pad_get_parent()

Original commit message from CVS:
* ext/libvisual/visual.c: (gst_visual_getcaps),
(gst_visual_src_setcaps), (gst_visual_sink_setcaps):
* ext/ogg/gstoggmux.c: (gst_ogg_mux_sinkconnect):
* ext/vorbis/vorbisenc.c: (gst_vorbisenc_convert_src),
(gst_vorbisenc_convert_sink):
* gst-libs/gst/audio/audio.c: (gst_audio_frame_byte_size),
(gst_audio_duration_from_pad_buffer):
* gst-libs/gst/audio/gstaudiofilter.c: (gst_audio_filter_link),
(gst_audio_filter_chain):
* gst-libs/gst/rtp/gstbasertpdepayload.c:
(gst_base_rtp_depayload_setcaps):
* gst-libs/gst/video/video.c: (gst_video_frame_rate),
(gst_video_get_size):
* gst/audiorate/gstaudiorate.c: (gst_audio_rate_setcaps):
Don't leak references returned by gst_pad_get_parent()
(#333663, based on patch by: Christophe Fergeau).
parent 4a65e3ee
2006-03-07 Tim-Philipp Müller <tim at centricular dot net>
* ext/libvisual/visual.c: (gst_visual_getcaps),
(gst_visual_src_setcaps), (gst_visual_sink_setcaps):
* ext/ogg/gstoggmux.c: (gst_ogg_mux_sinkconnect):
* ext/vorbis/vorbisenc.c: (gst_vorbisenc_convert_src),
(gst_vorbisenc_convert_sink):
* gst-libs/gst/audio/audio.c: (gst_audio_frame_byte_size),
(gst_audio_duration_from_pad_buffer):
* gst-libs/gst/audio/gstaudiofilter.c: (gst_audio_filter_link),
(gst_audio_filter_chain):
* gst-libs/gst/rtp/gstbasertpdepayload.c:
(gst_base_rtp_depayload_setcaps):
* gst-libs/gst/video/video.c: (gst_video_frame_rate),
(gst_video_get_size):
* gst/audiorate/gstaudiorate.c: (gst_audio_rate_setcaps):
Don't leak references returned by gst_pad_get_parent()
(#333663, based on patch by: Christophe Fergeau).
2006-03-06 Stefan Kost <ensonic@users.sf.net> 2006-03-06 Stefan Kost <ensonic@users.sf.net>
   
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnome_vfs_sink_class_init): * ext/gnomevfs/gstgnomevfssink.c: (gst_gnome_vfs_sink_class_init):
......
...@@ -231,18 +231,20 @@ gst_visual_getcaps (GstPad * pad) ...@@ -231,18 +231,20 @@ gst_visual_getcaps (GstPad * pad)
GstVisual *visual = GST_VISUAL (gst_pad_get_parent (pad)); GstVisual *visual = GST_VISUAL (gst_pad_get_parent (pad));
int depths; int depths;
if (!visual->actor) if (!visual->actor) {
return gst_caps_copy (gst_pad_get_pad_template_caps (visual->srcpad)); ret = gst_caps_copy (gst_pad_get_pad_template_caps (visual->srcpad));
goto beach;
}
ret = gst_caps_new_empty (); ret = gst_caps_new_empty ();
depths = visual_actor_get_supported_depth (visual->actor); depths = visual_actor_get_supported_depth (visual->actor);
if (depths < 0) { if (depths < 0) {
/* FIXME: set an error */ /* FIXME: set an error */
return ret; goto beach;
} }
if (depths == VISUAL_VIDEO_DEPTH_GL) { if (depths == VISUAL_VIDEO_DEPTH_GL) {
/* We can't handle GL only plugins */ /* We can't handle GL only plugins */
return ret; goto beach;
} }
GST_DEBUG_OBJECT (visual, "libvisual plugin supports depths %u (0x%04x)", GST_DEBUG_OBJECT (visual, "libvisual plugin supports depths %u (0x%04x)",
...@@ -261,7 +263,10 @@ gst_visual_getcaps (GstPad * pad) ...@@ -261,7 +263,10 @@ gst_visual_getcaps (GstPad * pad)
gst_caps_append (ret, gst_caps_from_string (GST_VIDEO_CAPS_RGB_16)); gst_caps_append (ret, gst_caps_from_string (GST_VIDEO_CAPS_RGB_16));
} }
beach:
GST_DEBUG_OBJECT (visual, "returning caps %" GST_PTR_FORMAT, ret); GST_DEBUG_OBJECT (visual, "returning caps %" GST_PTR_FORMAT, ret);
gst_object_unref (visual);
return ret; return ret;
} }
...@@ -277,21 +282,28 @@ gst_visual_src_setcaps (GstPad * pad, GstCaps * caps) ...@@ -277,21 +282,28 @@ gst_visual_src_setcaps (GstPad * pad, GstCaps * caps)
GST_DEBUG_OBJECT (visual, "src pad got caps %" GST_PTR_FORMAT, caps); GST_DEBUG_OBJECT (visual, "src pad got caps %" GST_PTR_FORMAT, caps);
if (!gst_structure_get_int (structure, "width", &visual->width)) if (!gst_structure_get_int (structure, "width", &visual->width))
return FALSE; goto error;
if (!gst_structure_get_int (structure, "height", &visual->height)) if (!gst_structure_get_int (structure, "height", &visual->height))
return FALSE; goto error;
if (!gst_structure_get_int (structure, "bpp", &depth)) if (!gst_structure_get_int (structure, "bpp", &depth))
return FALSE; goto error;
if (!gst_structure_get_fraction (structure, "framerate", &visual->fps_n, if (!gst_structure_get_fraction (structure, "framerate", &visual->fps_n,
&visual->fps_d)) &visual->fps_d))
return FALSE; goto error;
visual_video_set_depth (visual->video, visual_video_set_depth (visual->video,
visual_video_depth_enum_from_value (depth)); visual_video_depth_enum_from_value (depth));
visual_video_set_dimension (visual->video, visual->width, visual->height); visual_video_set_dimension (visual->video, visual->width, visual->height);
visual_actor_video_negotiate (visual->actor, 0, FALSE, FALSE); visual_actor_video_negotiate (visual->actor, 0, FALSE, FALSE);
gst_object_unref (visual);
return TRUE; return TRUE;
error:
{
gst_object_unref (visual);
return FALSE;
}
} }
static gboolean static gboolean
...@@ -304,6 +316,7 @@ gst_visual_sink_setcaps (GstPad * pad, GstCaps * caps) ...@@ -304,6 +316,7 @@ gst_visual_sink_setcaps (GstPad * pad, GstCaps * caps)
gst_structure_get_int (structure, "rate", &visual->rate); gst_structure_get_int (structure, "rate", &visual->rate);
gst_object_unref (visual);
return TRUE; return TRUE;
} }
......
...@@ -332,15 +332,12 @@ static GstPadLinkReturn ...@@ -332,15 +332,12 @@ static GstPadLinkReturn
gst_ogg_mux_sinkconnect (GstPad * pad, GstPad * peer) gst_ogg_mux_sinkconnect (GstPad * pad, GstPad * peer)
{ {
GstOggMux *ogg_mux; GstOggMux *ogg_mux;
gchar *name;
ogg_mux = GST_OGG_MUX (gst_pad_get_parent (pad)); ogg_mux = GST_OGG_MUX (gst_pad_get_parent (pad));
name = gst_pad_get_name (pad); GST_DEBUG_OBJECT (ogg_mux, "sinkconnect triggered on %s", GST_PAD_NAME (pad));
GST_DEBUG_OBJECT (ogg_mux, "sinkconnect triggered on %s", name); gst_object_unref (ogg_mux);
g_free (name);
return GST_PAD_LINK_OK; return GST_PAD_LINK_OK;
} }
......
...@@ -309,8 +309,10 @@ gst_vorbisenc_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value, ...@@ -309,8 +309,10 @@ gst_vorbisenc_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value,
vorbisenc = GST_VORBISENC (gst_pad_get_parent (pad)); vorbisenc = GST_VORBISENC (gst_pad_get_parent (pad));
if (vorbisenc->samples_in == 0 || if (vorbisenc->samples_in == 0 ||
vorbisenc->bytes_out == 0 || vorbisenc->frequency == 0) vorbisenc->bytes_out == 0 || vorbisenc->frequency == 0) {
gst_object_unref (vorbisenc);
return FALSE; return FALSE;
}
avg = (vorbisenc->bytes_out * vorbisenc->frequency) / (vorbisenc->samples_in); avg = (vorbisenc->bytes_out * vorbisenc->frequency) / (vorbisenc->samples_in);
...@@ -336,6 +338,7 @@ gst_vorbisenc_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value, ...@@ -336,6 +338,7 @@ gst_vorbisenc_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value,
default: default:
res = FALSE; res = FALSE;
} }
gst_object_unref (vorbisenc);
return res; return res;
} }
...@@ -407,6 +410,7 @@ gst_vorbisenc_convert_sink (GstPad * pad, GstFormat src_format, ...@@ -407,6 +410,7 @@ gst_vorbisenc_convert_sink (GstPad * pad, GstFormat src_format,
default: default:
res = FALSE; res = FALSE;
} }
gst_object_unref (vorbisenc);
return res; return res;
} }
......
...@@ -47,7 +47,7 @@ gst_audio_frame_byte_size (GstPad * pad) ...@@ -47,7 +47,7 @@ gst_audio_frame_byte_size (GstPad * pad)
if (caps == NULL) { if (caps == NULL) {
/* ERROR: could not get caps of pad */ /* ERROR: could not get caps of pad */
g_warning ("gstaudio: could not get caps of pad %s:%s\n", g_warning ("gstaudio: could not get caps of pad %s:%s\n",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
return 0; return 0;
} }
...@@ -102,7 +102,7 @@ gst_audio_duration_from_pad_buffer (GstPad * pad, GstBuffer * buf) ...@@ -102,7 +102,7 @@ gst_audio_duration_from_pad_buffer (GstPad * pad, GstBuffer * buf)
if (caps == NULL) { if (caps == NULL) {
/* ERROR: could not get caps of pad */ /* ERROR: could not get caps of pad */
g_warning ("gstaudio: could not get caps of pad %s:%s\n", g_warning ("gstaudio: could not get caps of pad %s:%s\n",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
length = GST_CLOCK_TIME_NONE; length = GST_CLOCK_TIME_NONE;
} else { } else {
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
......
...@@ -136,6 +136,7 @@ gst_audio_filter_link (GstPad * pad, GstPad * peer) ...@@ -136,6 +136,7 @@ gst_audio_filter_link (GstPad * pad, GstPad * peer)
} }
if (GST_PAD_LINK_FAILED (link_ret)) { if (GST_PAD_LINK_FAILED (link_ret)) {
gst_object_unref (audiofilter);
return link_ret; return link_ret;
} }
...@@ -153,8 +154,10 @@ gst_audio_filter_link (GstPad * pad, GstPad * peer) ...@@ -153,8 +154,10 @@ gst_audio_filter_link (GstPad * pad, GstPad * peer)
ret &= gst_structure_get_int (structure, "rate", &audiofilter->rate); ret &= gst_structure_get_int (structure, "rate", &audiofilter->rate);
ret &= gst_structure_get_int (structure, "channels", &audiofilter->channels); ret &= gst_structure_get_int (structure, "channels", &audiofilter->channels);
if (!ret) if (!ret) {
gst_object_unref (audiofilter);
return GST_PAD_LINK_REFUSED; return GST_PAD_LINK_REFUSED;
}
audiofilter->bytes_per_sample = (audiofilter->width / 8) * audiofilter->bytes_per_sample = (audiofilter->width / 8) *
audiofilter->channels; audiofilter->channels;
...@@ -163,6 +166,7 @@ gst_audio_filter_link (GstPad * pad, GstPad * peer) ...@@ -163,6 +166,7 @@ gst_audio_filter_link (GstPad * pad, GstPad * peer)
(audio_filter_class->setup) (audiofilter); (audio_filter_class->setup) (audiofilter);
#endif #endif
gst_object_unref (audiofilter);
return GST_PAD_LINK_OK; return GST_PAD_LINK_OK;
} }
...@@ -209,7 +213,7 @@ gst_audio_filter_chain (GstPad * pad, GstBuffer * buffer) ...@@ -209,7 +213,7 @@ gst_audio_filter_chain (GstPad * pad, GstBuffer * buffer)
g_return_val_if_fail (inbuf != NULL, GST_FLOW_ERROR); g_return_val_if_fail (inbuf != NULL, GST_FLOW_ERROR);
audiofilter = GST_AUDIO_FILTER (gst_pad_get_parent (pad)); audiofilter = GST_AUDIO_FILTER (gst_pad_get_parent (pad));
//g_return_if_fail (audiofilter->inited); /* g_return_if_fail (audiofilter->inited); */
audio_filter_class = audio_filter_class =
GST_AUDIO_FILTER_CLASS (G_OBJECT_GET_CLASS (audiofilter)); GST_AUDIO_FILTER_CLASS (G_OBJECT_GET_CLASS (audiofilter));
...@@ -218,6 +222,7 @@ gst_audio_filter_chain (GstPad * pad, GstBuffer * buffer) ...@@ -218,6 +222,7 @@ gst_audio_filter_chain (GstPad * pad, GstBuffer * buffer)
if (audiofilter->passthru) { if (audiofilter->passthru) {
gst_pad_push (audiofilter->srcpad, buffer); gst_pad_push (audiofilter->srcpad, buffer);
gst_object_unref (audiofilter);
return GST_FLOW_OK; return GST_FLOW_OK;
} }
...@@ -253,6 +258,7 @@ gst_audio_filter_chain (GstPad * pad, GstBuffer * buffer) ...@@ -253,6 +258,7 @@ gst_audio_filter_chain (GstPad * pad, GstBuffer * buffer)
gst_pad_push (audiofilter->srcpad, outbuf); gst_pad_push (audiofilter->srcpad, outbuf);
gst_object_unref (audiofilter);
return GST_FLOW_OK; return GST_FLOW_OK;
} }
......
...@@ -175,6 +175,7 @@ gst_base_rtp_depayload_setcaps (GstPad * pad, GstCaps * caps) ...@@ -175,6 +175,7 @@ gst_base_rtp_depayload_setcaps (GstPad * pad, GstCaps * caps)
{ {
GstBaseRTPDepayload *filter; GstBaseRTPDepayload *filter;
GstBaseRTPDepayloadClass *bclass; GstBaseRTPDepayloadClass *bclass;
gboolean res;
filter = GST_BASE_RTP_DEPAYLOAD (gst_pad_get_parent (pad)); filter = GST_BASE_RTP_DEPAYLOAD (gst_pad_get_parent (pad));
g_return_val_if_fail (filter != NULL, FALSE); g_return_val_if_fail (filter != NULL, FALSE);
...@@ -183,9 +184,12 @@ gst_base_rtp_depayload_setcaps (GstPad * pad, GstCaps * caps) ...@@ -183,9 +184,12 @@ gst_base_rtp_depayload_setcaps (GstPad * pad, GstCaps * caps)
bclass = GST_BASE_RTP_DEPAYLOAD_GET_CLASS (filter); bclass = GST_BASE_RTP_DEPAYLOAD_GET_CLASS (filter);
if (bclass->set_caps) if (bclass->set_caps)
return bclass->set_caps (filter, caps); res = bclass->set_caps (filter, caps);
else else
return TRUE; res = TRUE;
gst_object_unref (filter);
return res;
} }
static GstFlowReturn static GstFlowReturn
......
...@@ -38,27 +38,26 @@ gst_video_frame_rate (GstPad * pad) ...@@ -38,27 +38,26 @@ gst_video_frame_rate (GstPad * pad)
caps = GST_PAD_CAPS (pad); caps = GST_PAD_CAPS (pad);
if (caps == NULL) { if (caps == NULL) {
g_warning ("gstvideo: failed to get caps of pad %s:%s", g_warning ("gstvideo: failed to get caps of pad %s:%s",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
return NULL; return NULL;
} }
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
if ((fps = gst_structure_get_value (structure, "framerate")) == NULL) { if ((fps = gst_structure_get_value (structure, "framerate")) == NULL) {
g_warning ("gstvideo: failed to get framerate property of pad %s:%s", g_warning ("gstvideo: failed to get framerate property of pad %s:%s",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
return NULL; return NULL;
} }
if (!GST_VALUE_HOLDS_FRACTION (fps)) { if (!GST_VALUE_HOLDS_FRACTION (fps)) {
g_warning g_warning
("gstvideo: framerate property of pad %s:%s is not of type Fraction", ("gstvideo: framerate property of pad %s:%s is not of type Fraction",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
return NULL; return NULL;
} }
fps_string = gst_value_serialize (fps); fps_string = gst_value_serialize (fps);
GST_DEBUG ("Framerate request on pad %s:%s: %s", GST_DEBUG ("Framerate request on pad %s:%s: %s",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad), GST_DEBUG_PAD_NAME (pad), fps_string);
fps_string);
g_free (fps_string); g_free (fps_string);
return fps; return fps;
...@@ -79,7 +78,7 @@ gst_video_get_size (GstPad * pad, gint * width, gint * height) ...@@ -79,7 +78,7 @@ gst_video_get_size (GstPad * pad, gint * width, gint * height)
if (caps == NULL) { if (caps == NULL) {
g_warning ("gstvideo: failed to get caps of pad %s:%s", g_warning ("gstvideo: failed to get caps of pad %s:%s",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
return FALSE; return FALSE;
} }
...@@ -89,13 +88,12 @@ gst_video_get_size (GstPad * pad, gint * width, gint * height) ...@@ -89,13 +88,12 @@ gst_video_get_size (GstPad * pad, gint * width, gint * height)
if (!ret) { if (!ret) {
g_warning ("gstvideo: failed to get size properties on pad %s:%s", g_warning ("gstvideo: failed to get size properties on pad %s:%s",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
return FALSE; return FALSE;
} }
GST_DEBUG ("size request on pad %s:%s: %dx%d", GST_DEBUG ("size request on pad %s:%s: %dx%d",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_DEBUG_PAD_NAME (pad), width ? *width : -1, height ? *height : -1);
GST_PAD_NAME (pad), width ? *width : -1, height ? *height : -1);
return TRUE; return TRUE;
} }
...@@ -197,7 +197,8 @@ gst_audio_rate_setcaps (GstPad * pad, GstCaps * caps) ...@@ -197,7 +197,8 @@ gst_audio_rate_setcaps (GstPad * pad, GstCaps * caps)
GstAudioRate *audiorate; GstAudioRate *audiorate;
GstStructure *structure; GstStructure *structure;
GstPad *otherpad; GstPad *otherpad;
gint ret, channels, width; gboolean ret = FALSE;
gint channels, width;
audiorate = GST_AUDIO_RATE (gst_pad_get_parent (pad)); audiorate = GST_AUDIO_RATE (gst_pad_get_parent (pad));
...@@ -205,21 +206,23 @@ gst_audio_rate_setcaps (GstPad * pad, GstCaps * caps) ...@@ -205,21 +206,23 @@ gst_audio_rate_setcaps (GstPad * pad, GstCaps * caps)
audiorate->srcpad; audiorate->srcpad;
if (!gst_pad_set_caps (otherpad, caps)) if (!gst_pad_set_caps (otherpad, caps))
return FALSE; goto beach;
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
ret = gst_structure_get_int (structure, "channels", &channels); if (!gst_structure_get_int (structure, "channels", &channels) ||
ret &= gst_structure_get_int (structure, "width", &width); !gst_structure_get_int (structure, "width", &width)) {
goto beach;
if (!ret) }
return FALSE;
audiorate->bytes_per_sample = channels * (width / 8); audiorate->bytes_per_sample = channels * (width / 8);
if (audiorate->bytes_per_sample == 0) if (audiorate->bytes_per_sample == 0)
audiorate->bytes_per_sample = 1; audiorate->bytes_per_sample = 1;
ret = TRUE;
return TRUE; beach:
gst_object_unref (audiorate);
return ret;
} }
static void static void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment