summaryrefslogtreecommitdiff
path: root/plugins/mpgmad
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-04-04 21:19:33 +0200
committerGravatar waker <wakeroid@gmail.com>2011-04-04 21:19:33 +0200
commitefd1736048c49285ea8f32112ae2005e435b705d (patch)
treedeea55226866e4f4a116f9c31f53b8dec701788e /plugins/mpgmad
parent1951aa1d1af99ee2f5af1610cb4324f0e88605b1 (diff)
mp3: fixed streaming radio regression
Diffstat (limited to 'plugins/mpgmad')
-rw-r--r--plugins/mpgmad/mpgmad.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/plugins/mpgmad/mpgmad.c b/plugins/mpgmad/mpgmad.c
index c79050b4..58fbf102 100644
--- a/plugins/mpgmad/mpgmad.c
+++ b/plugins/mpgmad/mpgmad.c
@@ -25,8 +25,8 @@
#include <sys/time.h>
#include "../../deadbeef.h"
-//#define trace(...) { fprintf(stderr, __VA_ARGS__); }
-#define trace(fmt,...)
+#define trace(...) { fprintf(stderr, __VA_ARGS__); }
+//#define trace(fmt,...)
//#define WRITE_DUMP 1
@@ -1113,13 +1113,15 @@ cmp3_read (DB_fileinfo_t *_info, char *bytes, int size) {
}
#endif
mpgmad_info_t *info = (mpgmad_info_t *)_info;
- int samplesize = _info->fmt.channels * _info->fmt.bps / 8;
- int curr = info->buffer.currentsample - info->buffer.delay;
- if (size / samplesize + curr > info->buffer.endsample) {
- size = (info->buffer.endsample - curr + 1) * samplesize;
- trace ("mp3: size truncated to %d bytes (%d samples), cursample=%d, endsample=%d\n", size, info->buffer.endsample - curr + 1, curr, info->buffer.endsample);
- if (size <= 0) {
- return 0;
+ if (info->buffer.duration >= 0) {
+ int samplesize = _info->fmt.channels * _info->fmt.bps / 8;
+ int curr = info->buffer.currentsample - info->buffer.delay;
+ if (size / samplesize + curr > info->buffer.endsample) {
+ size = (info->buffer.endsample - curr + 1) * samplesize;
+ trace ("mp3: size truncated to %d bytes (%d samples), cursample=%d, endsample=%d\n", size, info->buffer.endsample - curr + 1, curr, info->buffer.endsample);
+ if (size <= 0) {
+ return 0;
+ }
}
}
int initsize = size;