From b59290a835bc1c5aeeec5e3a535848bd8faeadb2 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sat, 3 Nov 2012 09:49:49 +0000 Subject: Preparation to use boost::shared_ptr. --- intern/audaspace/OpenAL/AUD_OpenALDevice.cpp | 33 ++++++++++++++++++-------- intern/audaspace/intern/AUD_SoftwareDevice.cpp | 33 +++++++++++++++++--------- 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp index 12b6d2e4f38..a114d8b8a87 100644 --- a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp +++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp @@ -174,21 +174,34 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::stop() if(!m_status) return false; - // AUD_XXX Create a reference of our own object so that it doesn't get - // deleted before the end of this function - AUD_Reference This = this; - - if(m_status == AUD_STATUS_PLAYING) - m_device->m_playingSounds.remove(This); - else - m_device->m_pausedSounds.remove(This); + m_status = AUD_STATUS_INVALID; alDeleteSources(1, &m_source); if(!m_isBuffered) alDeleteBuffers(CYCLE_BUFFERS, m_buffers); - m_status = AUD_STATUS_INVALID; - return true; + for(AUD_HandleIterator it = m_device->m_playingSounds.begin(); it != m_device->m_playingSounds.end(); it++) + { + if(it->get() == this) + { + AUD_Reference This = *it; + + m_device->m_playingSounds.erase(it); + + return true; + } + } + + for(AUD_HandleIterator it = m_device->m_pausedSounds.begin(); it != m_device->m_pausedSounds.end(); it++) + { + if(it->get() == this) + { + m_device->m_pausedSounds.erase(it); + return true; + } + } + + return false; } bool AUD_OpenALDevice::AUD_OpenALHandle::getKeep() diff --git a/intern/audaspace/intern/AUD_SoftwareDevice.cpp b/intern/audaspace/intern/AUD_SoftwareDevice.cpp index 14f0c6429e9..1fbd0ad82d2 100644 --- a/intern/audaspace/intern/AUD_SoftwareDevice.cpp +++ b/intern/audaspace/intern/AUD_SoftwareDevice.cpp @@ -277,22 +277,33 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::stop() if(!m_status) return false; - // AUD_XXX Create a reference of our own object so that it doesn't get - // deleted before the end of this function - AUD_Reference This = this; + m_status = AUD_STATUS_INVALID; - if(m_status == AUD_STATUS_PLAYING) + for(AUD_HandleIterator it = m_device->m_playingSounds.begin(); it != m_device->m_playingSounds.end(); it++) { - m_device->m_playingSounds.remove(This); + if(it->get() == this) + { + AUD_Reference This = *it; + + m_device->m_playingSounds.erase(it); - if(m_device->m_playingSounds.empty()) - m_device->playing(m_device->m_playback = false); + if(m_device->m_playingSounds.empty()) + m_device->playing(m_device->m_playback = false); + + return true; + } } - else - m_device->m_pausedSounds.remove(This); - m_status = AUD_STATUS_INVALID; - return true; + for(AUD_HandleIterator it = m_device->m_pausedSounds.begin(); it != m_device->m_pausedSounds.end(); it++) + { + if(it->get() == this) + { + m_device->m_pausedSounds.erase(it); + return true; + } + } + + return false; } bool AUD_SoftwareDevice::AUD_SoftwareHandle::getKeep() -- cgit v1.2.3