- do not abort if stat for an audio file failed. Simply skip this file
instead.
- return proper error message if custom function failed.
- do not error out if the second scan for audio files yields more
files than the previous run. This happens if audio files are
added during the audio file scan of the random selector.
continue;
ret = -E_LSTAT;
if (lstat(entry->d_name, &s) == -1)
- goto out;
+ continue;
m = s.st_mode;
if (!S_ISREG(m) && !S_ISDIR(m)) /* skip links, sockets, ... */
continue;
if (S_ISREG(m)) { /* regular file */
if (guess_audio_format(entry->d_name) < 0)
continue;
- if (f(dirname, entry->d_name) < 0)
+ ret = f(dirname, entry->d_name);
+ if (ret < 0)
goto out;
continue;
}
#define RANDOM_SELECTOR_ERRORS \
- PARA_ERROR(FILE_COUNT, "audio file count exceeded"), \
PARA_ERROR(NOTHING_FOUND, "no audio files found"), \
static int remember_file(const char *dir, const char *name)
{
- if (audio_file_count >= num_audio_files)
- return -E_FILE_COUNT;
- audio_file_list[audio_file_count] = make_message("%s/%s", dir, name);
- audio_file_count++;
+ if (audio_file_count < num_audio_files) {
+ audio_file_list[audio_file_count] =
+ make_message("%s/%s", dir, name);
+ audio_file_count++;
+ }
return 1;
}