From 7bcb48928897389a8e41f2f0124f0b7aeb04fc70 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 10 Dec 2006 03:34:44 +0000 Subject: [PATCH] buffering fixes --- stepmania/src/RageSoundReader_ChannelSplit.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stepmania/src/RageSoundReader_ChannelSplit.cpp b/stepmania/src/RageSoundReader_ChannelSplit.cpp index 973cb3451b..e6e318ac10 100644 --- a/stepmania/src/RageSoundReader_ChannelSplit.cpp +++ b/stepmania/src/RageSoundReader_ChannelSplit.cpp @@ -174,13 +174,16 @@ bool RageSoundSplitterImpl::ReadBuffer() { int iFrame = m_pSource->SetPosition_Accurate( iMinFrameRequested ); m_iBufferPositionFrames = iFrame; + m_sBuffer.clear(); } int iFramesBuffered = m_sBuffer.size() / (sizeof(int16_t) * m_pSource->GetNumChannels() ); int iFramesToRead = iMaxFrameRequested - (m_iBufferPositionFrames + iFramesBuffered); - int iBytesToRead = iFramesToRead * sizeof(int16_t) * m_pSource->GetNumChannels(); + if( iFramesToRead <= 0 ) + return true; // requested data already buffered + int iBytesToRead = iFramesToRead * sizeof(int16_t) * m_pSource->GetNumChannels(); int iOldSizeBytes = m_sBuffer.size(); m_sBuffer.resize( iOldSizeBytes + iBytesToRead ); int iGotBytes = m_pSource->Read( &m_sBuffer[0] + iOldSizeBytes, iBytesToRead );