1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-21 12:49:10 +00:00

Use hsThread for SoundBuffer preloading.

This commit is contained in:
Darryl Pogue
2011-06-26 16:14:47 -07:00
parent 90223e723e
commit c699ae8ab6
2 changed files with 89 additions and 66 deletions

View File

@ -39,7 +39,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnKeyedObject/hsKeyedObject.h"
#include "plAudioCore.h"
#include "plAudioFileReader.h"
#include "pnUtils/pnUtils.h"
#include "hsThread.h"
//// Class Definition ////////////////////////////////////////////////////////
@ -55,8 +55,6 @@ public:
CLASSNAME_REGISTER( plSoundBuffer );
GETINTERFACE_ANY( plSoundBuffer, hsKeyedObject );
LINK(plSoundBuffer) link;
enum Flags
{
kIsExternal = 0x0001,
@ -143,4 +141,38 @@ protected:
plAudioFileReader *IGetReader( hsBool fullpath );
};
class plSoundPreloader : public hsThread
{
protected:
hsTArray<plSoundBuffer*> fBuffers;
hsEvent fEvent;
bool fRunning;
hsMutex fCritSect;
public:
virtual hsError Run();
virtual void Start() {
fRunning = true;
hsThread::Start();
}
virtual void Stop() {
fRunning = false;
fEvent.Signal();
hsThread::Stop();
}
bool IsRunning() const { return fRunning; }
void AddBuffer(plSoundBuffer* buffer) {
fCritSect.Lock();
fBuffers.Push(buffer);
fCritSect.Unlock();
fEvent.Signal();
}
};
#endif //_plSoundBuffer_h