diff --git a/intern/SoundSystem/openal/SND_OpenALDevice.cpp b/intern/SoundSystem/openal/SND_OpenALDevice.cpp index 6eea000559d..a7f7b075efa 100644 --- a/intern/SoundSystem/openal/SND_OpenALDevice.cpp +++ b/intern/SoundSystem/openal/SND_OpenALDevice.cpp @@ -60,6 +60,8 @@ #endif #include +#include + /* untill openal gets unified we need this hack for non-windows systems */ #if !defined(WIN32) && !defined(ALC_MAJOR_VERSION) @@ -208,7 +210,8 @@ ALvoid alutUnloadWAV(ALenum format,ALvoid *data,ALsizei size,ALsizei freq) SND_OpenALDevice::SND_OpenALDevice() - : m_context(NULL), + : SND_AudioDevice(), + m_context(NULL), m_device(NULL) { /* Removed the functionality for checking if noaudio was provided on */ @@ -235,6 +238,20 @@ SND_OpenALDevice::SND_OpenALDevice() alcMakeContextCurrent(m_context); m_audio = true; m_device = dev; +#ifdef __linux__ + /* + * SIGHUP Hack: + * + * On Linux, alcDestroyContext generates a SIGHUP (Hangup) when killing the OpenAL + * mixer thread, which kills Blender. + * + * So we set the signal to ignore.... + * + * TODO: check if this applies to other platforms. + * + */ + signal(SIGHUP, SIG_IGN); +#endif } } @@ -307,19 +324,33 @@ void SND_OpenALDevice::MakeCurrent() const SND_OpenALDevice::~SND_OpenALDevice() { + MakeCurrent(); + + if (m_buffersinitialized) + { + alDeleteBuffers(NUM_BUFFERS, m_buffers); + m_buffersinitialized = false; + } + + if (m_sourcesinitialized) + { + for (int i = 0; i < NUM_SOURCES; i++) + alSourceStop(m_sources[i]); + + alDeleteSources(NUM_SOURCES, m_sources); + m_sourcesinitialized = false; + } + if (m_context) { MakeCurrent(); - - if (m_buffersinitialized) - alDeleteBuffers(NUM_BUFFERS, m_buffers); - - if (m_sourcesinitialized) - alDeleteSources(NUM_SOURCES, m_sources); - alcDestroyContext(m_context); m_context = NULL; } +#ifdef __linux__ + // restore the signal state above. + signal(SIGHUP, SIG_DFL); +#endif // let's see if we used the cd. if not, just leave it alone SND_CDObject* pCD = SND_CDObject::Instance(); diff --git a/intern/SoundSystem/openal/SND_OpenALDevice.h b/intern/SoundSystem/openal/SND_OpenALDevice.h index 4cd386cd48d..e54c0443462 100644 --- a/intern/SoundSystem/openal/SND_OpenALDevice.h +++ b/intern/SoundSystem/openal/SND_OpenALDevice.h @@ -41,7 +41,7 @@ class SND_OpenALDevice : public SND_AudioDevice { public: SND_OpenALDevice(); - ~SND_OpenALDevice(); + virtual ~SND_OpenALDevice(); SND_WaveSlot* LoadSample(const STR_String& samplename, void* memlocation,