summaryrefslogtreecommitdiffstats
path: root/src/sound/oalsound/alsound.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sound/oalsound/alsound.cpp')
-rw-r--r--src/sound/oalsound/alsound.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp
index f683a62..b8dbcda 100644
--- a/src/sound/oalsound/alsound.cpp
+++ b/src/sound/oalsound/alsound.cpp
@@ -49,9 +49,14 @@ void ALSound::CleanUp()
if (mEnabled) {
GetLogger()->Info("Unloading files and closing device...\n");
StopAll();
+
+ for (auto channel : mChannels) {
+ delete channel.second;
+ }
- for (auto item : mSounds)
+ for (auto item : mSounds) {
delete item.second;
+ }
mEnabled = false;
alutExit();
@@ -213,7 +218,7 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
it.second->SetPriority(priority);
channel = it.first;
- bAlreadyLoaded = true;
+ bAlreadyLoaded = it.second->IsLoaded();
return true;
}
@@ -296,15 +301,20 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc
GetLogger()->Warn("Sound %d was not loaded!\n", sound);
return -1;
}
-
+
GetLogger()->Trace("ALSound::Play sound: %d volume: %f frequency: %f\n", sound, amplitude, frequency);
int channel;
bool bAlreadyLoaded;
if (!SearchFreeBuffer(sound, channel, bAlreadyLoaded))
return -1;
- if ( !bAlreadyLoaded ) {
- mChannels[channel]->SetBuffer(mSounds[sound]);
+
+ bAlreadyLoaded = false;
+ if (!bAlreadyLoaded) {
+ if (!mChannels[channel]->SetBuffer(mSounds[sound])) {
+ GetLogger()->Trace("ALSound::Play SetBuffer failed\n");
+ return -1;
+ }
}
Position(channel, pos);