diff options
author | Edward Hervey <edward@centricular.com> | 2017-09-22 17:04:54 +0200 |
---|---|---|
committer | Edward Hervey <bilboed@bilboed.com> | 2018-02-10 12:14:47 +0100 |
commit | 9f1063e4a3fe1b23c624c10e7a2b7dc801dd68ba (patch) | |
tree | b877e45d6aabcdd99fd99ef8e5679f6907654cc7 | |
parent | fc933020874ee0d2c78d9054ff02e5925b4b6fd4 (diff) |
playbin3: Remove duration caching
This is now handled directly via sinks and queries through pads
-rw-r--r-- | gst/playback/gstplaybin3.c | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/gst/playback/gstplaybin3.c b/gst/playback/gstplaybin3.c index 2b53f97e4..1f63034c0 100644 --- a/gst/playback/gstplaybin3.c +++ b/gst/playback/gstplaybin3.c @@ -472,13 +472,6 @@ struct _GstPlayBin3 GSequence *aelements; /* a list of GstAVElements for audio stream */ GSequence *velements; /* a list of GstAVElements for video stream */ - struct - { - gboolean valid; - GstFormat format; - gint64 duration; - } duration[5]; /* cached durations */ - guint64 ring_buffer_max_size; /* 0 means disabled */ /* Active stream collection */ @@ -581,7 +574,6 @@ static GstStateChangeReturn gst_play_bin3_change_state (GstElement * element, static void gst_play_bin3_handle_message (GstBin * bin, GstMessage * message); static void gst_play_bin3_deep_element_added (GstBin * playbin, GstBin * sub_bin, GstElement * child); -static gboolean gst_play_bin3_query (GstElement * element, GstQuery * query); static gboolean gst_play_bin3_send_event (GstElement * element, GstEvent * event); @@ -1023,7 +1015,6 @@ gst_play_bin3_class_init (GstPlayBin3Class * klass) gstelement_klass->change_state = GST_DEBUG_FUNCPTR (gst_play_bin3_change_state); - gstelement_klass->query = GST_DEBUG_FUNCPTR (gst_play_bin3_query); gstelement_klass->send_event = GST_DEBUG_FUNCPTR (gst_play_bin3_send_event); gstbin_klass->handle_message = @@ -2116,108 +2107,6 @@ gst_play_bin3_get_property (GObject * object, guint prop_id, GValue * value, } } -static void -gst_play_bin3_update_cached_duration_from_query (GstPlayBin3 * playbin, - gboolean valid, GstQuery * query) -{ - GstFormat fmt; - gint64 duration; - gint i; - - GST_DEBUG_OBJECT (playbin, "Updating cached duration from query"); - gst_query_parse_duration (query, &fmt, &duration); - - for (i = 0; i < G_N_ELEMENTS (playbin->duration); i++) { - if (playbin->duration[i].format == 0 || fmt == playbin->duration[i].format) { - playbin->duration[i].valid = valid; - playbin->duration[i].format = fmt; - playbin->duration[i].duration = valid ? duration : -1; - break; - } - } -} - -static void -gst_play_bin3_update_cached_duration (GstPlayBin3 * playbin) -{ - const GstFormat formats[] = - { GST_FORMAT_TIME, GST_FORMAT_BYTES, GST_FORMAT_DEFAULT }; - gboolean ret; - GstQuery *query; - gint i; - - GST_DEBUG_OBJECT (playbin, "Updating cached durations before group switch"); - for (i = 0; i < G_N_ELEMENTS (formats); i++) { - query = gst_query_new_duration (formats[i]); - ret = - GST_ELEMENT_CLASS (parent_class)->query (GST_ELEMENT_CAST (playbin), - query); - gst_play_bin3_update_cached_duration_from_query (playbin, ret, query); - gst_query_unref (query); - } -} - -static gboolean -gst_play_bin3_query (GstElement * element, GstQuery * query) -{ - GstPlayBin3 *playbin = GST_PLAY_BIN3 (element); - gboolean ret; - - /* During a group switch we shouldn't allow duration queries - * because it's not clear if the old or new group's duration - * is returned and if the sinks are already playing new data - * or old data. See bug #585969 - * - * While we're at it, also don't do any other queries during - * a group switch or any other event that causes topology changes - * by taking the playbin lock in any case. - */ - GST_PLAY_BIN3_LOCK (playbin); - - if (GST_QUERY_TYPE (query) == GST_QUERY_DURATION) { - GstSourceGroup *group = playbin->curr_group; - gboolean pending; - - GST_SOURCE_GROUP_LOCK (group); - - pending = group->pending || group->stream_changed_pending; - - if (pending) { - GstFormat fmt; - gint i; - - ret = FALSE; - gst_query_parse_duration (query, &fmt, NULL); - for (i = 0; i < G_N_ELEMENTS (playbin->duration); i++) { - if (fmt == playbin->duration[i].format) { - ret = playbin->duration[i].valid; - gst_query_set_duration (query, fmt, - (ret ? playbin->duration[i].duration : -1)); - break; - } - } - /* if nothing cached yet, we might as well request duration, - * such as during initial startup */ - if (ret) { - GST_DEBUG_OBJECT (playbin, - "Taking cached duration because of pending group switch: %d", ret); - GST_SOURCE_GROUP_UNLOCK (group); - GST_PLAY_BIN3_UNLOCK (playbin); - return ret; - } - } - GST_SOURCE_GROUP_UNLOCK (group); - } - - ret = GST_ELEMENT_CLASS (parent_class)->query (element, query); - - if (GST_QUERY_TYPE (query) == GST_QUERY_DURATION) - gst_play_bin3_update_cached_duration_from_query (playbin, ret, query); - GST_PLAY_BIN3_UNLOCK (playbin); - - return ret; -} - static gint get_combiner_stream_id (GstPlayBin3 * playbin, GstSourceCombine * combine, GList * full_list) @@ -4902,7 +4791,6 @@ setup_next_source (GstPlayBin3 * playbin, GstState target) if (old_group && old_group->valid && old_group->active) { new_group->stream_changed_pending = TRUE; - gst_play_bin3_update_cached_duration (playbin); /* unlink our pads with the sink */ deactivate_group (playbin, old_group); old_group->valid = FALSE; @@ -5001,12 +4889,8 @@ gst_play_bin3_change_state (GstElement * element, GstStateChange transition) playbin = GST_PLAY_BIN3 (element); switch (transition) { - case GST_STATE_CHANGE_NULL_TO_READY: - memset (&playbin->duration, 0, sizeof (playbin->duration)); - break; case GST_STATE_CHANGE_READY_TO_PAUSED: GST_LOG_OBJECT (playbin, "clearing shutdown flag"); - memset (&playbin->duration, 0, sizeof (playbin->duration)); g_atomic_int_set (&playbin->shutdown, 0); do_async_start (playbin); break; @@ -5015,7 +4899,6 @@ gst_play_bin3_change_state (GstElement * element, GstStateChange transition) /* FIXME unlock our waiting groups */ GST_LOG_OBJECT (playbin, "setting shutdown flag"); g_atomic_int_set (&playbin->shutdown, 1); - memset (&playbin->duration, 0, sizeof (playbin->duration)); /* wait for all callbacks to end by taking the lock. * No dynamic (critical) new callbacks will @@ -5033,7 +4916,6 @@ gst_play_bin3_change_state (GstElement * element, GstStateChange transition) do_save = TRUE; goto async_down; } - memset (&playbin->duration, 0, sizeof (playbin->duration)); /* unlock so that all groups go to NULL */ groups_set_locked_state (playbin, FALSE); |