summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-09-22 22:25:33 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-09-22 22:25:33 +0200
commitf793d8c45fb9313a5101224af8c25b59b1e98921 (patch)
tree293d63eb7ae686b120900fc1bc21c4c260f74aec /plugins
parent1117f9ee0035398cc8971fba8ebae57efbd91275 (diff)
mp3 accuracy fixes
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mpgmad/mpgmad.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/plugins/mpgmad/mpgmad.c b/plugins/mpgmad/mpgmad.c
index b014ac91..0fb59c23 100644
--- a/plugins/mpgmad/mpgmad.c
+++ b/plugins/mpgmad/mpgmad.c
@@ -22,8 +22,8 @@
#include <stdlib.h>
#include "../../deadbeef.h"
-//#define trace(...) { fprintf(stderr, __VA_ARGS__); }
-#define trace(fmt,...)
+#define trace(...) { fprintf(stderr, __VA_ARGS__); }
+//#define trace(fmt,...)
#define min(x,y) ((x)<(y)?(x):(y))
#define max(x,y) ((x)>(y)?(x):(y))
@@ -574,11 +574,14 @@ MadFixedToFloat (mad_fixed_t Fixed) {
static int
cmp3_decode (void) {
- if (buffer.currentsample >= buffer.totalsamples) {
- return 0;
+ if (buffer.currentsample + buffer.readsize / (4 * buffer.channels) > buffer.endsample) {
+ buffer.readsize = (buffer.endsample - buffer.currentsample + 1) * 4 * buffer.channels;
+ trace ("size truncated to %d bytes, cursample=%d, endsample=%d, totalsamples=%d\n", buffer.readsize, buffer.currentsample, buffer.endsample, buffer.totalsamples);
+ if (buffer.readsize <= 0) {
+ return 0;
+ }
}
int eof = 0;
-// char *output = buffer.output;
for (;;) {
if (eof) {
break;
@@ -683,7 +686,7 @@ cmp3_decode (void) {
trace ("mpgmad: warning: extra samples were read after end of stream\n");
}
if (buffer.readsize <= 0 || eof || buffer.currentsample > buffer.endsample) {
- if (buffer.endsample >= buffer.endsample) {
+ if (buffer.currentsample > buffer.endsample) {
trace ("finished at sample %d (%d)\n", buffer.currentsample, buffer.totalsamples);
}
break;