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
This commit is contained in:
Stas Sergeev 2012-10-26 10:33:03 +01:00 committed by Tim-Philipp Müller
parent 78193dfe71
commit 238a5ec826

View file

@ -340,6 +340,15 @@ gst_multi_file_src_create (GstPushSrc * src, GstBuffer ** buffer)
if (multifilesrc->index < multifilesrc->start_index) { if (multifilesrc->index < multifilesrc->start_index) {
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); filename = gst_multi_file_src_get_filename (multifilesrc);
GST_DEBUG_OBJECT (multifilesrc, "reading from file \"%s\".", filename); 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->successful_read = TRUE;
multifilesrc->index++; multifilesrc->index++;
if (multifilesrc->stop_index != -1 &&
multifilesrc->index >= multifilesrc->stop_index) {
multifilesrc->index = multifilesrc->start_index;
}
buf = gst_buffer_new (); buf = gst_buffer_new ();
gst_buffer_append_memory (buf, gst_buffer_append_memory (buf,