mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
added rude's better SDL thread fix
This commit is contained in:
@@ -27,6 +27,7 @@ namespace audio
|
|||||||
namespace openal
|
namespace openal
|
||||||
{
|
{
|
||||||
Audio::Audio()
|
Audio::Audio()
|
||||||
|
: finish(false)
|
||||||
{
|
{
|
||||||
// Passing zero for default device.
|
// Passing zero for default device.
|
||||||
device = alcOpenDevice(0);
|
device = alcOpenDevice(0);
|
||||||
@@ -52,7 +53,10 @@ namespace openal
|
|||||||
|
|
||||||
Audio::~Audio()
|
Audio::~Audio()
|
||||||
{
|
{
|
||||||
//SDL_KillThread(thread);
|
finish = true;
|
||||||
|
|
||||||
|
int status;
|
||||||
|
SDL_WaitThread(thread, &status);
|
||||||
|
|
||||||
pool->stop();
|
pool->stop();
|
||||||
|
|
||||||
@@ -61,18 +65,13 @@ namespace openal
|
|||||||
alcMakeContextCurrent(0);
|
alcMakeContextCurrent(0);
|
||||||
alcDestroyContext(context);
|
alcDestroyContext(context);
|
||||||
alcCloseDevice(device);
|
alcCloseDevice(device);
|
||||||
|
|
||||||
printf("waiting on thread to finish...\n");
|
|
||||||
int status;
|
|
||||||
SDL_WaitThread(thread, &status);
|
|
||||||
printf("%d", status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Audio::run(void * d)
|
int Audio::run(void * d)
|
||||||
{
|
{
|
||||||
Audio * instance = (Audio*)d;
|
Audio * instance = (Audio*)d;
|
||||||
|
|
||||||
while(true)
|
while(!instance->finish)
|
||||||
{
|
{
|
||||||
instance->pool->update();
|
instance->pool->update();
|
||||||
SDL_Delay(10);
|
SDL_Delay(10);
|
||||||
|
|||||||
@@ -70,6 +70,11 @@ namespace openal
|
|||||||
// The Pool.
|
// The Pool.
|
||||||
Pool * pool;
|
Pool * pool;
|
||||||
|
|
||||||
|
// Set this to true when the thread should finish.
|
||||||
|
// Main thread will write to this value, and Audio::run
|
||||||
|
// will read from it.
|
||||||
|
bool finish;
|
||||||
|
|
||||||
static int run(void * unused);
|
static int run(void * unused);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user