mssdemux: some fixes to bitrate switching
authorThiago Santos <thiago.sousa.santos@collabora.com>
Fri, 11 Jan 2013 18:01:33 +0000 (15:01 -0300)
committerThiago Santos <thiago.sousa.santos@collabora.com>
Wed, 8 May 2013 00:05:12 +0000 (21:05 -0300)
Removes a possible deadlock from bitrate switching when the pad
that requested the switch blocks on its pad-push

ext/smoothstreaming/gstmssdemux.c

index 9747601..8e4e263 100644 (file)
@@ -735,16 +735,19 @@ gst_mss_demux_reconfigure (GstMssDemux * mssdemux)
     /* if we changed the bitrate, we need to add new pads */
     for (iter = mssdemux->streams; iter; iter = g_slist_next (iter)) {
       GstMssDemuxStream *stream = iter->data;
+      GstPad *oldpad = stream->pad;
       GstClockTime ts =
           gst_mss_stream_get_fragment_gst_timestamp (stream->manifest_stream);
 
-      oldpads = g_slist_prepend (oldpads, stream->pad);
+      oldpads = g_slist_prepend (oldpads, oldpad);
 
       stream->pad = _create_pad (mssdemux, stream->manifest_stream);
       /* TODO keep the same playback rate */
       stream->pending_newsegment =
           gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, ts, -1, ts);
       gst_mss_demux_expose_stream (mssdemux, stream);
+
+      gst_pad_push_event (oldpad, gst_event_new_eos ());
     }
 
     gst_element_no_more_pads (GST_ELEMENT (mssdemux));
@@ -752,8 +755,6 @@ gst_mss_demux_reconfigure (GstMssDemux * mssdemux)
     for (iter = oldpads; iter; iter = g_slist_next (iter)) {
       GstPad *oldpad = iter->data;
 
-      /* Push out EOS */
-      gst_pad_push_event (oldpad, gst_event_new_eos ());
       gst_pad_set_active (oldpad, FALSE);
       gst_element_remove_pad (GST_ELEMENT (mssdemux), oldpad);
       gst_object_unref (oldpad);
@@ -846,6 +847,8 @@ gst_mss_demux_stream_loop (GstMssDemuxStream * stream)
     g_thread_create ((GThreadFunc) gst_mss_demux_reconfigure, mssdemux, FALSE,
         NULL);
     GST_DEBUG_OBJECT (mssdemux, "Finished streams reconfiguration");
+    gst_task_stop (stream->stream_task);
+    return;
   } else {
     GST_OBJECT_UNLOCK (mssdemux);
   }