From 7c7a90b99d593f75f73d968bfe23f03f7a87e089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Thu, 12 Oct 2023 16:05:18 +0200 Subject: [PATCH] imagesequencesrc: fix regular image deadlock With one regular image file path provided (without %05d), the element was stuck in a dead loop counting the frames: gst_image_sequence_src_count_frames This allows to display any image file out of the element for a given number of buffers. Part-of: --- .../gst/multifile/gstimagesequencesrc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/subprojects/gst-plugins-good/gst/multifile/gstimagesequencesrc.c b/subprojects/gst-plugins-good/gst/multifile/gstimagesequencesrc.c index ca2d11f560..b60f73b882 100644 --- a/subprojects/gst-plugins-good/gst/multifile/gstimagesequencesrc.c +++ b/subprojects/gst-plugins-good/gst/multifile/gstimagesequencesrc.c @@ -489,24 +489,25 @@ static gint gst_image_sequence_src_count_frames (GstImageSequenceSrc * self, gboolean can_read) { + gchar *previous_filename = NULL; if (can_read && self->stop_index < 0 && self->path) { gint i; for (i = self->start_index;; i++) { gchar *filename = g_strdup_printf (self->path, i); - - if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR)) { + if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR) + || !g_strcmp0 (previous_filename, filename)) { i--; g_free (filename); break; } - - g_free (filename); + g_free (previous_filename); + previous_filename = filename; } if (i > self->start_index) self->stop_index = i; } - + g_free (previous_filename); if (self->stop_index >= self->start_index) self->n_frames = self->stop_index - self->start_index + 1; return self->n_frames;