summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/playback.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/apps/playback.c b/apps/playback.c
index 1c5a7a4c9d..5d980b5634 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -1872,10 +1872,37 @@ static int audio_load_track(void)
1872 playlist_peek_offset); 1872 playlist_peek_offset);
1873 1873
1874 /* Get track name from current playlist read position */ 1874 /* Get track name from current playlist read position */
1875 int fd = -1;
1875 char path_buf[MAX_PATH + 1]; 1876 char path_buf[MAX_PATH + 1];
1876 const char *path = playlist_peek(playlist_peek_offset, 1877 const char *path;
1877 path_buf, 1878
1878 sizeof (path_buf)); 1879 while (1)
1880 {
1881 path = playlist_peek(playlist_peek_offset,
1882 path_buf,
1883 sizeof (path_buf));
1884
1885 if (!path)
1886 break;
1887
1888 /* Test for broken playlists by probing for the files */
1889 fd = open(path, O_RDONLY);
1890 if (fd >= 0)
1891 break;
1892
1893 logf("Open failed");
1894
1895 /* only skip if failed track has a successor in playlist */
1896 if (!playlist_peek(playlist_peek_offset + 1, NULL, 0))
1897 break;
1898
1899 /* Skip invalid entry from playlist */
1900 playlist_skip_entry(NULL, playlist_peek_offset);
1901
1902 /* Sync the playlist if it isn't finished */
1903 if (playlist_peek(playlist_peek_offset, NULL, 0))
1904 playlist_next(0);
1905 }
1879 1906
1880 if (!path) 1907 if (!path)
1881 { 1908 {
@@ -1911,14 +1938,12 @@ static int audio_load_track(void)
1911 /* Load the metadata for the first unbuffered track */ 1938 /* Load the metadata for the first unbuffered track */
1912 ub_id3 = id3_get(UNBUFFERED_ID3); 1939 ub_id3 = id3_get(UNBUFFERED_ID3);
1913 1940
1914 int fd = open(path, O_RDONLY);
1915 if (fd >= 0) 1941 if (fd >= 0)
1916 { 1942 {
1917 id3_mutex_lock(); 1943 id3_mutex_lock();
1918 if(!get_metadata(ub_id3, fd, path)) 1944 if(!get_metadata(ub_id3, fd, path))
1919 wipe_mp3entry(ub_id3); 1945 wipe_mp3entry(ub_id3);
1920 id3_mutex_unlock(); 1946 id3_mutex_unlock();
1921 close(fd);
1922 } 1947 }
1923 1948
1924 if (filling != STATE_FULL) 1949 if (filling != STATE_FULL)
@@ -1936,13 +1961,16 @@ static int audio_load_track(void)
1936 { 1961 {
1937 track_list_free_info(&info); 1962 track_list_free_info(&info);
1938 track_list.in_progress_hid = 0; 1963 track_list.in_progress_hid = 0;
1964 if (fd >= 0)
1965 close(fd);
1939 return LOAD_TRACK_ERR_FAILED; 1966 return LOAD_TRACK_ERR_FAILED;
1940 } 1967 }
1941 1968
1942 /* Successful load initiation */ 1969 /* Successful load initiation */
1943 track_list.in_progress_hid = info.self_hid; 1970 track_list.in_progress_hid = info.self_hid;
1944 } 1971 }
1945 1972 if (fd >= 0)
1973 close(fd);
1946 return LOAD_TRACK_OK; 1974 return LOAD_TRACK_OK;
1947} 1975}
1948 1976