mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
[Feature] onplay.c Playlist Playing Time more fault tolerant
bad tracks now get skipped with a message at the end of scanning rather than an error killing the count Change-Id: I6d8c14ce00e78416b772bc5e9093a889351bc3de
This commit is contained in:
parent
202d8939c8
commit
6e08731835
1 changed files with 38 additions and 17 deletions
|
@ -367,11 +367,13 @@ static int playing_time_speak_info(int selected_item, void * data)
|
||||||
other stats */
|
other stats */
|
||||||
static bool playing_time(void)
|
static bool playing_time(void)
|
||||||
{
|
{
|
||||||
|
int error_count = 0;
|
||||||
unsigned long talked_tick = current_tick;
|
unsigned long talked_tick = current_tick;
|
||||||
struct playing_time_info pti;
|
struct playing_time_info pti;
|
||||||
struct playlist_track_info pltrack;
|
struct playlist_track_info pltrack;
|
||||||
struct mp3entry id3;
|
struct mp3entry id3;
|
||||||
int i, fd, ret;
|
int i, fd;
|
||||||
|
bool ret;
|
||||||
|
|
||||||
pti.nb_tracks = playlist_amount();
|
pti.nb_tracks = playlist_amount();
|
||||||
playlist_get_resume_info(&pti.curr_playing);
|
playlist_get_resume_info(&pti.curr_playing);
|
||||||
|
@ -407,24 +409,44 @@ static bool playing_time(void)
|
||||||
if (i == pti.curr_playing)
|
if (i == pti.curr_playing)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (playlist_get_track_info(NULL, i, &pltrack) < 0)
|
if (playlist_get_track_info(NULL, i, &pltrack) >= 0)
|
||||||
goto error;
|
{
|
||||||
if ((fd = open(pltrack.filename, O_RDONLY)) < 0)
|
ret = false;
|
||||||
goto error;
|
if ((fd = open(pltrack.filename, O_RDONLY)) >= 0)
|
||||||
ret = get_metadata(&id3, fd, pltrack.filename);
|
{
|
||||||
close(fd);
|
ret = get_metadata(&id3, fd, pltrack.filename);
|
||||||
if (!ret)
|
close(fd);
|
||||||
goto error;
|
if (ret)
|
||||||
|
{
|
||||||
|
if (i < pti.curr_playing) {
|
||||||
|
pti.secs_bef += id3.length/1000;
|
||||||
|
pti.kbs_bef += id3.filesize/1024;
|
||||||
|
} else {
|
||||||
|
pti.secs_aft += id3.length/1000;
|
||||||
|
pti.kbs_aft += id3.filesize/1024;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (i < pti.curr_playing) {
|
if (!ret)
|
||||||
pti.secs_bef += id3.length/1000;
|
{
|
||||||
pti.kbs_bef += id3.filesize/1024;
|
error_count++;
|
||||||
} else {
|
continue;
|
||||||
pti.secs_aft += id3.length/1000;
|
}
|
||||||
pti.kbs_aft += id3.filesize/1024;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error_count++;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (error_count > 0)
|
||||||
|
{
|
||||||
|
splash(HZ, ID2P(LANG_PLAYTIME_ERROR));
|
||||||
|
}
|
||||||
|
|
||||||
|
pti.nb_tracks -= error_count;
|
||||||
pti.secs_ttl = pti.secs_bef +pti.secs_aft;
|
pti.secs_ttl = pti.secs_bef +pti.secs_aft;
|
||||||
pti.trk_secs_ttl = pti.trk_secs_bef +pti.trk_secs_aft;
|
pti.trk_secs_ttl = pti.trk_secs_bef +pti.trk_secs_aft;
|
||||||
pti.kbs_ttl = pti.kbs_bef +pti.kbs_aft;
|
pti.kbs_ttl = pti.kbs_bef +pti.kbs_aft;
|
||||||
|
@ -447,8 +469,7 @@ static bool playing_time(void)
|
||||||
return(default_event_handler(key) == SYS_USB_CONNECTED);
|
return(default_event_handler(key) == SYS_USB_CONNECTED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
error:
|
|
||||||
splash(HZ, ID2P(LANG_PLAYTIME_ERROR));
|
|
||||||
exit:
|
exit:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue