From f4a30e473b23425c13a755854cf7b22c22cca259 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sat, 23 Jul 2011 16:08:37 +0000 Subject: =?UTF-8?q?Cherry=20pick=20merge:=20/branches/soc-2011-pepper/inte?= =?UTF-8?q?rn/audaspace/OpenAL:r38630=20Original=20log:=20Corrected=20the?= =?UTF-8?q?=20OpenAL=20device's=20threading=20code.=20This=20is=20a=20bugf?= =?UTF-8?q?ix=20for=20#27913,=20thanks=20to=20Juha=20M=C3=A4ki-Kanto=20for?= =?UTF-8?q?=20helping=20to=20resolve=20this.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- intern/audaspace/OpenAL/AUD_OpenALDevice.cpp | 18 +++++++++--------- intern/audaspace/OpenAL/AUD_OpenALDevice.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'intern/audaspace') diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp index b9e30bbf62a..71e7b7677e8 100644 --- a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp +++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp @@ -105,12 +105,15 @@ void* AUD_openalRunThread(void* device) return NULL; } -void AUD_OpenALDevice::start() +void AUD_OpenALDevice::start(bool join) { lock(); if(!m_playing) { + if(join) + pthread_join(m_thread, NULL); + pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); @@ -271,8 +274,8 @@ void AUD_OpenALDevice::updateStreams() // stop thread if(m_playingSounds->empty() || (cerr != ALC_NO_ERROR)) { - unlock(); m_playing = false; + unlock(); pthread_exit(NULL); } @@ -366,6 +369,8 @@ AUD_OpenALDevice::AUD_OpenALDevice(AUD_DeviceSpecs specs, int buffersize) pthread_mutex_init(&m_mutex, &attr); pthread_mutexattr_destroy(&attr); + + start(false); } AUD_OpenALDevice::~AUD_OpenALDevice() @@ -414,13 +419,8 @@ AUD_OpenALDevice::~AUD_OpenALDevice() alcProcessContext(m_context); // wait for the thread to stop - if(m_playing) - { - unlock(); - pthread_join(m_thread, NULL); - } - else - unlock(); + unlock(); + pthread_join(m_thread, NULL); delete m_playingSounds; delete m_pausedSounds; diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.h b/intern/audaspace/OpenAL/AUD_OpenALDevice.h index 3bbbe85d7e6..127f69beca8 100644 --- a/intern/audaspace/OpenAL/AUD_OpenALDevice.h +++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.h @@ -106,7 +106,7 @@ private: /** * Starts the streaming thread. */ - void start(); + void start(bool join = true); /** * Checks if a handle is valid. -- cgit v1.2.3