Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Now updates time display after resume


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1829 a1c6a512-1295-4272-9138-f99709370657

+38 -1
+38 -1
firmware/mpeg.c
··· 246 246 } 247 247 #endif 248 248 249 + static void set_elapsed(struct mp3entry* id3) 250 + { 251 + if ( id3->vbr ) { 252 + if ( id3->vbrflags & VBR_TOC_FLAG ) { 253 + /* calculate elapsed time using TOC */ 254 + int i, remainder, plen, relpos; 255 + 256 + relpos = id3->offset * 256 / id3->filesize; 257 + remainder = id3->offset - (relpos * id3->filesize / 256); 258 + 259 + /* find wich percent we're at */ 260 + for (i=0; i<100; i++ ) 261 + if ( relpos < id3->toc[i] ) 262 + break; 263 + 264 + /* set time for this percent */ 265 + id3->elapsed = (i-1) * id3->length / 100; 266 + 267 + /* calculate remainder time */ 268 + plen = (id3->toc[i] - id3->toc[i-1]) * id3->filesize / 256; 269 + id3->elapsed += remainder * 1000 / plen ; 270 + } 271 + else { 272 + /* no TOC exists. set a rough estimate using average bitrate */ 273 + int tpk = (id3->filesize / 1024) / id3->length; 274 + id3->elapsed = id3->offset * tpk / 1024; 275 + } 276 + } 277 + else 278 + /* constant bitrate == simple frame calculation */ 279 + id3->elapsed = id3->offset / id3->bpf * id3->tpf; 280 + } 281 + 249 282 static bool paused; /* playback is paused */ 250 283 #ifdef SIMULATOR 251 284 static bool playing = false; ··· 688 721 return; 689 722 690 723 start_offset = (int)ev.data; 724 + 725 + /* mid-song resume? */ 691 726 if (start_offset) { 727 + struct mp3entry* id3 = &id3tags[tag_read_idx]->id3; 692 728 lseek(mpeg_file, start_offset, SEEK_SET); 693 - id3tags[tag_read_idx]->id3.offset = start_offset; 729 + id3->offset = start_offset; 730 + set_elapsed(id3); 694 731 } 695 732 else { 696 733 /* skip past id3v2 tag (to an even byte) */