Commits

Bart van Strien committed 7897f06

Some audio fixes (no more mp3 clicking and popping?) (issue #217)

Comments (0)

Files changed (3)

src/modules/audio/openal/Source.cpp

 				offsetSamples += (curOffsetSamples - newOffsetSamples);
 				offsetSeconds += (curOffsetSecs - newOffsetSecs);
 				
-				if(streamAtomic(buffer, decoder) > 0)
-					alSourceQueueBuffers(source, 1, &buffer);
+				streamAtomic(buffer, decoder);
+				alSourceQueueBuffers(source, 1, &buffer);
 			}
 		}
 	}
 			{
 				int decoded = streamAtomic(buffers[i], decoder);
 				++usedBuffers;
-				if(decoded < decoder->getSize())
+				if(decoder->isFinished())
 					break;
 			}
 
 		if(decoded > 0 && fmt != 0)
 			alBufferData(buffer, fmt, d->getBuffer(), decoded, d->getSampleRate());
 
-		if(decoded < d->getSize() && isLooping()) {
+		if(decoder->isFinished() && isLooping()) {
 			offsetSamples = 0;
 			offsetSeconds = 0;
 			d->rewind();

src/modules/sound/lullaby/Mpg123Decoder.cpp

 				continue;
 			case MPG123_NEED_MORE:
 				{
+					size += numbytes;
 					int v = feed(8192);
 
 					switch(v)

src/modules/sound/lullaby/VorbisDecoder.cpp

 			else if(result <= OV_EREAD)
 				return -1;
 			else if(result == 0)
+			{
+				eof = true;
 				break;
+			}
 			else if(result > 0)
 				size += result;
 		}
 
-		if(oggFile.dataSize - oggFile.dataRead == 0)
-			eof = true;
-
 		return size;
 	}