Playback: Skip invalid entries from playlist

Reverts to the behavior pre-commit dfff938 with the additional change
that it will not skip the last entry.

Change-Id: Ia03da03b1bdccd8a9591548cd0ca9f58f4767947
This commit is contained in:
Christian Soffke 2021-04-08 19:20:13 +02:00 committed by Aidan MacDonald
parent ce18e13504
commit e6313201c1

View file

@ -1872,10 +1872,37 @@ static int audio_load_track(void)
playlist_peek_offset); playlist_peek_offset);
/* Get track name from current playlist read position */ /* Get track name from current playlist read position */
int fd = -1;
char path_buf[MAX_PATH + 1]; char path_buf[MAX_PATH + 1];
const char *path = playlist_peek(playlist_peek_offset, const char *path;
path_buf,
sizeof (path_buf)); while (1)
{
path = playlist_peek(playlist_peek_offset,
path_buf,
sizeof (path_buf));
if (!path)
break;
/* Test for broken playlists by probing for the files */
fd = open(path, O_RDONLY);
if (fd >= 0)
break;
logf("Open failed");
/* only skip if failed track has a successor in playlist */
if (!playlist_peek(playlist_peek_offset + 1, NULL, 0))
break;
/* Skip invalid entry from playlist */
playlist_skip_entry(NULL, playlist_peek_offset);
/* Sync the playlist if it isn't finished */
if (playlist_peek(playlist_peek_offset, NULL, 0))
playlist_next(0);
}
if (!path) if (!path)
{ {
@ -1911,14 +1938,12 @@ static int audio_load_track(void)
/* Load the metadata for the first unbuffered track */ /* Load the metadata for the first unbuffered track */
ub_id3 = id3_get(UNBUFFERED_ID3); ub_id3 = id3_get(UNBUFFERED_ID3);
int fd = open(path, O_RDONLY);
if (fd >= 0) if (fd >= 0)
{ {
id3_mutex_lock(); id3_mutex_lock();
if(!get_metadata(ub_id3, fd, path)) if(!get_metadata(ub_id3, fd, path))
wipe_mp3entry(ub_id3); wipe_mp3entry(ub_id3);
id3_mutex_unlock(); id3_mutex_unlock();
close(fd);
} }
if (filling != STATE_FULL) if (filling != STATE_FULL)
@ -1936,13 +1961,16 @@ static int audio_load_track(void)
{ {
track_list_free_info(&info); track_list_free_info(&info);
track_list.in_progress_hid = 0; track_list.in_progress_hid = 0;
if (fd >= 0)
close(fd);
return LOAD_TRACK_ERR_FAILED; return LOAD_TRACK_ERR_FAILED;
} }
/* Successful load initiation */ /* Successful load initiation */
track_list.in_progress_hid = info.self_hid; track_list.in_progress_hid = info.self_hid;
} }
if (fd >= 0)
close(fd);
return LOAD_TRACK_OK; return LOAD_TRACK_OK;
} }