fpsdisplaysink: fix NULL ref and error handling if no video sink is found

If no video sink is set and autovideosink is not available for some
reason, post a proper error message on the bus when failing to
change state, and don't try to gst_object_ref() NULL pointers. Fixes
generic/states unit test when distchecking.
This commit is contained in:
Tim-Philipp Müller 2010-02-19 10:32:33 +00:00
parent 20540ebdb4
commit 7c890c0b91

View file

@ -228,6 +228,9 @@ update_video_sink (GstFPSDisplaySink * self, GstElement * video_sink)
/* create child elements */
self->video_sink = video_sink;
if (self->video_sink == NULL)
return;
fps_display_sink_update_sink_sync (self);
/* take a ref before bin takes the ownership */
@ -240,7 +243,6 @@ update_video_sink (GstFPSDisplaySink * self, GstElement * video_sink)
self->data_probe_id = gst_pad_add_data_probe (sink_pad,
G_CALLBACK (on_video_sink_data_flow), (gpointer) self);
gst_object_unref (sink_pad);
}
static void
@ -467,6 +469,7 @@ fps_display_sink_change_state (GstElement * element, GstStateChange transition)
if (self->video_sink == NULL) {
GstElement *video_sink;
GST_DEBUG_OBJECT (self, "No video sink set, creating autovideosink");
video_sink = gst_element_factory_make ("autovideosink",
"fps-display-video_sink");
@ -476,8 +479,8 @@ fps_display_sink_change_state (GstElement * element, GstStateChange transition)
if (self->video_sink != NULL) {
fps_display_sink_start (self);
} else {
GST_ERROR_OBJECT (self, "Internal sink isn't set and autovideosink "
"could not be created");
GST_ELEMENT_ERROR (self, LIBRARY, INIT,
("No video sink set and autovideosink is not available"), (NULL));
ret = GST_STATE_CHANGE_FAILURE;
}
break;