pipeline: don't link tracks unnecessarily

Unless the pipeline is in certain modes, we do not want to try and link
every track. The previous debug message implied this, but the method did
not actually end early.
Also, we always end early if we receive a track that is neither video
nor audio.
This commit is contained in:
Henry Wilkes 2020-03-05 19:00:20 +00:00 committed by Thibault Saunier
parent 7f65b7be0c
commit 1cc5221d49

View file

@ -780,6 +780,7 @@ _link_track (GESPipeline * self, GESTrack * track)
GstCaps *caps; GstCaps *caps;
GstPadLinkReturn lret; GstPadLinkReturn lret;
gboolean reconfigured = FALSE; gboolean reconfigured = FALSE;
gboolean ignore;
pad = ges_timeline_get_pad_for_track (self->priv->timeline, track); pad = ges_timeline_get_pad_for_track (self->priv->timeline, track);
if (G_UNLIKELY (!pad)) { if (G_UNLIKELY (!pad)) {
@ -799,21 +800,28 @@ _link_track (GESPipeline * self, GESTrack * track)
* video or text tracks. Also provide a way to switch between these. */ * video or text tracks. Also provide a way to switch between these. */
/* Don't connect track if it's not going to be used */ /* Don't connect track if it's not going to be used */
if (track->type == GES_TRACK_TYPE_VIDEO && ignore = TRUE;
!(self->priv->mode & GES_PIPELINE_MODE_PREVIEW_VIDEO) && /* only support audio and video. Technically, preview mode could support
!(self->priv->mode & GES_PIPELINE_MODE_RENDER) && * text quite easily, but this isn't yet the case for rendering using
!(self->priv->mode & GES_PIPELINE_MODE_SMART_RENDER)) { * encodebin */
GST_DEBUG_OBJECT (self, "Video track... but we don't need it. Not linking"); if (track->type == GES_TRACK_TYPE_AUDIO ||
/* FIXME: why are we not returning early at this point? */ track->type == GES_TRACK_TYPE_VIDEO) {
if (IN_RENDERING_MODE (self))
ignore = FALSE;
else if (track->type == GES_TRACK_TYPE_VIDEO &&
self->priv->mode & GES_PIPELINE_MODE_PREVIEW_VIDEO)
ignore = FALSE;
else if (track->type == GES_TRACK_TYPE_AUDIO &&
self->priv->mode & GES_PIPELINE_MODE_PREVIEW_AUDIO)
ignore = FALSE;
} }
if (track->type == GES_TRACK_TYPE_AUDIO &&
!(self->priv->mode & GES_PIPELINE_MODE_PREVIEW_AUDIO) && if (ignore) {
!(self->priv->mode & GES_PIPELINE_MODE_RENDER) && gst_object_unref (pad);
!(self->priv->mode & GES_PIPELINE_MODE_SMART_RENDER)) { GST_DEBUG_OBJECT (self, "Ignoring track (type %u). Not linking",
GST_DEBUG_OBJECT (self, "Audio track... but we don't need it. Not linking"); track->type);
/* FIXME: why are we not returning early at this point? */ return;
} }
/* FIXME: what about text and custom tracks? */
/* Get an existing chain or create it */ /* Get an existing chain or create it */
if (!(chain = get_output_chain_for_track (self, track))) if (!(chain = get_output_chain_for_track (self, track)))