summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Schmidt <jan@centricular.com>2016-05-14 18:32:52 +1000
committerJan Schmidt <jan@centricular.com>2016-05-14 18:34:57 +1000
commit08af8cd5b8b18577cfd74f6e5454be5cc2ec1f96 (patch)
tree15276d5a3645fa8f474e1c99e8f17725926641d8
parentf35f604610380f5d4d02973e8389ca823b7b5fc5 (diff)
splitmuxsink: Hide internal async state changes.
When switching fragments, hide the async-start/async-done messages from the parent bin, as otherwise we sometimes (very rarely) hang in PAUSED instead of returning / continuing to PLAYING state.
-rw-r--r--gst/multifile/gstsplitmuxsink.c26
-rw-r--r--gst/multifile/gstsplitmuxsink.h1
2 files changed, 25 insertions, 2 deletions
diff --git a/gst/multifile/gstsplitmuxsink.c b/gst/multifile/gstsplitmuxsink.c
index 6f889e5f8..9cd3d01cb 100644
--- a/gst/multifile/gstsplitmuxsink.c
+++ b/gst/multifile/gstsplitmuxsink.c
@@ -755,13 +755,21 @@ static void
start_next_fragment (GstSplitMuxSink * splitmux)
{
/* 1 change to new file */
+ splitmux->switching_fragment = TRUE;
+
+ gst_element_set_locked_state (splitmux->muxer, TRUE);
+ gst_element_set_locked_state (splitmux->active_sink, TRUE);
gst_element_set_state (splitmux->muxer, GST_STATE_NULL);
gst_element_set_state (splitmux->active_sink, GST_STATE_NULL);
set_next_filename (splitmux);
- gst_element_sync_state_with_parent (splitmux->active_sink);
- gst_element_sync_state_with_parent (splitmux->muxer);
+ gst_element_set_state (splitmux->active_sink, GST_STATE_TARGET (splitmux));
+ gst_element_set_state (splitmux->muxer, GST_STATE_TARGET (splitmux));
+ gst_element_set_locked_state (splitmux->muxer, FALSE);
+ gst_element_set_locked_state (splitmux->active_sink, FALSE);
+
+ splitmux->switching_fragment = FALSE;
g_list_foreach (splitmux->contexts, (GFunc) restart_context, splitmux);
@@ -814,6 +822,20 @@ bus_handler (GstBin * bin, GstMessage * message)
}
GST_SPLITMUX_UNLOCK (splitmux);
break;
+ case GST_MESSAGE_ASYNC_START:
+ case GST_MESSAGE_ASYNC_DONE:
+ /* Ignore state changes from our children while switching */
+ if (splitmux->switching_fragment) {
+ if (GST_MESSAGE_SRC (message) == (GstObject *) splitmux->active_sink ||
+ GST_MESSAGE_SRC (message) == (GstObject *) splitmux->muxer) {
+ GST_LOG_OBJECT (splitmux,
+ "Ignoring state change from child %" GST_PTR_FORMAT
+ " while switching", GST_MESSAGE_SRC (message));
+ gst_message_unref (message);
+ return;
+ }
+ }
+ break;
default:
break;
}
diff --git a/gst/multifile/gstsplitmuxsink.h b/gst/multifile/gstsplitmuxsink.h
index a233642c7..0fdb56b16 100644
--- a/gst/multifile/gstsplitmuxsink.h
+++ b/gst/multifile/gstsplitmuxsink.h
@@ -125,6 +125,7 @@ struct _GstSplitMuxSink {
gsize mux_start_bytes;
gboolean opening_first_fragment;
+ gboolean switching_fragment;
};
struct _GstSplitMuxSinkClass {