Revert "splitmuxsink: Use GstBin async-handling instead of our own."
authorJan Schmidt <jan@centricular.com>
Sun, 7 Aug 2016 16:53:48 +0000 (02:53 +1000)
committerJan Schmidt <jan@centricular.com>
Sun, 7 Aug 2016 17:07:34 +0000 (03:07 +1000)
This reverts commit fa008f271a52f82dededc28bd81b020ca7939b47.

async-handling in GstBin causes the pipeline to spin at 100%
CPU as the top-level pipeline tries to change that state
to PLAYING constantly. This is a workaround for a core
problem, essentially, but an improvement in this case for now.

gst/multifile/gstsplitmuxsink.c
gst/multifile/gstsplitmuxsink.h

index d3908c0..f52dc67 100644 (file)
@@ -248,7 +248,6 @@ gst_splitmux_sink_init (GstSplitMuxSink * splitmux)
   splitmux->max_files = DEFAULT_MAX_FILES;
 
   GST_OBJECT_FLAG_SET (splitmux, GST_ELEMENT_FLAG_SINK);
-  g_object_set (splitmux, "async-handling", TRUE, NULL);
 }
 
 static void
@@ -776,6 +775,8 @@ 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);
@@ -788,6 +789,8 @@ start_next_fragment (GstSplitMuxSink * 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);
 
   /* Switch state and go back to processing */
@@ -839,6 +842,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;
   }
index 82e03a7..8a43892 100644 (file)
@@ -125,6 +125,7 @@ struct _GstSplitMuxSink {
   gsize mux_start_bytes;
 
   gboolean opening_first_fragment;
+  gboolean switching_fragment;
 };
 
 struct _GstSplitMuxSinkClass {