Page MenuHome

svn_diff_AUD_OpenALDevice.cpp

File Metadata

Author
kanttori (kanttori)
Created
Nov 13 2013, 3:27 PM

svn_diff_AUD_OpenALDevice.cpp

Index: intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
===================================================================
--- intern/audaspace/OpenAL/AUD_OpenALDevice.cpp (revision 38452)
+++ intern/audaspace/OpenAL/AUD_OpenALDevice.cpp (working copy)
@@ -98,6 +98,8 @@
/**************************** Threading Code **********************************/
/******************************************************************************/
+
+static int has_been_running=0;
void* AUD_openalRunThread(void* device)
{
AUD_OpenALDevice* dev = (AUD_OpenALDevice*)device;
@@ -115,6 +117,10 @@
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+ // Let's not leave things hanging around
+ if(has_been_running) pthread_join(m_thread, NULL);
+ has_been_running = 1;
+
pthread_create(&m_thread, &attr, AUD_openalRunThread, this);
pthread_attr_destroy(&attr);
@@ -271,8 +277,9 @@
// stop thread
if(m_playingSounds->empty() || (cerr != ALC_NO_ERROR))
{
+ m_playing = false;
unlock();
- m_playing = false;
+
pthread_exit(NULL);
}
@@ -414,7 +421,7 @@
alcProcessContext(m_context);
// wait for the thread to stop
- if(m_playing)
+ if(m_playing || has_been_running)
{
unlock();
pthread_join(m_thread, NULL);

Event Timeline