summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2005-06-11 19:14:40 +0000
committerDave Chapman <dave@dchapman.com>2005-06-11 19:14:40 +0000
commit8f0a0fed4e40c1fb831744ca1cc34f20a93d85b4 (patch)
tree5aec170ab4891367dca02be16f002b7bb41c457d /apps
parent94b917e9ee1e287a2713fad52754250d591e0e57 (diff)
downloadrockbox-8f0a0fed4e40c1fb831744ca1cc34f20a93d85b4.tar.gz
rockbox-8f0a0fed4e40c1fb831744ca1cc34f20a93d85b4.zip
Estimate (poorly) the duration of an Ogg track, and display elapsed time in WPS
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6681 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/playback.c12
-rw-r--r--apps/plugins/codecvorbis.c4
2 files changed, 10 insertions, 6 deletions
diff --git a/apps/playback.c b/apps/playback.c
index 8d5ba3c830..739496ec73 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -831,11 +831,13 @@ bool audio_load_track(int offset, bool start_play, int peek_offset)
831 tracks[track_widx].id3.bitrate=(buf[48]|(buf[49]<<8)|(buf[50]<<16)|(buf[51]<<24))/1000; 831 tracks[track_widx].id3.bitrate=(buf[48]|(buf[49]<<8)|(buf[50]<<16)|(buf[51]<<24))/1000;
832 tracks[track_widx].id3.vbr=true; 832 tracks[track_widx].id3.vbr=true;
833 833
834 /* I don't yet know how to calculate the totalsamples */ 834 if (tracks[track_widx].id3.bitrate!=0) {
835 totalsamples=0; 835 /* A _really_ stupid and inaccurate calculation, but the best
836 836 I can do at the moment. */
837 /* Calculate the length in ms */ 837 tracks[track_widx].id3.length=(tracks[track_widx].filesize)/(tracks[track_widx].id3.bitrate/8);
838 tracks[track_widx].id3.length=(totalsamples/tracks[track_widx].id3.frequency)*1000; 838 } else {
839 tracks[track_widx].id3.length=0;
840 }
839 841
840 lseek(fd, 0, SEEK_SET); 842 lseek(fd, 0, SEEK_SET);
841 strncpy(tracks[track_widx].id3.path,trackname,sizeof(tracks[track_widx].id3.path)); 843 strncpy(tracks[track_widx].id3.path,trackname,sizeof(tracks[track_widx].id3.path));
diff --git a/apps/plugins/codecvorbis.c b/apps/plugins/codecvorbis.c
index 6c512f7ce4..a1f39f0242 100644
--- a/apps/plugins/codecvorbis.c
+++ b/apps/plugins/codecvorbis.c
@@ -147,7 +147,9 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parm)
147 rb->yield(); 147 rb->yield();
148 while (!ci->audiobuffer_insert(pcmbuf, n)) 148 while (!ci->audiobuffer_insert(pcmbuf, n))
149 rb->yield(); 149 rb->yield();
150 150
151 ci->set_elapsed(ov_time_tell(&vf));
152
151#if BYTE_ORDER == BIG_ENDIAN 153#if BYTE_ORDER == BIG_ENDIAN
152 for (i=0;i<n;i+=2) { 154 for (i=0;i<n;i+=2) {
153 x=pcmbuf[i]; pcmbuf[i]=pcmbuf[i+1]; pcmbuf[i+1]=x; 155 x=pcmbuf[i]; pcmbuf[i]=pcmbuf[i+1]; pcmbuf[i+1]=x;