From 238a5ec8260f419e321ce9030e1f252b6996edfc Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Fri, 26 Oct 2012 10:33:03 +0100 Subject: [PATCH] multifilesrc: fix stop index handling 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 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gst/multifile/gstmultifilesrc.c b/gst/multifile/gstmultifilesrc.c index 85e0d99020..4ac7f1622c 100644 --- a/gst/multifile/gstmultifilesrc.c +++ b/gst/multifile/gstmultifilesrc.c @@ -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,