From f1b5f9b53b9bb6704cf01512edcf483166696c19 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 9 Dec 2006 03:51:32 +0000 Subject: [PATCH] simplify --- stepmania/src/RageSoundReader_Chain.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/stepmania/src/RageSoundReader_Chain.cpp b/stepmania/src/RageSoundReader_Chain.cpp index 27d8708fc2..5221a5d365 100644 --- a/stepmania/src/RageSoundReader_Chain.cpp +++ b/stepmania/src/RageSoundReader_Chain.cpp @@ -284,7 +284,10 @@ int RageSoundReader_Chain::ReadBlock( int16_t *pBuffer, int iFrames ) iFrames = min( iFramesToRead, iFrames ); } - if( iFrames > 0 && m_apActiveSounds.size() == 1 && + if( iFrames == 0 ) + return 0; + + if( m_apActiveSounds.size() == 1 && m_apActiveSounds.front().fPan == 0 && m_apActiveSounds.front().pSound->GetNumChannels() == m_iChannels && m_apActiveSounds.front().pSound->GetSampleRate() == m_iActualSampleRate ) @@ -298,7 +301,14 @@ int RageSoundReader_Chain::ReadBlock( int16_t *pBuffer, int iFrames ) return iBytes / (sizeof(int16_t) * m_iChannels); } - if( iFrames > 0 && !m_apActiveSounds.empty() ) + if( m_apActiveSounds.empty() ) + { + /* If we have more sounds ahead of us, pretend we read the entire block, since + * there's silence in between. Otherwise, we're at EOF. */ + memset( pBuffer, 0, iFrames * m_iChannels * sizeof(int16_t) ); + return iFrames; + } + { RageSoundMixBuffer mix; /* Read iFrames from each sound. */ @@ -340,16 +350,6 @@ int RageSoundReader_Chain::ReadBlock( int16_t *pBuffer, int iFrames ) mix.read( (int16_t *) pBuffer ); return iMaxFramesRead; } - - /* If we have more sounds ahead of us, pretend we read the entire block, since - * there's silence in between. Otherwise, we're at EOF. */ - if( iFrames > 0 ) - { - memset( pBuffer, 0, iFrames * m_iChannels * sizeof(int16_t) ); - return iFrames; - } - - return 0; }