From fb72702e801d65b9ec206ca55e9d1b2fa938a451 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 21 Aug 2004 07:19:54 +0000 Subject: [PATCH] don't interleave reads --- .../src/arch/Sound/RageSoundDriver_DSound.cpp | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp b/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp index 75f9fa16e8..e70d5d72a6 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp @@ -48,26 +48,15 @@ void RageSound_DSound::MixerThread() CHECKPOINT; LockMut( m_Mutex ); - /* GetData() will return false if the buffer is sufficiently full. Interleave - * reads: call GetData for each file before calling it on the same file twice. - * That way, if we're behind, we'll catch up each file a little, instead of bursting - * to catch up one file while the others fall further behind. - * - * A better approach would be to sort the files by how many chunks they need, - * and to fill sounds that need the most first. */ - while( 1 ) + for( unsigned i = 0; i < stream_pool.size(); ++i ) { - bool bMoreData = false; - for(unsigned i = 0; i < stream_pool.size(); ++i) + /* We're only interested in PLAYING and FLUSHING sounds. */ + while( stream_pool[i]->state == stream::PLAYING || + stream_pool[i]->state == stream::FLUSHING ) { - /* We're only interested in PLAYING and FLUSHING sounds. */ - if( stream_pool[i]->state != stream::PLAYING && - stream_pool[i]->state != stream::FLUSHING ) - continue; /* inactive */ - bool bEOF; - if( stream_pool[i]->GetData( false, bEOF ) ) - bMoreData = true; + if( !stream_pool[i]->GetData( false, bEOF ) ) + break; if( bEOF ) { @@ -79,8 +68,6 @@ void RageSound_DSound::MixerThread() stream_pool[i]->flush_pos = stream_pool[i]->pcm->GetOutputPosition(); } } - if( !bMoreData ) - break; } /* When sounds are in FLUSHING, and we've finished flushing, stop the sound