aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/decode.c9
-rw-r--r--src/ogg_decode.c14
2 files changed, 13 insertions, 10 deletions
diff --git a/src/decode.c b/src/decode.c
index b1c0bb012..ce2629f5f 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -345,7 +345,7 @@ void decode() {
else if((cb->begin!=cb->end || cb->wrap) &&
cb->begin!=cb->next)
{
- if(doCrossFade==1 && cb->next>=0 &&
+ if(doCrossFade==1 && cb->next>=0 &&
((cb->next>cb->begin &&
(fadePosition=cb->next-cb->begin)
<=crossFadeChunks) ||
@@ -356,9 +356,9 @@ void decode() {
if(nextChunk<0) {
crossFadeChunks = fadePosition;
}
- nextChunk = cb->begin+crossFadeChunks;
test = cb->end;
if(cb->wrap) test+=buffered_chunks;
+ nextChunk = cb->begin+crossFadeChunks;
if(nextChunk<test) {
if(nextChunk>=buffered_chunks)
{
@@ -390,10 +390,7 @@ void decode() {
{
doCrossFade = -1;
}
- else {
- usleep(10);
- continue;
- }
+ else continue;
}
}
pc->elapsedTime = cb->times[cb->begin];
diff --git a/src/ogg_decode.c b/src/ogg_decode.c
index 158428beb..c9cf0016c 100644
--- a/src/ogg_decode.c
+++ b/src/ogg_decode.c
@@ -63,6 +63,7 @@ int ogg_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc)
int eof = 0;
long ret;
char chunk[CHUNK_SIZE];
+ int chunkpos = 0;
long bitRate = 0;
long test;
@@ -70,13 +71,17 @@ int ogg_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc)
if(dc->seek) {
cb->end = 0;
cb->wrap = 0;
+ chunkpos = 0;
ov_time_seek_page(&vf,dc->seekWhere);
dc->seek = 0;
}
- ret = ov_read(&vf,chunk,CHUNK_SIZE,0,2,1,
+ ret = ov_read(&vf,chunk+chunkpos,
+ CHUNK_SIZE-chunkpos,
+ 0,2,1,
&current_section);
if(ret<=0) eof = 1;
- else {
+ else chunkpos+=ret;
+ if(chunkpos>=CHUNK_SIZE || eof) {
while(cb->begin==cb->end && cb->wrap &&
!dc->stop && !dc->seek)
{
@@ -89,8 +94,9 @@ int ogg_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc)
af->bits);
#endif
memcpy(cb->chunks+cb->end*CHUNK_SIZE,
- chunk,CHUNK_SIZE);
- cb->chunkSize[cb->end] = ret;
+ chunk,chunkpos);
+ cb->chunkSize[cb->end] = chunkpos;
+ chunkpos = 0;
cb->times[cb->end] = ov_time_tell(&vf);
if((test = ov_bitrate_instant(&vf))>0) {
bitRate = test/1000;