mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-06 23:48:53 +00:00
playbin: use flushing pads instead of fakesink
Use the flushing pads on playsink to terminate on shutdown instead of plugging fakesinks. this should be a little cheaper.
This commit is contained in:
parent
747841e97c
commit
f5a3387bdb
1 changed files with 17 additions and 41 deletions
|
@ -265,7 +265,6 @@ struct _GstSourceSelect
|
||||||
GPtrArray *channels;
|
GPtrArray *channels;
|
||||||
GstPad *srcpad; /* the source pad of the selector */
|
GstPad *srcpad; /* the source pad of the selector */
|
||||||
GstPad *sinkpad; /* the sinkpad of the sink when the selector is linked */
|
GstPad *sinkpad; /* the sinkpad of the sink when the selector is linked */
|
||||||
GstElement *fakesink; /* the fakesink the selector might be linked to */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GST_SOURCE_GROUP_GET_LOCK(group) (((GstSourceGroup*)(group))->lock)
|
#define GST_SOURCE_GROUP_GET_LOCK(group) (((GstSourceGroup*)(group))->lock)
|
||||||
|
@ -1998,43 +1997,27 @@ no_more_pads_cb (GstElement * decodebin, GstSourceGroup * group)
|
||||||
shutdown:
|
shutdown:
|
||||||
{
|
{
|
||||||
GST_DEBUG ("ignoring, we are shutting down");
|
GST_DEBUG ("ignoring, we are shutting down");
|
||||||
/* unblock selector and link fakesink in READY to make downstream
|
/* Request a flushing pad from playsink that we then link to the selector.
|
||||||
* return WRONG_STATE
|
* Then we unblock the selectors so that they stop with a WRONG_STATE
|
||||||
* (trying to avoid NOT_LINKED leading to confusing errors) */
|
* instead of a NOT_LINKED error.
|
||||||
|
*/
|
||||||
GST_SOURCE_GROUP_LOCK (group);
|
GST_SOURCE_GROUP_LOCK (group);
|
||||||
for (i = 0; i < GST_PLAY_SINK_TYPE_LAST; i++) {
|
for (i = 0; i < GST_PLAY_SINK_TYPE_LAST; i++) {
|
||||||
GstSourceSelect *select = &group->selector[i];
|
GstSourceSelect *select = &group->selector[i];
|
||||||
|
|
||||||
/* if we are in normal case, i.e. have a selector etc, plug fakesink */
|
if (select->selector && select->sinkpad == NULL) {
|
||||||
if (select->selector) {
|
GST_DEBUG_OBJECT (playbin, "requesting new flushing sink pad");
|
||||||
if (select->srcpad) {
|
select->sinkpad =
|
||||||
GST_DEBUG_OBJECT (playbin, "unblocking %" GST_PTR_FORMAT,
|
gst_play_sink_request_pad (playbin->playsink,
|
||||||
select->srcpad);
|
GST_PLAY_SINK_TYPE_FLUSHING);
|
||||||
gst_pad_set_blocked_async (select->srcpad, FALSE, selector_blocked,
|
res = gst_pad_link (select->srcpad, select->sinkpad);
|
||||||
NULL);
|
GST_DEBUG_OBJECT (playbin, "linked flushing, result: %d", res);
|
||||||
}
|
}
|
||||||
/* streaming might error with NOT_LINKED if any of this fails,
|
if (select->srcpad) {
|
||||||
* but at least we tried */
|
GST_DEBUG_OBJECT (playbin, "unblocking %" GST_PTR_FORMAT,
|
||||||
GST_DEBUG_OBJECT (playbin, "creating fakesink (sinktype:%d)",
|
select->srcpad);
|
||||||
select->type);
|
gst_pad_set_blocked_async (select->srcpad, FALSE, selector_blocked,
|
||||||
select->fakesink = gst_element_factory_make ("fakesink", "fakesink");
|
NULL);
|
||||||
if (select->fakesink) {
|
|
||||||
GST_OBJECT_FLAG_UNSET (select->fakesink, GST_ELEMENT_IS_SINK);
|
|
||||||
gst_element_set_state (select->fakesink, GST_STATE_READY);
|
|
||||||
if (gst_bin_add (GST_BIN (playbin), select->fakesink)) {
|
|
||||||
if (!gst_element_link (select->selector, select->fakesink)) {
|
|
||||||
GST_DEBUG_OBJECT (playbin, "could not link fakesink element");
|
|
||||||
gst_object_unref (select->fakesink);
|
|
||||||
select->fakesink = NULL;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
GST_DEBUG_OBJECT (playbin, "could not add fakesink element");
|
|
||||||
gst_object_unref (select->fakesink);
|
|
||||||
select->fakesink = NULL;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
GST_DEBUG_OBJECT (playbin, "failed to create fakesink");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GST_SOURCE_GROUP_UNLOCK (group);
|
GST_SOURCE_GROUP_UNLOCK (group);
|
||||||
|
@ -2386,13 +2369,6 @@ deactivate_group (GstPlayBin * playbin, GstSourceGroup * group)
|
||||||
select->sinkpad = NULL;
|
select->sinkpad = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (select->fakesink) {
|
|
||||||
GST_LOG_OBJECT (playbin, "removing fakesink");
|
|
||||||
gst_element_set_state (select->fakesink, GST_STATE_NULL);
|
|
||||||
gst_bin_remove (GST_BIN_CAST (playbin), select->fakesink);
|
|
||||||
select->fakesink = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_object_unref (select->srcpad);
|
gst_object_unref (select->srcpad);
|
||||||
select->srcpad = NULL;
|
select->srcpad = NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue