bin: Drop need-context messages without source instead of crashing

This commit is contained in:
Sebastian Dröge 2019-09-30 11:34:51 +03:00 committed by Tim-Philipp Müller
parent 0c6f5b3e4c
commit e6f55805b4

View file

@ -4013,24 +4013,32 @@ gst_bin_handle_message_func (GstBin * bin, GstMessage * message)
GList *l, *contexts; GList *l, *contexts;
gst_message_parse_context_type (message, &context_type); gst_message_parse_context_type (message, &context_type);
GST_OBJECT_LOCK (bin);
contexts = GST_ELEMENT_CAST (bin)->contexts;
GST_LOG_OBJECT (bin, "got need-context message type: %s", context_type);
for (l = contexts; l; l = l->next) {
GstContext *tmp = l->data;
const gchar *tmp_type = gst_context_get_context_type (tmp);
if (strcmp (context_type, tmp_type) == 0) { if (src) {
gst_element_set_context (GST_ELEMENT (src), l->data); GST_OBJECT_LOCK (bin);
break; contexts = GST_ELEMENT_CAST (bin)->contexts;
GST_LOG_OBJECT (bin, "got need-context message type: %s", context_type);
for (l = contexts; l; l = l->next) {
GstContext *tmp = l->data;
const gchar *tmp_type = gst_context_get_context_type (tmp);
if (strcmp (context_type, tmp_type) == 0) {
gst_element_set_context (GST_ELEMENT (src), l->data);
break;
}
} }
} GST_OBJECT_UNLOCK (bin);
GST_OBJECT_UNLOCK (bin);
/* Forward if we couldn't answer the message */ /* Forward if we couldn't answer the message */
if (l == NULL) { if (l == NULL) {
goto forward; goto forward;
} else {
gst_message_unref (message);
}
} else { } else {
g_warning
("Got need-context message in bin '%s' without source element, dropping",
GST_ELEMENT_NAME (bin));
gst_message_unref (message); gst_message_unref (message);
} }