diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugin.c | 2 | ||||
-rw-r--r-- | apps/plugin.h | 2 | ||||
-rw-r--r-- | apps/plugins/playing_time.c | 35 |
3 files changed, 27 insertions, 12 deletions
diff --git a/apps/plugin.c b/apps/plugin.c index cb6990384c..bd93cb8b5c 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -835,6 +835,8 @@ static const struct plugin_api rockbox_api = { | |||
835 | #ifdef HAVE_TAGCACHE | 835 | #ifdef HAVE_TAGCACHE |
836 | tagcache_commit_finalize, | 836 | tagcache_commit_finalize, |
837 | #endif | 837 | #endif |
838 | playlist_get_first_index, | ||
839 | playlist_get_display_index, | ||
838 | }; | 840 | }; |
839 | 841 | ||
840 | static int plugin_buffer_handle; | 842 | static int plugin_buffer_handle; |
diff --git a/apps/plugin.h b/apps/plugin.h index a85af47826..24eb28b2bd 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -972,6 +972,8 @@ struct plugin_api { | |||
972 | #ifdef HAVE_TAGCACHE | 972 | #ifdef HAVE_TAGCACHE |
973 | void (*tagcache_commit_finalize)(void); | 973 | void (*tagcache_commit_finalize)(void); |
974 | #endif | 974 | #endif |
975 | int (*playlist_get_first_index)(const struct playlist_info* playlist); | ||
976 | int (*playlist_get_display_index)(void); | ||
975 | }; | 977 | }; |
976 | 978 | ||
977 | /* plugin header */ | 979 | /* plugin header */ |
diff --git a/apps/plugins/playing_time.c b/apps/plugins/playing_time.c index 148da67df8..942513c499 100644 --- a/apps/plugins/playing_time.c +++ b/apps/plugins/playing_time.c | |||
@@ -50,8 +50,10 @@ enum ePT_KBS { | |||
50 | 50 | ||
51 | /* playing_time screen context */ | 51 | /* playing_time screen context */ |
52 | struct playing_time_info { | 52 | struct playing_time_info { |
53 | int curr_playing; /* index of currently playing track in playlist */ | 53 | int curr_index; /* index of currently playing track in playlist */ |
54 | int nb_tracks; /* how many tracks in playlist */ | 54 | int curr_display_index; /* display index of currently playing track in playlist */ |
55 | int nb_tracks; /* how many tracks in playlist */ | ||
56 | |||
55 | /* seconds total, before, and after current position. Datatype | 57 | /* seconds total, before, and after current position. Datatype |
56 | allows for values up to 68years. If I had kept it in ms | 58 | allows for values up to 68years. If I had kept it in ms |
57 | though, it would have overflowed at 24days, which takes | 59 | though, it would have overflowed at 24days, which takes |
@@ -59,6 +61,7 @@ struct playing_time_info { | |||
59 | have playlists lasting longer than that. */ | 61 | have playlists lasting longer than that. */ |
60 | long secs[ePT_SECS_COUNT]; | 62 | long secs[ePT_SECS_COUNT]; |
61 | long trk_secs[ePT_SECS_COUNT]; | 63 | long trk_secs[ePT_SECS_COUNT]; |
64 | |||
62 | /* kilobytes played total, before, and after current pos. | 65 | /* kilobytes played total, before, and after current pos. |
63 | Kilobytes because bytes would overflow. Data type range is up | 66 | Kilobytes because bytes would overflow. Data type range is up |
64 | to 2TB. */ | 67 | to 2TB. */ |
@@ -160,13 +163,14 @@ static const char * playing_time_get_or_speak_info(int selected_item, void * dat | |||
160 | break; | 163 | break; |
161 | } | 164 | } |
162 | case 4: { /* track index */ | 165 | case 4: { /* track index */ |
163 | int track_pct = (pti->curr_playing + 1) * 100 / pti->nb_tracks; | 166 | int track_pct = pti->curr_display_index * 100 / pti->nb_tracks; |
167 | |||
164 | rb->snprintf(buf, buffer_len, rb->str(LANG_PLAYTIME_TRACK), | 168 | rb->snprintf(buf, buffer_len, rb->str(LANG_PLAYTIME_TRACK), |
165 | pti->curr_playing + 1, pti->nb_tracks, track_pct); | 169 | pti->curr_display_index, pti->nb_tracks, track_pct); |
166 | 170 | ||
167 | if (say_it) | 171 | if (say_it) |
168 | rb_talk_ids(false, LANG_PLAYTIME_TRACK, | 172 | rb_talk_ids(false, LANG_PLAYTIME_TRACK, |
169 | TALK_ID(pti->curr_playing + 1, UNIT_INT), | 173 | TALK_ID(pti->curr_display_index, UNIT_INT), |
170 | VOICE_OF, | 174 | VOICE_OF, |
171 | TALK_ID(pti->nb_tracks, UNIT_INT), | 175 | TALK_ID(pti->nb_tracks, UNIT_INT), |
172 | VOICE_PAUSE, | 176 | VOICE_PAUSE, |
@@ -248,13 +252,15 @@ static bool playing_time(void) | |||
248 | struct playing_time_info pti; | 252 | struct playing_time_info pti; |
249 | struct playlist_track_info pltrack; | 253 | struct playlist_track_info pltrack; |
250 | struct mp3entry id3; | 254 | struct mp3entry id3; |
251 | int i, fd; | 255 | int i, index, fd; |
252 | 256 | ||
253 | pti.nb_tracks = rb->playlist_amount(); | 257 | pti.nb_tracks = rb->playlist_amount(); |
254 | rb->playlist_get_resume_info(&pti.curr_playing); | 258 | rb->playlist_get_resume_info(&pti.curr_index); |
255 | struct mp3entry *curr_id3 = rb->audio_current_track(); | 259 | struct mp3entry *curr_id3 = rb->audio_current_track(); |
256 | if (pti.curr_playing == -1 || !curr_id3) | 260 | if (pti.curr_index == -1 || !curr_id3) |
257 | return false; | 261 | return false; |
262 | pti.curr_display_index = rb->playlist_get_display_index(); | ||
263 | |||
258 | pti.secs[ePT_SECS_BEF] = pti.trk_secs[ePT_SECS_BEF] = curr_id3->elapsed / 1000; | 264 | pti.secs[ePT_SECS_BEF] = pti.trk_secs[ePT_SECS_BEF] = curr_id3->elapsed / 1000; |
259 | pti.secs[ePT_SECS_AFT] = pti.trk_secs[ePT_SECS_AFT] | 265 | pti.secs[ePT_SECS_AFT] = pti.trk_secs[ePT_SECS_AFT] |
260 | = (curr_id3->length -curr_id3->elapsed) / 1000; | 266 | = (curr_id3->length -curr_id3->elapsed) / 1000; |
@@ -267,7 +273,12 @@ static bool playing_time(void) | |||
267 | huge playlists this can take a while... The reference position | 273 | huge playlists this can take a while... The reference position |
268 | is the position at the moment this function was invoked, | 274 | is the position at the moment this function was invoked, |
269 | although playback continues forward. */ | 275 | although playback continues forward. */ |
270 | for (i = 0; i < pti.nb_tracks; i++) { | 276 | index = rb->playlist_get_first_index(NULL); |
277 | for (i = 0; i < pti.nb_tracks; i++, index++) { | ||
278 | |||
279 | if (index == pti.nb_tracks) | ||
280 | index = 0; | ||
281 | |||
271 | /* Show a splash while we are loading. */ | 282 | /* Show a splash while we are loading. */ |
272 | rb->splash_progress(i, pti.nb_tracks, | 283 | rb->splash_progress(i, pti.nb_tracks, |
273 | "%s (%s)", rb->str(LANG_WAIT), rb->str(LANG_OFF_ABORT)); | 284 | "%s (%s)", rb->str(LANG_WAIT), rb->str(LANG_OFF_ABORT)); |
@@ -281,10 +292,10 @@ static bool playing_time(void) | |||
281 | if (rb->action_userabort(TIMEOUT_NOBLOCK)) | 292 | if (rb->action_userabort(TIMEOUT_NOBLOCK)) |
282 | goto exit; | 293 | goto exit; |
283 | 294 | ||
284 | if (i == pti.curr_playing) | 295 | if (index == pti.curr_index) |
285 | continue; | 296 | continue; |
286 | 297 | ||
287 | if (rb->playlist_get_track_info(NULL, i, &pltrack) >= 0) | 298 | if (rb->playlist_get_track_info(NULL, index, &pltrack) >= 0) |
288 | { | 299 | { |
289 | bool ret = false; | 300 | bool ret = false; |
290 | if ((fd = rb->open(pltrack.filename, O_RDONLY)) >= 0) | 301 | if ((fd = rb->open(pltrack.filename, O_RDONLY)) >= 0) |
@@ -293,7 +304,7 @@ static bool playing_time(void) | |||
293 | rb->close(fd); | 304 | rb->close(fd); |
294 | if (ret) | 305 | if (ret) |
295 | { | 306 | { |
296 | if (i < pti.curr_playing) { | 307 | if (pltrack.display_index < pti.curr_display_index) { |
297 | pti.secs[ePT_SECS_BEF] += id3.length / 1000; | 308 | pti.secs[ePT_SECS_BEF] += id3.length / 1000; |
298 | pti.kbs[ePT_KBS_BEF] += id3.filesize / 1024; | 309 | pti.kbs[ePT_KBS_BEF] += id3.filesize / 1024; |
299 | } else { | 310 | } else { |