mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
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:
parent
20540ebdb4
commit
7c890c0b91
1 changed files with 6 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue