summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorChristian Soffke <christian.soffke@gmail.com>2024-07-23 21:14:22 +0200
committerChristian Soffke <christian.soffke@gmail.com>2024-07-23 21:14:31 +0200
commit8d436561e2db57bf8a6d2fc22e98e2e1d707a516 (patch)
treeb728d8899351ed13d3d0dda3af234071467df860 /apps
parent6dd9b9786c96cf0057bfc04ebea8106805e885f7 (diff)
downloadrockbox-8d436561e2db57bf8a6d2fc22e98e2e1d707a516.tar.gz
rockbox-8d436561e2db57bf8a6d2fc22e98e2e1d707a516.zip
plugins: playing time: use cpu_boost + simplify a bit
Change-Id: I860621530af1d5c6a6de9651fc81e235e43ece97
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/playing_time.c56
1 files changed, 27 insertions, 29 deletions
diff --git a/apps/plugins/playing_time.c b/apps/plugins/playing_time.c
index e465c35a18..f8b4b006a9 100644
--- a/apps/plugins/playing_time.c
+++ b/apps/plugins/playing_time.c
@@ -298,7 +298,7 @@ static bool playing_time(void)
298 struct playing_time_info pti; 298 struct playing_time_info pti;
299 struct playlist_track_info pltrack; 299 struct playlist_track_info pltrack;
300 struct mp3entry id3; 300 struct mp3entry id3;
301 int i, index, fd; 301 int i, index;
302 302
303 pti.nb_tracks = rb->playlist_amount(); 303 pti.nb_tracks = rb->playlist_amount();
304 rb->playlist_get_resume_info(&pti.curr_index); 304 rb->playlist_get_resume_info(&pti.curr_index);
@@ -313,8 +313,11 @@ static bool playing_time(void)
313 pti.kbs[ePT_KBS_BEF] = curr_id3->offset / 1024; 313 pti.kbs[ePT_KBS_BEF] = curr_id3->offset / 1024;
314 pti.kbs[ePT_KBS_AFT] = (curr_id3->filesize -curr_id3->offset) / 1024; 314 pti.kbs[ePT_KBS_AFT] = (curr_id3->filesize -curr_id3->offset) / 1024;
315 315
316 rb->splash(0, ID2P(LANG_WAIT)); 316 rb->splash_progress_set_delay(HZ/2);
317 rb->splash_progress_set_delay(5 * HZ); 317
318#ifdef HAVE_ADJUSTABLE_CPU_FREQ
319 rb->cpu_boost(true);
320#endif
318 /* Go through each file in the playlist and get its stats. For 321 /* Go through each file in the playlist and get its stats. For
319 huge playlists this can take a while... The reference position 322 huge playlists this can take a while... The reference position
320 is the position at the moment this function was invoked, 323 is the position at the moment this function was invoked,
@@ -326,8 +329,8 @@ static bool playing_time(void)
326 index = 0; 329 index = 0;
327 330
328 /* Show a splash while we are loading. */ 331 /* Show a splash while we are loading. */
329 rb->splash_progress(i, pti.nb_tracks, 332 rb->splash_progress(i, pti.nb_tracks, "%s (%s)",
330 "%s (%s)", rb->str(LANG_WAIT), rb->str(LANG_OFF_ABORT)); 333 rb->str(LANG_WAIT), rb->str(LANG_OFF_ABORT));
331 334
332 /* Voice equivalent */ 335 /* Voice equivalent */
333 if (TIME_AFTER(*rb->current_tick, talked_tick + 5 * HZ)) { 336 if (TIME_AFTER(*rb->current_tick, talked_tick + 5 * HZ)) {
@@ -336,42 +339,37 @@ static bool playing_time(void)
336 TALK_ID(i * 100 / pti.nb_tracks, UNIT_PERCENT)); 339 TALK_ID(i * 100 / pti.nb_tracks, UNIT_PERCENT));
337 } 340 }
338 if (rb->action_userabort(TIMEOUT_NOBLOCK)) 341 if (rb->action_userabort(TIMEOUT_NOBLOCK))
342 {
343#ifdef HAVE_ADJUSTABLE_CPU_FREQ
344 rb->cpu_boost(false);
345#endif
339 goto exit; 346 goto exit;
347 }
340 348
341 if (index == pti.curr_index) 349 if (index == pti.curr_index)
342 continue; 350 continue;
343 351
344 if (rb->playlist_get_track_info(NULL, index, &pltrack) >= 0) 352 if (rb->playlist_get_track_info(NULL, index, &pltrack) < 0
353 || rb->mp3info(&id3, pltrack.filename))
345 { 354 {
346 bool ret = false; 355 error_count++;
347 if ((fd = rb->open(pltrack.filename, O_RDONLY)) >= 0) 356 continue;
348 { 357 }
349 ret = rb->get_metadata(&id3, fd, pltrack.filename);
350 rb->close(fd);
351 if (ret)
352 {
353 if (pltrack.display_index < pti.curr_display_index) {
354 pti.secs[ePT_SECS_BEF] += id3.length / 1000;
355 pti.kbs[ePT_KBS_BEF] += id3.filesize / 1024;
356 } else {
357 pti.secs[ePT_SECS_AFT] += id3.length / 1000;
358 pti.kbs[ePT_KBS_AFT] += id3.filesize / 1024;
359 }
360 }
361 }
362 358
363 if (!ret) 359 if (pltrack.display_index < pti.curr_display_index) /* preceding tracks */
364 { 360 {
365 error_count++; 361 pti.secs[ePT_SECS_BEF] += id3.length / 1000;
366 continue; 362 pti.kbs[ePT_KBS_BEF] += id3.filesize / 1024;
367 }
368 } 363 }
369 else 364 else
370 { 365 {
371 error_count++; 366 pti.secs[ePT_SECS_AFT] += id3.length / 1000;
372 break; 367 pti.kbs[ePT_KBS_AFT] += id3.filesize / 1024;
373 } 368 }
374 } 369 }
370#ifdef HAVE_ADJUSTABLE_CPU_FREQ
371 rb->cpu_boost(false);
372#endif
375 373
376 if (error_count > 0) 374 if (error_count > 0)
377 { 375 {