multifilesrc: fix stop index handling
authorStas Sergeev <stsp@aknet.ru>
Fri, 26 Oct 2012 09:33:03 +0000 (10:33 +0100)
committerTim-Philipp Müller <tim@centricular.net>
Fri, 26 Oct 2012 10:04:01 +0000 (11:04 +0100)
Make sure the stop index is always honoured. Avoids
endless loop if one wants to read and output the same
file N times, for example.

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

gst/multifile/gstmultifilesrc.c

index 85e0d99..4ac7f16 100644 (file)
@@ -340,6 +340,15 @@ gst_multi_file_src_create (GstPushSrc * src, GstBuffer ** buffer)
   if (multifilesrc->index < multifilesrc->start_index) {
     multifilesrc->index = multifilesrc->start_index;
   }
+
+  if (multifilesrc->stop_index != -1 &&
+      multifilesrc->index > multifilesrc->stop_index) {
+    if (multifilesrc->loop)
+      multifilesrc->index = multifilesrc->start_index;
+    else
+      return GST_FLOW_EOS;
+  }
+
   filename = gst_multi_file_src_get_filename (multifilesrc);
 
   GST_DEBUG_OBJECT (multifilesrc, "reading from file \"%s\".", filename);
@@ -376,10 +385,6 @@ gst_multi_file_src_create (GstPushSrc * src, GstBuffer ** buffer)
 
   multifilesrc->successful_read = TRUE;
   multifilesrc->index++;
-  if (multifilesrc->stop_index != -1 &&
-      multifilesrc->index >= multifilesrc->stop_index) {
-    multifilesrc->index = multifilesrc->start_index;
-  }
 
   buf = gst_buffer_new ();
   gst_buffer_append_memory (buf,