summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2009-08-18 19:56:34 +0200
committerGravatar waker <wakeroid@gmail.com>2009-08-18 19:56:34 +0200
commit4648789ea45e407541864772bb40963b65dcb096 (patch)
tree2c8d841c7ad3c719a0a99a4ddbb2d24b754caa5c
parent61c914a7e835875978040824402066a3beb12ace (diff)
fixed some more errors in streamer and mp3 decoder
-rw-r--r--cmp3.c15
-rw-r--r--streamer.c2
2 files changed, 9 insertions, 8 deletions
diff --git a/cmp3.c b/cmp3.c
index 31eef2f6..6b0a8533 100644
--- a/cmp3.c
+++ b/cmp3.c
@@ -71,7 +71,6 @@ typedef struct {
int bitspersample;
int channels;
float duration;
- float trackduration;
int startoffset;
int endoffset;
#if 0
@@ -124,15 +123,14 @@ cmp3_init (struct playItem_s *it) {
if (it->timeend > 0) {
buffer.timestart = it->timestart;
buffer.timeend = it->timeend;
- buffer.trackduration = it->duration;
- printf ("duration: %f\n", it->duration);
// that comes from cue, don't calc duration, just seek and play
cmp3_scan_stream (&buffer, it->timestart);
+ mad_timer_reset(&buffer.timer);
}
else {
- buffer.trackduration = it->duration = cmp3_scan_stream (&buffer, -1); // scan entire stream, calc duration
- timestart = 0;
- timeend = buffer.trackduration;
+ it->duration = cmp3_scan_stream (&buffer, -1); // scan entire stream, calc duration
+ buffer.timestart = 0;
+ buffer.timeend = it->duration;
fseek (buffer.file, buffer.startoffset, SEEK_SET);
}
cmp3.info.bitsPerSample = buffer.bitspersample;
@@ -596,6 +594,9 @@ int
cmp3_read (char *bytes, int size) {
int result;
int ret = 0;
+ if (cmp3.info.readposition >= (buffer.timeend - buffer.timestart)) {
+ return 0;
+ }
if (buffer.cachefill > 0) {
int sz = min (size, buffer.cachefill);
memcpy (bytes, buffer.cache, sz);
@@ -616,7 +617,7 @@ cmp3_read (char *bytes, int size) {
ret += cmp3_decode ();
cmp3.info.readposition = (float)buffer.timer.seconds + (float)buffer.timer.fraction / MAD_TIMER_RESOLUTION;
}
- if (cmp3.info.readposition >= buffer.trackduration) {
+ if (cmp3.info.readposition >= (buffer.timeend - buffer.timestart)) {
return 0;
}
return ret;
diff --git a/streamer.c b/streamer.c
index 7b6216e9..65a9f006 100644
--- a/streamer.c
+++ b/streamer.c
@@ -140,7 +140,7 @@ streamer_thread (uintptr_t ctx) {
}
streamer_lock ();
- if (streambuffer_fill < STREAM_BUFFER_SIZE) {
+ if (streambuffer_fill < STREAM_BUFFER_SIZE && bytes_until_next_song == 0) {
int sz = STREAM_BUFFER_SIZE - streambuffer_fill;
int minsize = 4096;
if (streambuffer_fill < 16384) {