improve altency
This commit is contained in:
@@ -46,10 +46,10 @@ void RageSound_DSound::MixerThread()
|
|||||||
while(!shutdown) {
|
while(!shutdown) {
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
|
|
||||||
/* Sleep for the size of one chunk. */
|
/* Sleep for the size of one chunk, or until we're signalled. */
|
||||||
const int chunksize_frames = buffersize_frames / num_chunks;
|
const int chunksize_frames = buffersize_frames / num_chunks;
|
||||||
float sleep_secs = (float(chunksize_frames) / samplerate);
|
float sleep_secs = (float(chunksize_frames) / samplerate);
|
||||||
Sleep(int(1000 * sleep_secs));
|
WaitForSingleObject( m_ThreadWakeupEvent, int(1000 * sleep_secs) );
|
||||||
|
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
LockMutex L(SOUNDMAN->lock);
|
LockMutex L(SOUNDMAN->lock);
|
||||||
@@ -193,6 +193,7 @@ RageSound_DSound::RageSound_DSound()
|
|||||||
/* Set channel volumes. */
|
/* Set channel volumes. */
|
||||||
VolumeChanged();
|
VolumeChanged();
|
||||||
|
|
||||||
|
m_ThreadWakeupEvent = CreateEvent( NULL, false, false, NULL );
|
||||||
MixingThread.SetName("Mixer thread");
|
MixingThread.SetName("Mixer thread");
|
||||||
MixingThread.Create( MixerThread_start, this );
|
MixingThread.Create( MixerThread_start, this );
|
||||||
}
|
}
|
||||||
@@ -209,6 +210,8 @@ RageSound_DSound::~RageSound_DSound()
|
|||||||
|
|
||||||
for(unsigned i = 0; i < stream_pool.size(); ++i)
|
for(unsigned i = 0; i < stream_pool.size(); ++i)
|
||||||
delete stream_pool[i];
|
delete stream_pool[i];
|
||||||
|
|
||||||
|
CloseHandle( m_ThreadWakeupEvent );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageSound_DSound::VolumeChanged()
|
void RageSound_DSound::VolumeChanged()
|
||||||
@@ -254,6 +257,10 @@ void RageSound_DSound::StartMixing(RageSound *snd)
|
|||||||
if(stream_pool[i]->state == stream_pool[i]->INACTIVE)
|
if(stream_pool[i]->state == stream_pool[i]->INACTIVE)
|
||||||
stream_pool[i]->state = stream_pool[i]->PLAYING;
|
stream_pool[i]->state = stream_pool[i]->PLAYING;
|
||||||
|
|
||||||
|
/* Kick the decoder thread, so it'll start this sound up quickly. */
|
||||||
|
L.Unlock();
|
||||||
|
SetEvent( m_ThreadWakeupEvent );
|
||||||
|
|
||||||
// LOG->Trace("new sound assigned to channel %i", i);
|
// LOG->Trace("new sound assigned to channel %i", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class RageSound_DSound: public RageSoundDriver
|
|||||||
|
|
||||||
DSound ds;
|
DSound ds;
|
||||||
|
|
||||||
|
HANDLE m_ThreadWakeupEvent;
|
||||||
bool shutdown; /* tells the MixerThread to shut down */
|
bool shutdown; /* tells the MixerThread to shut down */
|
||||||
static int MixerThread_start(void *p);
|
static int MixerThread_start(void *p);
|
||||||
void MixerThread();
|
void MixerThread();
|
||||||
|
|||||||
Reference in New Issue
Block a user