Replaced Common::Thread with a partial implementation of std::thread. (rvalue references are used if available, <thread> is used if possible) Eliminates the need to use dynamic memory allocation for threads, so it's impossible to forget to delete a thread or set a pointer to NULL. Enables use of type-safe thread functions, no need to cast to and from void*. I've made sure the code compiles in vs08 and tested the functionality of "StdThread.h" on Linux so I'm hoping everything will work :p. In the future "StdThread.h" can be removed (maybe when OS X ships with gcc 4.4 and vs2015 is released :p).

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6933 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Jordan Woyak
2011-01-27 20:47:58 +00:00
parent 0371f15c23
commit 2c05c49a04
29 changed files with 484 additions and 396 deletions

View File

@ -91,10 +91,9 @@ bool DSound::WriteDataToBuffer(DWORD dwOffset, // Our own write
}
// The audio thread.
THREAD_RETURN soundThread(void* args)
void soundThread(DSound* dsound)
{
(reinterpret_cast<DSound *>(args))->SoundLoop();
return 0;
dsound->SoundLoop();
}
void DSound::SoundLoop()
@ -138,7 +137,7 @@ bool DSound::Start()
dsBuffer->Lock(0, bufferSize, (void* *)&p1, &num1, 0, 0, 0);
memset(p1, 0, num1);
dsBuffer->Unlock(p1, num1, 0, 0);
thread = new Common::Thread(soundThread, (void *)this);
thread = std::thread(soundThread, this);
return true;
}
@ -179,8 +178,7 @@ void DSound::Stop()
// kick the thread if it's waiting
soundSyncEvent.Set();
delete thread;
thread = NULL;
thread.join();
dsBuffer->Stop();
dsBuffer->Release();
ds->Release();