From 1e5c5f54e330ac6531ff1efc1d1eb937ccba3697 Mon Sep 17 00:00:00 2001 From: vspader Date: Sat, 3 Mar 2007 23:05:15 +0000 Subject: [PATCH] Updated vorbis decoder to make it better. --- Plugins/Vorbis/VorbisDecoder.m | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Plugins/Vorbis/VorbisDecoder.m b/Plugins/Vorbis/VorbisDecoder.m index ae2dff455..f094a95e9 100644 --- a/Plugins/Vorbis/VorbisDecoder.m +++ b/Plugins/Vorbis/VorbisDecoder.m @@ -80,6 +80,7 @@ long sourceTell(void *datasource) - (int)fillBuffer:(void *)buf ofSize:(UInt32)size { int numread; + int total = 0; if (currentSection != lastSection) { vorbis_info *vi; @@ -93,18 +94,22 @@ long sourceTell(void *datasource) NSLog(@"Format changed..."); [self willChangeValueForKey:@"properties"]; [self didChangeValueForKey:@"properties"]; - NSLog(@"Done with format change..."); } - - lastSection = currentSection; - do { - numread = ov_read(&vorbisRef, (char *)buf, size, 0, bitsPerSample/8, 1, ¤tSection); - if (numread < 0) { - NSLog(@"SOME KINDA ERROR!"); - } - } while (numread < 0); - return numread; + do { + lastSection = currentSection; + numread = ov_read(&vorbisRef, &((char *)buf)[total], size - total, 0, bitsPerSample/8, 1, ¤tSection); + if (numread > 0) { + total += numread; + } + + if (currentSection != lastSection) { + break; + } + + } while (total != size && numread != 0); + + return total; } - (void)close