summaryrefslogtreecommitdiff
path: root/apps/playback.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/playback.c')
-rw-r--r--apps/playback.c57
1 files changed, 0 insertions, 57 deletions
diff --git a/apps/playback.c b/apps/playback.c
index f49831ef30..2875f44505 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -1559,62 +1559,6 @@ static bool audio_loadcodec(bool start_play)
1559 return true; 1559 return true;
1560} 1560}
1561 1561
1562/* TODO: Copied from mpeg.c. Should be moved somewhere else. */
1563static void audio_set_elapsed(struct mp3entry* id3)
1564{
1565 unsigned long offset = id3->offset > id3->first_frame_offset ?
1566 id3->offset - id3->first_frame_offset : 0;
1567
1568 if ( id3->vbr ) {
1569 if ( id3->has_toc ) {
1570 /* calculate elapsed time using TOC */
1571 int i;
1572 unsigned int remainder, plen, relpos, nextpos;
1573
1574 /* find wich percent we're at */
1575 for (i=0; i<100; i++ )
1576 if ( offset < id3->toc[i] * (id3->filesize / 256) )
1577 break;
1578
1579 i--;
1580 if (i < 0)
1581 i = 0;
1582
1583 relpos = id3->toc[i];
1584
1585 if (i < 99)
1586 nextpos = id3->toc[i+1];
1587 else
1588 nextpos = 256;
1589
1590 remainder = offset - (relpos * (id3->filesize / 256));
1591
1592 /* set time for this percent (divide before multiply to prevent
1593 overflow on long files. loss of precision is negligible on
1594 short files) */
1595 id3->elapsed = i * (id3->length / 100);
1596
1597 /* calculate remainder time */
1598 plen = (nextpos - relpos) * (id3->filesize / 256);
1599 id3->elapsed += (((remainder * 100) / plen) *
1600 (id3->length / 10000));
1601 }
1602 else {
1603 /* no TOC exists. set a rough estimate using average bitrate */
1604 int tpk = id3->length /
1605 ((id3->filesize - id3->first_frame_offset - id3->id3v1len) /
1606 1024);
1607 id3->elapsed = offset / 1024 * tpk;
1608 }
1609 }
1610 else
1611 {
1612 /* constant bitrate, use exact calculation */
1613 if (id3->bitrate != 0)
1614 id3->elapsed = offset / (id3->bitrate / 8);
1615 }
1616}
1617
1618/* Load one track by making the appropriate bufopen calls. Return true if 1562/* Load one track by making the appropriate bufopen calls. Return true if
1619 everything required was loaded correctly, false if not. */ 1563 everything required was loaded correctly, false if not. */
1620static bool audio_load_track(int offset, bool start_play) 1564static bool audio_load_track(int offset, bool start_play)
@@ -1781,7 +1725,6 @@ static bool audio_load_track(int offset, bool start_play)
1781 if (offset > 0) { 1725 if (offset > 0) {
1782 file_offset = offset; 1726 file_offset = offset;
1783 track_id3->offset = offset; 1727 track_id3->offset = offset;
1784 audio_set_elapsed(track_id3);
1785 } 1728 }
1786 break; 1729 break;
1787 1730