* Fix bug where OpenAL resources never get released

* Remove unused function release from cAudioSource interface
This commit is contained in:
Murat Suri 2011-06-05 13:56:16 +00:00
parent 83a61f0494
commit 43dfdb841c
3 changed files with 15 additions and 22 deletions

View File

@ -58,7 +58,6 @@ namespace cAudio
virtual int getCurrentCompressedAudioPosition();
virtual bool update();
virtual void release();
virtual const bool isValid() const;
virtual const bool isPlaying() const;
@ -123,7 +122,6 @@ namespace cAudio
virtual void removeFilter();
#endif
protected:
private:
//! Mutex for thread synchronization
cAudioMutex Mutex;

View File

@ -78,9 +78,6 @@ namespace cAudio
//! Normally called every frame by the audio manager to update the internal buffers. Note: For internal use only.
virtual bool update() = 0;
//! Releases all resources used by the audio source, normally used to clean up before deletion. Note: For internal use only.
virtual void release() = 0;
//! Returns if the source is ready to be used.
virtual const bool isValid() const = 0;

View File

@ -66,8 +66,6 @@ namespace cAudio
cAudioSource::~cAudioSource()
{
cAudioMutexBasicLock lock(Mutex);
if(Decoder)
Decoder->drop();
#if CAUDIO_EFX_ENABLED == 1
for(int i=0; i<CAUDIO_SOURCE_MAX_EFFECT_SLOTS; ++i)
@ -81,6 +79,21 @@ namespace cAudio
Filter->drop();
Filter = NULL;
#endif
//Stops the audio Source
alSourceStop(Source);
empty();
//Deletes the source
alDeleteSources(1, &Source);
//deletes the last filled buffer
alDeleteBuffers(CAUDIO_SOURCE_NUM_BUFFERS, Buffers);
checkError();
getLogger()->logDebug("Audio Source", "Audio source released.");
signalEvent(ON_RELEASE);
if(Decoder)
Decoder->drop();
unRegisterAllEventHandlers();
}
@ -285,21 +298,6 @@ namespace cAudio
return active;
}
void cAudioSource::release()
{
cAudioMutexBasicLock lock(Mutex);
//Stops the audio Source
alSourceStop(Source);
empty();
//Deletes the source
alDeleteSources(1, &Source);
//deletes the last filled buffer
alDeleteBuffers(CAUDIO_SOURCE_NUM_BUFFERS, Buffers);
checkError();
getLogger()->logDebug("Audio Source", "Audio source released.");
signalEvent(ON_RELEASE);
}
const bool cAudioSource::isValid() const
{
return Valid;