Commit 24e21ae6 authored by Sebastian Dröge's avatar Sebastian Dröge
Browse files

ext/gconf/: When we can't create a fakesink/fakesrc complain instead of unreffing

Original commit message from CVS:
* ext/gconf/gstgconfaudiosrc.c: (gst_gconf_audio_src_reset),
(gst_gconf_audio_src_change_state):
* ext/gconf/gstgconfvideosink.c: (gst_gconf_video_sink_reset),
(gst_gconf_video_sink_change_state):
* ext/gconf/gstgconfvideosrc.c: (gst_gconf_video_src_reset),
(gst_gconf_video_src_change_state):
* ext/gconf/gstswitchsink.c: (gst_switch_sink_reset),
(gst_switch_commit_new_kid), (gst_switch_sink_change_state):
When we can't create a fakesink/fakesrc complain instead of unreffing
NULL pointers and crashing later. See bug #530535.
parent 34f916ab
2008-05-03 Sebastian Dröge <slomo@circular-chaos.org>
* ext/gconf/gstgconfaudiosrc.c: (gst_gconf_audio_src_reset),
(gst_gconf_audio_src_change_state):
* ext/gconf/gstgconfvideosink.c: (gst_gconf_video_sink_reset),
(gst_gconf_video_sink_change_state):
* ext/gconf/gstgconfvideosrc.c: (gst_gconf_video_src_reset),
(gst_gconf_video_src_change_state):
* ext/gconf/gstswitchsink.c: (gst_switch_sink_reset),
(gst_switch_commit_new_kid), (gst_switch_sink_change_state):
When we can't create a fakesink/fakesrc complain instead of unreffing
NULL pointers and crashing later. See bug #530535.
2008-05-02 Wim Taymans <wim.taymans@collabora.co.uk>
 
* gst/rtp/gstrtph263pdepay.c: (gst_rtp_h263p_depay_process):
......
......@@ -71,7 +71,7 @@ gst_gconf_audio_src_class_init (GstGConfAudioSrcClass * klass)
* Hack to make negotiation work.
*/
static void
static gboolean
gst_gconf_audio_src_reset (GstGConfAudioSrc * src)
{
GstPad *targetpad;
......@@ -82,6 +82,10 @@ gst_gconf_audio_src_reset (GstGConfAudioSrc * src)
gst_bin_remove (GST_BIN (src), src->kid);
}
src->kid = gst_element_factory_make ("fakesrc", "testsrc");
if (!src->kid) {
GST_ERROR_OBJECT (src, "Failed to create fakesrc");
return FALSE;
}
gst_bin_add (GST_BIN (src), src->kid);
targetpad = gst_element_get_pad (src->kid, "src");
......@@ -90,6 +94,7 @@ gst_gconf_audio_src_reset (GstGConfAudioSrc * src)
g_free (src->gconf_str);
src->gconf_str = NULL;
return TRUE;
}
static void
......@@ -225,7 +230,8 @@ gst_gconf_audio_src_change_state (GstElement * element,
switch (transition) {
case GST_STATE_CHANGE_READY_TO_NULL:
gst_gconf_audio_src_reset (src);
if (!gst_gconf_audio_src_reset (src))
ret = GST_STATE_CHANGE_FAILURE;
break;
default:
break;
......
......@@ -70,7 +70,7 @@ gst_gconf_video_sink_class_init (GstGConfVideoSinkClass * klass)
* Hack to make negotiation work.
*/
static void
static gboolean
gst_gconf_video_sink_reset (GstGConfVideoSink * sink)
{
GstPad *targetpad;
......@@ -81,6 +81,10 @@ gst_gconf_video_sink_reset (GstGConfVideoSink * sink)
gst_bin_remove (GST_BIN (sink), sink->kid);
}
sink->kid = gst_element_factory_make ("fakesink", "testsink");
if (!sink->kid) {
GST_ERROR_OBJECT (sink, "Failed to create fakesink");
return FALSE;
}
gst_bin_add (GST_BIN (sink), sink->kid);
targetpad = gst_element_get_pad (sink->kid, "sink");
......@@ -89,6 +93,8 @@ gst_gconf_video_sink_reset (GstGConfVideoSink * sink)
g_free (sink->gconf_str);
sink->gconf_str = NULL;
return TRUE;
}
static void
......@@ -223,7 +229,8 @@ gst_gconf_video_sink_change_state (GstElement * element,
switch (transition) {
case GST_STATE_CHANGE_READY_TO_NULL:
gst_gconf_video_sink_reset (sink);
if (!gst_gconf_video_sink_reset (sink))
ret = GST_STATE_CHANGE_FAILURE;
break;
default:
break;
......
......@@ -71,7 +71,7 @@ gst_gconf_video_src_class_init (GstGConfVideoSrcClass * klass)
* Hack to make negotiation work.
*/
static void
static gboolean
gst_gconf_video_src_reset (GstGConfVideoSrc * src)
{
GstPad *targetpad;
......@@ -82,6 +82,10 @@ gst_gconf_video_src_reset (GstGConfVideoSrc * src)
gst_bin_remove (GST_BIN (src), src->kid);
}
src->kid = gst_element_factory_make ("fakesrc", "testsrc");
if (!src->kid) {
GST_ERROR_OBJECT (src, "Failed to create fakesrc");
return FALSE;
}
gst_bin_add (GST_BIN (src), src->kid);
targetpad = gst_element_get_pad (src->kid, "src");
......@@ -90,6 +94,8 @@ gst_gconf_video_src_reset (GstGConfVideoSrc * src)
g_free (src->gconf_str);
src->gconf_str = NULL;
return TRUE;
}
static void
......@@ -217,7 +223,8 @@ gst_gconf_video_src_change_state (GstElement * element,
switch (transition) {
case GST_STATE_CHANGE_READY_TO_NULL:
gst_gconf_video_src_reset (src);
if (!gst_gconf_video_src_reset (src))
ret = GST_STATE_CHANGE_FAILURE;
break;
default:
break;
......
......@@ -76,15 +76,17 @@ gst_switch_sink_class_init (GstSwitchSinkClass * klass)
}
}
static void
static gboolean
gst_switch_sink_reset (GstSwitchSink * sink)
{
/* this will install fakesink if no other child has been set,
* otherwise we rely on the subclass to know when to unset its
* custom kid */
if (sink->kid == NULL) {
gst_switch_sink_set_child (sink, NULL);
return gst_switch_sink_set_child (sink, NULL);
}
return TRUE;
}
static void
......@@ -143,6 +145,10 @@ gst_switch_commit_new_kid (GstSwitchSink * sink)
if (new_kid == NULL) {
GST_DEBUG_OBJECT (sink, "Replacing kid with fakesink");
new_kid = gst_element_factory_make ("fakesink", "testsink");
if (new_kid == NULL) {
GST_ERROR_OBJECT (sink, "Failed to create fakesink");
return FALSE;
}
/* Add a reference, as it would if the element came from sink->new_kid */
gst_object_ref (new_kid);
g_object_set (new_kid, "sync", TRUE, NULL);
......@@ -299,7 +305,8 @@ gst_switch_sink_change_state (GstElement * element, GstStateChange transition)
switch (transition) {
case GST_STATE_CHANGE_READY_TO_NULL:
gst_switch_sink_reset (sink);
if (!gst_switch_sink_reset (sink))
ret = GST_STATE_CHANGE_FAILURE;
break;
default:
break;
......
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