gst/playback/gstplaybasebin.c: Handle unknown or invalid pads without crashing, as might occur if a media file like a...

Original commit message from CVS:
* gst/playback/gstplaybasebin.c: (new_decoded_pad_full):
Handle unknown or invalid pads without crashing, as might occur if
a media file like an mp3 is specified as a subtitle file.
Fixes: #410039
This commit is contained in:
Jan Schmidt 2007-05-24 11:15:32 +00:00
parent c446f911d4
commit d9504cf065
2 changed files with 33 additions and 14 deletions

View file

@ -1,3 +1,10 @@
2007-05-24 Jan Schmidt <thaytan@mad.scientist.com>
* gst/playback/gstplaybasebin.c: (new_decoded_pad_full):
Handle unknown or invalid pads without crashing, as might occur if
a media file like an mp3 is specified as a subtitle file.
Fixes: #410039
2007-05-24 Jan Schmidt <thaytan@mad.scientist.com> 2007-05-24 Jan Schmidt <thaytan@mad.scientist.com>
* gst/playback/gstplaybin.c: (add_sink), (dummy_blocked_cb), * gst/playback/gstplaybin.c: (add_sink), (dummy_blocked_cb),

View file

@ -1248,11 +1248,12 @@ new_decoded_pad_full (GstElement * element, GstPad * pad, gboolean last,
const gchar *mimetype; const gchar *mimetype;
GstCaps *caps; GstCaps *caps;
GstStreamInfo *info; GstStreamInfo *info;
GstStreamType type; GstStreamType type = GST_STREAM_TYPE_UNKNOWN;
GstPad *sinkpad; GstPad *sinkpad;
GstPlayBaseGroup *group; GstPlayBaseGroup *group;
guint sig; guint sig;
GstObject *parent; GstObject *parent;
gboolean first_pad;
GST_DEBUG ("play base: new decoded pad. Last: %d", last); GST_DEBUG ("play base: new decoded pad. Last: %d", last);
@ -1280,18 +1281,32 @@ new_decoded_pad_full (GstElement * element, GstPad * pad, gboolean last,
type = GST_STREAM_TYPE_VIDEO; type = GST_STREAM_TYPE_VIDEO;
} else if (g_str_has_prefix (mimetype, "text/")) { } else if (g_str_has_prefix (mimetype, "text/")) {
type = GST_STREAM_TYPE_TEXT; type = GST_STREAM_TYPE_TEXT;
} else {
type = GST_STREAM_TYPE_UNKNOWN;
} }
gst_object_unref (parent); gst_object_unref (parent);
info = gst_stream_info_new (GST_OBJECT_CAST (pad), type, NULL, caps); info = gst_stream_info_new (GST_OBJECT_CAST (pad), type, NULL, caps);
if (type > 0 && type <= NUM_TYPES) { gst_caps_unref (caps);
/* first pad of each type gets a selector + preroll queue */
if (group->type[type - 1].npads == 0) { if (type == GST_STREAM_TYPE_UNKNOWN) {
GST_DEBUG ("play base: pad needs new preroll"); /* Unknown streams get added to the group, but the data
gen_preroll_element (play_base_bin, group, type, pad, info); * just gets ignored */
} add_stream (group, info);
GROUP_UNLOCK (play_base_bin);
/* signal the no more pads after adding the stream */
if (last)
no_more_pads_full (element, is_subs, play_base_bin);
return;
}
/* first pad of each type gets a selector + preroll queue */
first_pad = (group->type[type - 1].npads == 0);
if (first_pad) {
GST_DEBUG ("play base: pad needs new preroll");
gen_preroll_element (play_base_bin, group, type, pad, info);
} }
/* add to stream selector */ /* add to stream selector */
@ -1309,12 +1324,8 @@ new_decoded_pad_full (GstElement * element, GstPad * pad, gboolean last,
gst_pad_link (pad, sinkpad); gst_pad_link (pad, sinkpad);
gst_object_unref (sinkpad); gst_object_unref (sinkpad);
/* add the stream to the list */
gst_caps_unref (caps);
info->origin = GST_OBJECT_CAST (pad);
/* select 1st for now - we'll select a preferred one after preroll */ /* select 1st for now - we'll select a preferred one after preroll */
if (type == GST_STREAM_TYPE_UNKNOWN || group->type[type - 1].npads > 0) { if (!first_pad) {
guint id; guint id;
GST_DEBUG ("Adding silence_stream data probe on type %d (npads %d)", type, GST_DEBUG ("Adding silence_stream data probe on type %d (npads %d)", type,
@ -1325,6 +1336,7 @@ new_decoded_pad_full (GstElement * element, GstPad * pad, gboolean last,
g_object_set_data (G_OBJECT (pad), "eat_probe", GINT_TO_POINTER (id)); g_object_set_data (G_OBJECT (pad), "eat_probe", GINT_TO_POINTER (id));
} }
/* add the stream to the list */
add_stream (group, info); add_stream (group, info);
GROUP_UNLOCK (play_base_bin); GROUP_UNLOCK (play_base_bin);