summaryrefslogtreecommitdiff
path: root/plugins/ffap
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-09-19 12:04:48 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-09-19 12:04:48 +0200
commit7bfdd334bf382c82f94fb0f4490a22bf93a5a0e6 (patch)
tree4600fd6134a5ef7c53696015be2a5d1f30e23dca /plugins/ffap
parent58a5a39c7efaf146889b04df0fcf107e432772a7 (diff)
fixed start-stutter in ape decoder
Diffstat (limited to 'plugins/ffap')
-rw-r--r--plugins/ffap/ffap.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/plugins/ffap/ffap.c b/plugins/ffap/ffap.c
index f995f9b2..99141fd2 100644
--- a/plugins/ffap/ffap.c
+++ b/plugins/ffap/ffap.c
@@ -261,6 +261,9 @@ typedef struct APEContext {
int samplestoskip;
int currentsample; // current sample from beginning of file
+ uint8_t buffer[BLOCKS_PER_LOOP * 2 * 2 * 2];
+ int remaining;
+
int error;
} APEContext;
@@ -1672,9 +1675,6 @@ ffap_insert (DB_playItem_t *after, const char *fname) {
return after;
}
-static uint8_t g_buffer[BLOCKS_PER_LOOP * 2 * 2 * 2];
-static int remaining = 0;
-
static int
ffap_read_int16 (char *buffer, int size) {
int inits = size;
@@ -1682,35 +1682,35 @@ ffap_read_int16 (char *buffer, int size) {
return 0;
}
while (size > 0) {
- if (remaining > 0) {
- int sz = min (size, remaining);
- memcpy (buffer, g_buffer, sz);
+ if (ape_ctx.remaining > 0) {
+ int sz = min (size, ape_ctx.remaining);
+ memcpy (buffer, ape_ctx.buffer, sz);
buffer += sz;
size -= sz;
- if (remaining > sz) {
- memmove (g_buffer, g_buffer + sz, remaining-sz);
+ if (ape_ctx.remaining > sz) {
+ memmove (ape_ctx.buffer, ape_ctx.buffer + sz, ape_ctx.remaining-sz);
}
- remaining -= sz;
+ ape_ctx.remaining -= sz;
continue;
}
int s = BLOCKS_PER_LOOP * 2 * 2 * 2;
- assert (remaining <= s/2);
- s -= remaining;
- uint8_t *buf = g_buffer + remaining;
+ assert (ape_ctx.remaining <= s/2);
+ s -= ape_ctx.remaining;
+ uint8_t *buf = ape_ctx.buffer + ape_ctx.remaining;
int n = ape_decode_frame (&ape_ctx, buf, &s);
if (n == -1) {
break;
}
- remaining += s;
+ ape_ctx.remaining += s;
- int sz = min (size, remaining);
- memcpy (buffer, g_buffer, sz);
+ int sz = min (size, ape_ctx.remaining);
+ memcpy (buffer, ape_ctx.buffer, sz);
buffer += sz;
size -= sz;
- if (remaining > sz) {
- memmove (g_buffer, g_buffer + sz, remaining-sz);
+ if (ape_ctx.remaining > sz) {
+ memmove (ape_ctx.buffer, ape_ctx.buffer + sz, ape_ctx.remaining-sz);
}
- remaining -= sz;
+ ape_ctx.remaining -= sz;
}
plugin.info.readpos = ape_ctx.currentsample / (float)plugin.info.samplerate - timestart;
return inits - size;