summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-09-10 12:28:16 +0000
committerJens Arnold <amiconn@rockbox.org>2005-09-10 12:28:16 +0000
commitec9b202a921996945ebd42a7edba1326754d7737 (patch)
treef88c7d9ee1ff94c3a5cefdba0d30c78b84e72d62 /apps
parent1996dca15a495c09986cefc02086e03a53244f3a (diff)
downloadrockbox-ec9b202a921996945ebd42a7edba1326754d7737.tar.gz
rockbox-ec9b202a921996945ebd42a7edba1326754d7737.zip
Reworked handling of MPEG audio frame & file info: * Fixed frame size calculation for layer 1 (all versions) and layer 2 (V2/V2.5). * Exact frame time (expressed as a fraction) for way more precise playtime calculation at 44100/22050/11025Hz sample frequency. * Exact playtime<->position conversion for CBR also used for resume position. * More compact code, long policy.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7505 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/bookmark.c2
-rw-r--r--apps/playback.c10
-rw-r--r--apps/screens.c2
-rw-r--r--apps/settings.h4
-rw-r--r--apps/wps-display.c4
5 files changed, 11 insertions, 11 deletions
diff --git a/apps/bookmark.c b/apps/bookmark.c
index c157d01662..593bfe98cb 100644
--- a/apps/bookmark.c
+++ b/apps/bookmark.c
@@ -389,7 +389,7 @@ static char* create_bookmark()
/* create the bookmark */
snprintf(global_bookmark, sizeof(global_bookmark),
- "%d;%d;%d;%d;%d;%d;%d;%s;%s",
+ "%d;%ld;%d;%d;%ld;%d;%d;%s;%s",
resume_index,
id3->offset,
playlist_get_seed(NULL),
diff --git a/apps/playback.c b/apps/playback.c
index 6fd63d5a0f..1677e3138b 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -2008,7 +2008,7 @@ static void mp3_set_elapsed(struct mp3entry* id3)
/* find wich percent we're at */
for (i=0; i<100; i++ )
{
- if ( id3->offset < (int)(id3->toc[i] * (id3->filesize / 256)) )
+ if ( id3->offset < id3->toc[i] * (id3->filesize / 256) )
{
break;
}
@@ -2048,8 +2048,8 @@ static void mp3_set_elapsed(struct mp3entry* id3)
}
}
else
- /* constant bitrate == simple frame calculation */
- id3->elapsed = id3->offset / id3->bpf * id3->tpf;
+ /* constant bitrate, use exact calculation */
+ id3->elapsed = id3->offset / (id3->bitrate / 8);
}
/* Copied from mpeg.c. Should be moved somewhere else. */
@@ -2092,8 +2092,8 @@ int mp3_get_file_pos(void)
(id3->elapsed / 1000);
}
}
- else if (id3->bpf && id3->tpf)
- pos = (id3->elapsed/id3->tpf)*id3->bpf;
+ else if (id3->bitrate)
+ pos = id3->elapsed * (id3->bitrate / 8);
else
{
return -1;
diff --git a/apps/screens.c b/apps/screens.c
index 10e1cdd188..bba5b279e2 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -1398,7 +1398,7 @@ bool browse_id3(void)
id3->vbr ? str(LANG_ID3_VBR) : (const unsigned char*) "");
line = draw_id3_item(line, top, LANG_ID3_BITRATE, buf);
- snprintf(buf, sizeof(buf), "%d Hz", id3->frequency);
+ snprintf(buf, sizeof(buf), "%ld Hz", id3->frequency);
line = draw_id3_item(line, top, LANG_ID3_FRECUENCY, buf);
#if CONFIG_CODEC == SWCODEC
diff --git a/apps/settings.h b/apps/settings.h
index 1c1e664b90..327b79a7ee 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -215,13 +215,13 @@ struct user_settings
#ifdef HAVE_SPDIF_POWER
bool spdif_enable; /* S/PDIF power on/off */
#endif
-
+
/* resume settings */
bool resume; /* resume option: 0=off, 1=on */
int resume_index; /* index in playlist (-1 for no active resume) */
int resume_first_index; /* index of first track in playlist */
- int resume_offset; /* byte offset in mp3 file */
+ unsigned long resume_offset; /* byte offset in mp3 file */
int resume_seed; /* shuffle seed (-1=no resume shuffle 0=sorted
>0=shuffled) */
diff --git a/apps/wps-display.c b/apps/wps-display.c
index 1794e53549..3c3cc98ed4 100644
--- a/apps/wps-display.c
+++ b/apps/wps-display.c
@@ -598,7 +598,7 @@ static char* get_tag(struct mp3entry* cid3,
return buf;
case 'f': /* File Frequency */
- snprintf(buf, buf_size, "%d", id3->frequency);
+ snprintf(buf, buf_size, "%ld", id3->frequency);
return buf;
case 'p': /* File Path */
@@ -626,7 +626,7 @@ static char* get_tag(struct mp3entry* cid3,
}
case 's': /* File Size (in kilobytes) */
- snprintf(buf, buf_size, "%d", id3->filesize / 1024);
+ snprintf(buf, buf_size, "%ld", id3->filesize / 1024);
return buf;
case 'c': /* File Codec */