don't interleave reads

This commit is contained in:
Glenn Maynard
2004-08-21 07:19:54 +00:00
parent 6312cfce58
commit fb72702e80
@@ -48,26 +48,15 @@ void RageSound_DSound::MixerThread()
CHECKPOINT; CHECKPOINT;
LockMut( m_Mutex ); LockMut( m_Mutex );
/* GetData() will return false if the buffer is sufficiently full. Interleave for( unsigned i = 0; i < stream_pool.size(); ++i )
* 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 )
{ {
bool bMoreData = false; /* We're only interested in PLAYING and FLUSHING sounds. */
for(unsigned i = 0; i < stream_pool.size(); ++i) 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; bool bEOF;
if( stream_pool[i]->GetData( false, bEOF ) ) if( !stream_pool[i]->GetData( false, bEOF ) )
bMoreData = true; break;
if( bEOF ) if( bEOF )
{ {
@@ -79,8 +68,6 @@ void RageSound_DSound::MixerThread()
stream_pool[i]->flush_pos = stream_pool[i]->pcm->GetOutputPosition(); 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 /* When sounds are in FLUSHING, and we've finished flushing, stop the sound