summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-04-24 20:00:36 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-04-24 20:00:36 +0200
commit48594c75a15c4d3976efede324ad5bb92e38381e (patch)
tree63135a971bba45ef3d03b3457724c54a13aac8a5 /plugins
parentb1e379ec5b930f2f26c963f4c42d095be205c372 (diff)
fixed sample-accurate seeking in ape plugin
Diffstat (limited to 'plugins')
-rw-r--r--plugins/ffap/ffap.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/plugins/ffap/ffap.c b/plugins/ffap/ffap.c
index 60ba9b18..11456ebd 100644
--- a/plugins/ffap/ffap.c
+++ b/plugins/ffap/ffap.c
@@ -598,7 +598,7 @@ static int ape_read_packet(DB_FILE *fp, APEContext *ape_ctx)
if (ape->currentframe > ape->totalframes)
return -1;
-// fprintf (stderr, "seeking to %d\n", ape->frames[ape->currentframe].pos);
+ trace ("seeking to packet %d (%d + %d)\n", ape->currentframe, ape->frames[ape->currentframe].pos, ape_ctx->skip_header);
if (deadbeef->fseek (fp, ape->frames[ape->currentframe].pos + ape_ctx->skip_header, SEEK_SET) != 0) {
return -1;
}
@@ -1761,9 +1761,9 @@ ffap_insert (DB_playItem_t *after, const char *fname) {
static int
ffap_read_int16 (DB_fileinfo_t *_info, char *buffer, int size) {
ape_info_t *info = (ape_info_t*)_info;
- if (info->ape_ctx.currentsample + size / (2 * info->ape_ctx.channels) > info->endsample) {
- size = (info->endsample - info->ape_ctx.currentsample + 1) * 2 * info->ape_ctx.channels;
- trace ("size truncated to %d bytes, cursample=%d, info->endsample=%d, totalsamples=%d\n", size, info->ape_ctx.currentsample, info->endsample, info->ape_ctx.totalsamples);
+ if (info->ape_ctx.currentsample + size / ((info->info.bps / 8) * info->ape_ctx.channels) > info->endsample) {
+ size = (info->endsample - info->ape_ctx.currentsample + 1) * (info->info.bps / 8) * info->ape_ctx.channels;
+ trace ("size truncated to %d bytes (%d samples), cursample=%d, info->endsample=%d, totalsamples=%d\n", size, size / (info->info.bps / 8) / info->ape_ctx.channels, info->ape_ctx.currentsample, info->endsample, info->ape_ctx.totalsamples);
if (size <= 0) {
return 0;
}
@@ -1822,8 +1822,11 @@ ffap_seek_sample (DB_fileinfo_t *_info, int sample) {
}
info->ape_ctx.currentframe = nframe;
info->ape_ctx.samplestoskip = newsample - nframe * info->ape_ctx.blocksperframe;
+ trace ("seek to sample %d at blockstart\n", nframe * info->ape_ctx.blocksperframe);
+ trace ("samples to skip: %d\n", info->ape_ctx.samplestoskip);
// reset decoder
+ info->ape_ctx.remaining = 0;
info->ape_ctx.packet_remaining = 0;
info->ape_ctx.samples = 0;
info->ape_ctx.currentsample = newsample;