summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2005-10-22 09:10:51 +0000
committerDave Chapman <dave@dchapman.com>2005-10-22 09:10:51 +0000
commit1a82763d3ada3c668e27a54b64bfb1f74370fe88 (patch)
treed790eda069fb51b8bad1b3a84d49d5874e24d888 /apps
parentaaf36caeb65dbe3f312bb96a9670822a9cb7901b (diff)
downloadrockbox-1a82763d3ada3c668e27a54b64bfb1f74370fe88.tar.gz
rockbox-1a82763d3ada3c668e27a54b64bfb1f74370fe88.tar.bz2
rockbox-1a82763d3ada3c668e27a54b64bfb1f74370fe88.zip
Seeking support for AC3/A52 files. We assume they are always CBR.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7650 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/codecs/a52.c13
-rw-r--r--apps/metadata.c9
2 files changed, 17 insertions, 5 deletions
diff --git a/apps/codecs/a52.c b/apps/codecs/a52.c
index fb881f8483..e214cbb635 100644
--- a/apps/codecs/a52.c
+++ b/apps/codecs/a52.c
@@ -24,6 +24,8 @@
#define BUFFER_SIZE 4096
+#define A52_SAMPLESPERFRAME (6*256)
+
struct codec_api *ci;
static a52_state_t *state;
@@ -124,6 +126,7 @@ enum codec_status codec_start(struct codec_api *api)
{
long n;
unsigned char *filebuf;
+ int sample_loc;
/* Generic codec initialisation */
TEST_CODEC_API(api);
@@ -160,6 +163,16 @@ next_track:
if (ci->stop_codec || ci->reload_codec)
break;
+ if (ci->seek_time) {
+ sample_loc = ci->seek_time/1000 * ci->id3->frequency;
+
+ if (ci->seek_buffer((sample_loc/A52_SAMPLESPERFRAME)*ci->id3->bytesperframe)) {
+ samplesdone = sample_loc;
+ ci->set_elapsed(samplesdone/(ci->id3->frequency/1000));
+ }
+ ci->seek_time = 0;
+ }
+
filebuf = ci->request_buffer(&n, BUFFER_SIZE);
if (n == 0) /* End of Stream */
diff --git a/apps/metadata.c b/apps/metadata.c
index f22e10d979..d8aa12085b 100644
--- a/apps/metadata.c
+++ b/apps/metadata.c
@@ -1259,7 +1259,6 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
{
unsigned char* buf;
unsigned long totalsamples;
- int bytesperframe;
int i;
/* Load codec specific track tag information. */
@@ -1381,17 +1380,17 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
{
case 0x00:
track->id3.frequency = 48000;
- bytesperframe=track->id3.bitrate * 2 * 2;
+ track->id3.bytesperframe=track->id3.bitrate * 2 * 2;
break;
case 0x40:
track->id3.frequency = 44100;
- bytesperframe = a52_441framesizes[i];
+ track->id3.bytesperframe = a52_441framesizes[i];
break;
case 0x80:
track->id3.frequency = 32000;
- bytesperframe = track->id3.bitrate * 3 * 2;
+ track->id3.bytesperframe = track->id3.bitrate * 3 * 2;
break;
default:
@@ -1401,7 +1400,7 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
}
/* One A52 frame contains 6 blocks, each containing 256 samples */
- totalsamples = (track->filesize / bytesperframe) * 6 * 256;
+ totalsamples = (track->filesize / track->id3.bytesperframe) * 6 * 256;
track->id3.length = (totalsamples / track->id3.frequency) * 1000;
break;