1
0
Fork 0
forked from len0rd/rockbox

plugins: playing time: use cpu_boost + simplify a bit

Change-Id: I860621530af1d5c6a6de9651fc81e235e43ece97
This commit is contained in:
Christian Soffke 2024-07-23 21:14:22 +02:00
parent 6dd9b9786c
commit 8d436561e2

View file

@ -298,7 +298,7 @@ static bool playing_time(void)
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, index, fd; int i, index;
pti.nb_tracks = rb->playlist_amount(); pti.nb_tracks = rb->playlist_amount();
rb->playlist_get_resume_info(&pti.curr_index); rb->playlist_get_resume_info(&pti.curr_index);
@ -313,8 +313,11 @@ static bool playing_time(void)
pti.kbs[ePT_KBS_BEF] = curr_id3->offset / 1024; pti.kbs[ePT_KBS_BEF] = curr_id3->offset / 1024;
pti.kbs[ePT_KBS_AFT] = (curr_id3->filesize -curr_id3->offset) / 1024; pti.kbs[ePT_KBS_AFT] = (curr_id3->filesize -curr_id3->offset) / 1024;
rb->splash(0, ID2P(LANG_WAIT)); rb->splash_progress_set_delay(HZ/2);
rb->splash_progress_set_delay(5 * HZ);
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
rb->cpu_boost(true);
#endif
/* Go through each file in the playlist and get its stats. For /* Go through each file in the playlist and get its stats. For
huge playlists this can take a while... The reference position huge playlists this can take a while... The reference position
is the position at the moment this function was invoked, is the position at the moment this function was invoked,
@ -326,8 +329,8 @@ static bool playing_time(void)
index = 0; index = 0;
/* Show a splash while we are loading. */ /* Show a splash while we are loading. */
rb->splash_progress(i, pti.nb_tracks, rb->splash_progress(i, pti.nb_tracks, "%s (%s)",
"%s (%s)", rb->str(LANG_WAIT), rb->str(LANG_OFF_ABORT)); rb->str(LANG_WAIT), rb->str(LANG_OFF_ABORT));
/* Voice equivalent */ /* Voice equivalent */
if (TIME_AFTER(*rb->current_tick, talked_tick + 5 * HZ)) { if (TIME_AFTER(*rb->current_tick, talked_tick + 5 * HZ)) {
@ -336,42 +339,37 @@ static bool playing_time(void)
TALK_ID(i * 100 / pti.nb_tracks, UNIT_PERCENT)); TALK_ID(i * 100 / pti.nb_tracks, UNIT_PERCENT));
} }
if (rb->action_userabort(TIMEOUT_NOBLOCK)) if (rb->action_userabort(TIMEOUT_NOBLOCK))
{
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
rb->cpu_boost(false);
#endif
goto exit; goto exit;
}
if (index == pti.curr_index) if (index == pti.curr_index)
continue; continue;
if (rb->playlist_get_track_info(NULL, index, &pltrack) >= 0) if (rb->playlist_get_track_info(NULL, index, &pltrack) < 0
{ || rb->mp3info(&id3, pltrack.filename))
bool ret = false;
if ((fd = rb->open(pltrack.filename, O_RDONLY)) >= 0)
{
ret = rb->get_metadata(&id3, fd, pltrack.filename);
rb->close(fd);
if (ret)
{
if (pltrack.display_index < pti.curr_display_index) {
pti.secs[ePT_SECS_BEF] += id3.length / 1000;
pti.kbs[ePT_KBS_BEF] += id3.filesize / 1024;
} else {
pti.secs[ePT_SECS_AFT] += id3.length / 1000;
pti.kbs[ePT_KBS_AFT] += id3.filesize / 1024;
}
}
}
if (!ret)
{ {
error_count++; error_count++;
continue; continue;
} }
if (pltrack.display_index < pti.curr_display_index) /* preceding tracks */
{
pti.secs[ePT_SECS_BEF] += id3.length / 1000;
pti.kbs[ePT_KBS_BEF] += id3.filesize / 1024;
} }
else else
{ {
error_count++; pti.secs[ePT_SECS_AFT] += id3.length / 1000;
break; pti.kbs[ePT_KBS_AFT] += id3.filesize / 1024;
} }
} }
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
rb->cpu_boost(false);
#endif
if (error_count > 0) if (error_count > 0)
{ {