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>
 
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnome_vfs_sink_class_init):
......
......@@ -231,18 +231,20 @@ gst_visual_getcaps (GstPad * pad)
GstVisual *visual = GST_VISUAL (gst_pad_get_parent (pad));
int depths;
if (!visual->actor)
return gst_caps_copy (gst_pad_get_pad_template_caps (visual->srcpad));
if (!visual->actor) {
ret = gst_caps_copy (gst_pad_get_pad_template_caps (visual->srcpad));
goto beach;
}
ret = gst_caps_new_empty ();
depths = visual_actor_get_supported_depth (visual->actor);
if (depths < 0) {
/* FIXME: set an error */
return ret;
goto beach;
}
if (depths == VISUAL_VIDEO_DEPTH_GL) {
/* We can't handle GL only plugins */
return ret;
goto beach;
}
GST_DEBUG_OBJECT (visual, "libvisual plugin supports depths %u (0x%04x)",
......@@ -261,7 +263,10 @@ gst_visual_getcaps (GstPad * pad)
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_object_unref (visual);
return ret;
}
......@@ -277,21 +282,28 @@ gst_visual_src_setcaps (GstPad * pad, GstCaps * caps)
GST_DEBUG_OBJECT (visual, "src pad got caps %" GST_PTR_FORMAT, caps);
if (!gst_structure_get_int (structure, "width", &visual->width))
return FALSE;
goto error;
if (!gst_structure_get_int (structure, "height", &visual->height))
return FALSE;
goto error;
if (!gst_structure_get_int (structure, "bpp", &depth))
return FALSE;
goto error;
if (!gst_structure_get_fraction (structure, "framerate", &visual->fps_n,
&visual->fps_d))
return FALSE;
goto error;
visual_video_set_depth (visual->video,
visual_video_depth_enum_from_value (depth));
visual_video_set_dimension (visual->video, visual->width, visual->height);
visual_actor_video_negotiate (visual->actor, 0, FALSE, FALSE);
gst_object_unref (visual);
return TRUE;
error:
{
gst_object_unref (visual);
return FALSE;
}
}
static gboolean
......@@ -304,6 +316,7 @@ gst_visual_sink_setcaps (GstPad * pad, GstCaps * caps)
gst_structure_get_int (structure, "rate", &visual->rate);
gst_object_unref (visual);
return TRUE;
}
......
......@@ -332,15 +332,12 @@ static GstPadLinkReturn
gst_ogg_mux_sinkconnect (GstPad * pad, GstPad * peer)
{
GstOggMux *ogg_mux;
gchar *name;
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);
g_free (name);
gst_object_unref (ogg_mux);
return GST_PAD_LINK_OK;
}
......
......@@ -309,8 +309,10 @@ gst_vorbisenc_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value,
vorbisenc = GST_VORBISENC (gst_pad_get_parent (pad));
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;
}
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,
default:
res = FALSE;
}
gst_object_unref (vorbisenc);
return res;
}
......@@ -407,6 +410,7 @@ gst_vorbisenc_convert_sink (GstPad * pad, GstFormat src_format,
default:
res = FALSE;
}
gst_object_unref (vorbisenc);
return res;
}
......
......@@ -47,7 +47,7 @@ gst_audio_frame_byte_size (GstPad * pad)
if (caps == NULL) {
/* ERROR: could not get caps of pad */
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;
}
......@@ -102,7 +102,7 @@ gst_audio_duration_from_pad_buffer (GstPad * pad, GstBuffer * buf)
if (caps == NULL) {
/* ERROR: could not get caps of pad */
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;
} else {
structure = gst_caps_get_structure (caps, 0);
......
......@@ -136,6 +136,7 @@ gst_audio_filter_link (GstPad * pad, GstPad * peer)
}
if (GST_PAD_LINK_FAILED (link_ret)) {
gst_object_unref (audiofilter);
return link_ret;
}
......@@ -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, "channels", &audiofilter->channels);
if (!ret)
if (!ret) {
gst_object_unref (audiofilter);
return GST_PAD_LINK_REFUSED;
}
audiofilter->bytes_per_sample = (audiofilter->width / 8) *
audiofilter->channels;
......@@ -163,6 +166,7 @@ gst_audio_filter_link (GstPad * pad, GstPad * peer)
(audio_filter_class->setup) (audiofilter);
#endif
gst_object_unref (audiofilter);
return GST_PAD_LINK_OK;
}
......@@ -209,7 +213,7 @@ gst_audio_filter_chain (GstPad * pad, GstBuffer * buffer)
g_return_val_if_fail (inbuf != NULL, GST_FLOW_ERROR);
audiofilter = GST_AUDIO_FILTER (gst_pad_get_parent (pad));
//g_return_if_fail (audiofilter->inited);
/* g_return_if_fail (audiofilter->inited); */
audio_filter_class =
GST_AUDIO_FILTER_CLASS (G_OBJECT_GET_CLASS (audiofilter));
......@@ -218,6 +222,7 @@ gst_audio_filter_chain (GstPad * pad, GstBuffer * buffer)
if (audiofilter->passthru) {
gst_pad_push (audiofilter->srcpad, buffer);
gst_object_unref (audiofilter);
return GST_FLOW_OK;
}
......@@ -253,6 +258,7 @@ gst_audio_filter_chain (GstPad * pad, GstBuffer * buffer)
gst_pad_push (audiofilter->srcpad, outbuf);
gst_object_unref (audiofilter);
return GST_FLOW_OK;
}
......
......@@ -175,6 +175,7 @@ gst_base_rtp_depayload_setcaps (GstPad * pad, GstCaps * caps)
{
GstBaseRTPDepayload *filter;
GstBaseRTPDepayloadClass *bclass;
gboolean res;
filter = GST_BASE_RTP_DEPAYLOAD (gst_pad_get_parent (pad));
g_return_val_if_fail (filter != NULL, FALSE);
......@@ -183,9 +184,12 @@ gst_base_rtp_depayload_setcaps (GstPad * pad, GstCaps * caps)
bclass = GST_BASE_RTP_DEPAYLOAD_GET_CLASS (filter);
if (bclass->set_caps)
return bclass->set_caps (filter, caps);
res = bclass->set_caps (filter, caps);
else
return TRUE;
res = TRUE;
gst_object_unref (filter);
return res;
}
static GstFlowReturn
......
......@@ -38,27 +38,26 @@ gst_video_frame_rate (GstPad * pad)
caps = GST_PAD_CAPS (pad);
if (caps == NULL) {
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;
}
structure = gst_caps_get_structure (caps, 0);
if ((fps = gst_structure_get_value (structure, "framerate")) == NULL) {
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;
}
if (!GST_VALUE_HOLDS_FRACTION (fps)) {
g_warning
("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;
}
fps_string = gst_value_serialize (fps);
GST_DEBUG ("Framerate request on pad %s:%s: %s",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad),
fps_string);
GST_DEBUG_PAD_NAME (pad), fps_string);
g_free (fps_string);
return fps;
......@@ -79,7 +78,7 @@ gst_video_get_size (GstPad * pad, gint * width, gint * height)
if (caps == NULL) {
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;
}
......@@ -89,13 +88,12 @@ gst_video_get_size (GstPad * pad, gint * width, gint * height)
if (!ret) {
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;
}
GST_DEBUG ("size request on pad %s:%s: %dx%d",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)),
GST_PAD_NAME (pad), width ? *width : -1, height ? *height : -1);
GST_DEBUG_PAD_NAME (pad), width ? *width : -1, height ? *height : -1);
return TRUE;
}
......@@ -197,7 +197,8 @@ gst_audio_rate_setcaps (GstPad * pad, GstCaps * caps)
GstAudioRate *audiorate;
GstStructure *structure;
GstPad *otherpad;
gint ret, channels, width;
gboolean ret = FALSE;
gint channels, width;
audiorate = GST_AUDIO_RATE (gst_pad_get_parent (pad));
......@@ -205,21 +206,23 @@ gst_audio_rate_setcaps (GstPad * pad, GstCaps * caps)
audiorate->srcpad;
if (!gst_pad_set_caps (otherpad, caps))
return FALSE;
goto beach;
structure = gst_caps_get_structure (caps, 0);
ret = gst_structure_get_int (structure, "channels", &channels);
ret &= gst_structure_get_int (structure, "width", &width);
if (!ret)
return FALSE;
if (!gst_structure_get_int (structure, "channels", &channels) ||
!gst_structure_get_int (structure, "width", &width)) {
goto beach;
}
audiorate->bytes_per_sample = channels * (width / 8);
if (audiorate->bytes_per_sample == 0)
audiorate->bytes_per_sample = 1;
ret = TRUE;
return TRUE;
beach:
gst_object_unref (audiorate);
return ret;
}
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