adaptivedemux: fix stream exposure condition
authorMichael Olbrich <m.olbrich@pengutronix.de>
Thu, 18 Aug 2016 08:06:27 +0000 (10:06 +0200)
committerJan Schmidt <jan@centricular.com>
Mon, 22 Aug 2016 15:40:39 +0000 (01:40 +1000)
The new streams should not be exposed until all streams are done with the
current fragment. The old code is incorrect and actually only checked the
current stream. Fix this by properly checking all streams.

Also, ignore the current stream. The code is only reached when the current
stream finished downloading and since
07f49f15b1196cc9fa0d45af91149a35fce123b9 ("adaptivedemux: On EOS, handle it
before waking download loop") download_finished is set after
gst_adaptive_demux_stream_advance_fragment_unlocked() is called.

Without this HLS playback with multiple streams is broken, because the new
streams are never exposed.

https://bugzilla.gnome.org/show_bug.cgi?id=770075

gst-libs/gst/adaptivedemux/gstadaptivedemux.c

index ea13658..3341c98 100644 (file)
@@ -3677,10 +3677,13 @@ gst_adaptive_demux_stream_advance_fragment_unlocked (GstAdaptiveDemux * demux,
 
       for (iter = demux->streams; iter; iter = g_list_next (iter)) {
         /* Only expose if all streams are now cancelled or finished downloading */
-        g_mutex_lock (&stream->fragment_download_lock);
-        can_expose &= (stream->cancelled == TRUE
-            || stream->download_finished == TRUE);
-        g_mutex_unlock (&stream->fragment_download_lock);
+        GstAdaptiveDemuxStream *other = iter->data;
+        if (other != stream) {
+          g_mutex_lock (&other->fragment_download_lock);
+          can_expose &= (other->cancelled == TRUE
+              || other->download_finished == TRUE);
+          g_mutex_unlock (&other->fragment_download_lock);
+        }
       }
 
       if (can_expose) {