playsink: remove some heuristic in chain configuration code

.. since queues are now inserted unconditionally.
This commit is contained in:
Mark Nauwelaerts 2010-08-12 10:01:03 +02:00
parent 6c5b437118
commit 2379e96bbc

View file

@ -1153,8 +1153,7 @@ link_failed:
* *
*/ */
static GstPlayVideoChain * static GstPlayVideoChain *
gen_video_chain (GstPlaySink * playsink, gboolean raw, gboolean async, gen_video_chain (GstPlaySink * playsink, gboolean raw, gboolean async)
gboolean queue)
{ {
GstPlayVideoChain *chain; GstPlayVideoChain *chain;
GstBin *bin; GstBin *bin;
@ -1217,29 +1216,23 @@ gen_video_chain (GstPlaySink * playsink, gboolean raw, gboolean async,
gst_object_ref_sink (bin); gst_object_ref_sink (bin);
gst_bin_add (bin, chain->sink); gst_bin_add (bin, chain->sink);
/* NOTE streamsynchronizer needs streams decoupled */ /* decouple decoder from sink, this improves playback quite a lot since the
if (TRUE) { * decoder can continue while the sink blocks for synchronisation. We don't
/* decouple decoder from sink, this improves playback quite a lot since the * need a lot of buffers as this consumes a lot of memory and we don't want
* decoder can continue while the sink blocks for synchronisation. We don't * too little because else we would be context switching too quickly. */
* need a lot of buffers as this consumes a lot of memory and we don't want chain->queue = gst_element_factory_make ("queue", "vqueue");
* too little because else we would be context switching too quickly. */ if (chain->queue == NULL) {
chain->queue = gst_element_factory_make ("queue", "vqueue"); post_missing_element_message (playsink, "queue");
if (chain->queue == NULL) { GST_ELEMENT_WARNING (playsink, CORE, MISSING_PLUGIN,
post_missing_element_message (playsink, "queue"); (_("Missing element '%s' - check your GStreamer installation."),
GST_ELEMENT_WARNING (playsink, CORE, MISSING_PLUGIN, "queue"), ("video rendering might be suboptimal"));
(_("Missing element '%s' - check your GStreamer installation."),
"queue"), ("video rendering might be suboptimal"));
head = chain->sink;
prev = NULL;
} else {
g_object_set (G_OBJECT (chain->queue), "max-size-buffers", 3,
"max-size-bytes", 0, "max-size-time", (gint64) 0, NULL);
gst_bin_add (bin, chain->queue);
head = prev = chain->queue;
}
} else {
head = chain->sink; head = chain->sink;
prev = NULL; prev = NULL;
} else {
g_object_set (G_OBJECT (chain->queue), "max-size-buffers", 3,
"max-size-bytes", 0, "max-size-time", (gint64) 0, NULL);
gst_bin_add (bin, chain->queue);
head = prev = chain->queue;
} }
if (raw && !(playsink->flags & GST_PLAY_FLAG_NATIVE_VIDEO)) { if (raw && !(playsink->flags & GST_PLAY_FLAG_NATIVE_VIDEO)) {
@ -1342,8 +1335,7 @@ link_failed:
} }
static gboolean static gboolean
setup_video_chain (GstPlaySink * playsink, gboolean raw, gboolean async, setup_video_chain (GstPlaySink * playsink, gboolean raw, gboolean async)
gboolean queue)
{ {
GstElement *elem; GstElement *elem;
GstPlayVideoChain *chain; GstPlayVideoChain *chain;
@ -1612,7 +1604,7 @@ notify_mute_cb (GObject * object, GParamSpec * pspec, GstPlaySink * playsink)
* +-------------------------------------------------------------+ * +-------------------------------------------------------------+
*/ */
static GstPlayAudioChain * static GstPlayAudioChain *
gen_audio_chain (GstPlaySink * playsink, gboolean raw, gboolean queue) gen_audio_chain (GstPlaySink * playsink, gboolean raw)
{ {
GstPlayAudioChain *chain; GstPlayAudioChain *chain;
GstBin *bin; GstBin *bin;
@ -1654,27 +1646,20 @@ gen_audio_chain (GstPlaySink * playsink, gboolean raw, gboolean queue)
gst_object_ref_sink (bin); gst_object_ref_sink (bin);
gst_bin_add (bin, chain->sink); gst_bin_add (bin, chain->sink);
/* NOTE streamsynchronizer always need a queue to decouple its EOS sending /* we have to add a queue when we need to decouple for the video sink in
* (which might otherwise hang in downstream prerolling on EOS) */ * visualisations */
if (TRUE) { GST_DEBUG_OBJECT (playsink, "adding audio queue");
/* we have to add a queue when we need to decouple for the video sink in chain->queue = gst_element_factory_make ("queue", "aqueue");
* visualisations */ if (chain->queue == NULL) {
GST_DEBUG_OBJECT (playsink, "adding audio queue"); post_missing_element_message (playsink, "queue");
chain->queue = gst_element_factory_make ("queue", "aqueue"); GST_ELEMENT_WARNING (playsink, CORE, MISSING_PLUGIN,
if (chain->queue == NULL) { (_("Missing element '%s' - check your GStreamer installation."),
post_missing_element_message (playsink, "queue"); "queue"), ("audio playback and visualizations might not work"));
GST_ELEMENT_WARNING (playsink, CORE, MISSING_PLUGIN,
(_("Missing element '%s' - check your GStreamer installation."),
"queue"), ("audio playback and visualizations might not work"));
head = chain->sink;
prev = NULL;
} else {
gst_bin_add (bin, chain->queue);
prev = head = chain->queue;
}
} else {
head = chain->sink; head = chain->sink;
prev = NULL; prev = NULL;
} else {
gst_bin_add (bin, chain->queue);
prev = head = chain->queue;
} }
/* find ts-offset element */ /* find ts-offset element */
@ -1871,7 +1856,7 @@ link_failed:
} }
static gboolean static gboolean
setup_audio_chain (GstPlaySink * playsink, gboolean raw, gboolean queue) setup_audio_chain (GstPlaySink * playsink, gboolean raw)
{ {
GstElement *elem; GstElement *elem;
GstPlayAudioChain *chain; GstPlayAudioChain *chain;
@ -2161,13 +2146,9 @@ gst_play_sink_reconfigure (GstPlaySink * playsink)
GST_DEBUG_OBJECT (playsink, "audio:%d, video:%d, vis:%d, text:%d", need_audio, GST_DEBUG_OBJECT (playsink, "audio:%d, video:%d, vis:%d, text:%d", need_audio,
need_video, need_vis, need_text); need_video, need_vis, need_text);
/* NOTE although there is some nifty heuristic regarding whether or not to
* include a queue in some chain, streamsynchronizer mechanics need
* subsequent streams decoupled to prevent hangs */
/* set up video pipeline */ /* set up video pipeline */
if (need_video) { if (need_video) {
gboolean raw, async, queue; gboolean raw, async;
/* we need a raw sink when we do vis or when we have a raw pad */ /* we need a raw sink when we do vis or when we have a raw pad */
raw = need_vis ? TRUE : playsink->video_pad_raw; raw = need_vis ? TRUE : playsink->video_pad_raw;
@ -2175,15 +2156,12 @@ gst_play_sink_reconfigure (GstPlaySink * playsink)
* avoid a queue in the audio chain. */ * avoid a queue in the audio chain. */
async = !need_vis; async = !need_vis;
/* If subtitles are requested there already is a queue in the video chain */
queue = (need_text == FALSE);
GST_DEBUG_OBJECT (playsink, "adding video, raw %d", GST_DEBUG_OBJECT (playsink, "adding video, raw %d",
playsink->video_pad_raw); playsink->video_pad_raw);
if (playsink->videochain) { if (playsink->videochain) {
/* try to reactivate the chain */ /* try to reactivate the chain */
if (!setup_video_chain (playsink, raw, async, queue)) { if (!setup_video_chain (playsink, raw, async)) {
if (playsink->video_sinkpad_stream_synchronizer) { if (playsink->video_sinkpad_stream_synchronizer) {
gst_element_release_request_pad (GST_ELEMENT_CAST gst_element_release_request_pad (GST_ELEMENT_CAST
(playsink->stream_synchronizer), (playsink->stream_synchronizer),
@ -2202,7 +2180,7 @@ gst_play_sink_reconfigure (GstPlaySink * playsink)
} }
if (!playsink->videochain) if (!playsink->videochain)
playsink->videochain = gen_video_chain (playsink, raw, async, queue); playsink->videochain = gen_video_chain (playsink, raw, async);
if (!playsink->video_sinkpad_stream_synchronizer) { if (!playsink->video_sinkpad_stream_synchronizer) {
GstIterator *it; GstIterator *it;
@ -2311,27 +2289,16 @@ gst_play_sink_reconfigure (GstPlaySink * playsink)
} }
if (need_audio) { if (need_audio) {
gboolean raw, queue; gboolean raw;
GST_DEBUG_OBJECT (playsink, "adding audio"); GST_DEBUG_OBJECT (playsink, "adding audio");
/* get a raw sink if we are asked for a raw pad */ /* get a raw sink if we are asked for a raw pad */
raw = playsink->audio_pad_raw; raw = playsink->audio_pad_raw;
if (need_vis && playsink->videochain) {
/* If we are dealing with visualisations, we need to add a queue to
* decouple the audio from the video part. We only have to do this when
* the video part is async=true */
queue = ((GstPlayVideoChain *) playsink->videochain)->async;
GST_DEBUG_OBJECT (playsink, "need audio queue for vis: %d", queue);
} else {
/* no vis, we can avoid a queue */
GST_DEBUG_OBJECT (playsink, "don't need audio queue");
queue = FALSE;
}
if (playsink->audiochain) { if (playsink->audiochain) {
/* try to reactivate the chain */ /* try to reactivate the chain */
if (!setup_audio_chain (playsink, raw, queue)) { if (!setup_audio_chain (playsink, raw)) {
GST_DEBUG_OBJECT (playsink, "removing current audio chain"); GST_DEBUG_OBJECT (playsink, "removing current audio chain");
if (playsink->audio_tee_asrc) { if (playsink->audio_tee_asrc) {
gst_element_release_request_pad (playsink->audio_tee, gst_element_release_request_pad (playsink->audio_tee,
@ -2364,7 +2331,7 @@ gst_play_sink_reconfigure (GstPlaySink * playsink)
if (!playsink->audiochain) { if (!playsink->audiochain) {
GST_DEBUG_OBJECT (playsink, "creating new audio chain"); GST_DEBUG_OBJECT (playsink, "creating new audio chain");
playsink->audiochain = gen_audio_chain (playsink, raw, queue); playsink->audiochain = gen_audio_chain (playsink, raw);
} }
if (!playsink->audio_sinkpad_stream_synchronizer) { if (!playsink->audio_sinkpad_stream_synchronizer) {