diff options
author | William Wilgus <wilgus.william@gmail.com> | 2023-01-14 00:34:36 -0500 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2023-01-14 00:46:08 -0500 |
commit | 6e08731835172bc68f40eba1ceedca8f5db1ac38 (patch) | |
tree | fb90c5a57e79f7fd7283a3e1974ba9e111e71da4 | |
parent | 202d8939c8bd6d49ef3f47756abd4bbb6a76f66e (diff) | |
download | rockbox-6e08731835172bc68f40eba1ceedca8f5db1ac38.tar.gz rockbox-6e08731835172bc68f40eba1ceedca8f5db1ac38.zip |
[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
-rw-r--r-- | apps/onplay.c | 57 |
1 files changed, 39 insertions, 18 deletions
diff --git a/apps/onplay.c b/apps/onplay.c index 2504835f77..56809e45cd 100644 --- a/apps/onplay.c +++ b/apps/onplay.c | |||
@@ -367,11 +367,13 @@ static int playing_time_speak_info(int selected_item, void * data) | |||
367 | other stats */ | 367 | other stats */ |
368 | static bool playing_time(void) | 368 | static bool playing_time(void) |
369 | { | 369 | { |
370 | int error_count = 0; | ||
370 | unsigned long talked_tick = current_tick; | 371 | unsigned long talked_tick = current_tick; |
371 | struct playing_time_info pti; | 372 | struct playing_time_info pti; |
372 | struct playlist_track_info pltrack; | 373 | struct playlist_track_info pltrack; |
373 | struct mp3entry id3; | 374 | struct mp3entry id3; |
374 | int i, fd, ret; | 375 | int i, fd; |
376 | bool ret; | ||
375 | 377 | ||
376 | pti.nb_tracks = playlist_amount(); | 378 | pti.nb_tracks = playlist_amount(); |
377 | playlist_get_resume_info(&pti.curr_playing); | 379 | playlist_get_resume_info(&pti.curr_playing); |
@@ -407,24 +409,44 @@ static bool playing_time(void) | |||
407 | if (i == pti.curr_playing) | 409 | if (i == pti.curr_playing) |
408 | continue; | 410 | continue; |
409 | 411 | ||
410 | if (playlist_get_track_info(NULL, i, &pltrack) < 0) | 412 | if (playlist_get_track_info(NULL, i, &pltrack) >= 0) |
411 | goto error; | 413 | { |
412 | if ((fd = open(pltrack.filename, O_RDONLY)) < 0) | 414 | ret = false; |
413 | goto error; | 415 | if ((fd = open(pltrack.filename, O_RDONLY)) >= 0) |
414 | ret = get_metadata(&id3, fd, pltrack.filename); | 416 | { |
415 | close(fd); | 417 | ret = get_metadata(&id3, fd, pltrack.filename); |
416 | if (!ret) | 418 | close(fd); |
417 | goto error; | 419 | if (ret) |
418 | 420 | { | |
419 | if (i < pti.curr_playing) { | 421 | if (i < pti.curr_playing) { |
420 | pti.secs_bef += id3.length/1000; | 422 | pti.secs_bef += id3.length/1000; |
421 | pti.kbs_bef += id3.filesize/1024; | 423 | pti.kbs_bef += id3.filesize/1024; |
422 | } else { | 424 | } else { |
423 | pti.secs_aft += id3.length/1000; | 425 | pti.secs_aft += id3.length/1000; |
424 | pti.kbs_aft += id3.filesize/1024; | 426 | pti.kbs_aft += id3.filesize/1024; |
427 | } | ||
428 | } | ||
429 | } | ||
430 | |||
431 | if (!ret) | ||
432 | { | ||
433 | error_count++; | ||
434 | continue; | ||
435 | } | ||
436 | } | ||
437 | else | ||
438 | { | ||
439 | error_count++; | ||
440 | break; | ||
425 | } | 441 | } |
426 | } | 442 | } |
427 | 443 | ||
444 | if (error_count > 0) | ||
445 | { | ||
446 | splash(HZ, ID2P(LANG_PLAYTIME_ERROR)); | ||
447 | } | ||
448 | |||
449 | pti.nb_tracks -= error_count; | ||
428 | pti.secs_ttl = pti.secs_bef +pti.secs_aft; | 450 | pti.secs_ttl = pti.secs_bef +pti.secs_aft; |
429 | pti.trk_secs_ttl = pti.trk_secs_bef +pti.trk_secs_aft; | 451 | pti.trk_secs_ttl = pti.trk_secs_bef +pti.trk_secs_aft; |
430 | pti.kbs_ttl = pti.kbs_bef +pti.kbs_aft; | 452 | pti.kbs_ttl = pti.kbs_bef +pti.kbs_aft; |
@@ -447,8 +469,7 @@ static bool playing_time(void) | |||
447 | return(default_event_handler(key) == SYS_USB_CONNECTED); | 469 | return(default_event_handler(key) == SYS_USB_CONNECTED); |
448 | } | 470 | } |
449 | } | 471 | } |
450 | error: | 472 | |
451 | splash(HZ, ID2P(LANG_PLAYTIME_ERROR)); | ||
452 | exit: | 473 | exit: |
453 | return false; | 474 | return false; |
454 | } | 475 | } |