summaryrefslogtreecommitdiffstats
path: root/src/sound/oalsound/alsound.cpp
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2013-01-07 19:43:04 +0100
committerPiotr Dziwinski <piotrdz@gmail.com>2013-01-07 19:43:04 +0100
commit5a6b3f005a83363d323e00b499756d6ecc277574 (patch)
tree7d18ebbb9dd63f2c160ff011ef29e24d49c12efa /src/sound/oalsound/alsound.cpp
parentedb1c0cbd62bfe7c620d7c8399f49acb98994b85 (diff)
parentff5c89085415a370911793d5764dfb694fc43b7d (diff)
downloadcolobot-5a6b3f005a83363d323e00b499756d6ecc277574.tar.gz
colobot-5a6b3f005a83363d323e00b499756d6ecc277574.tar.bz2
colobot-5a6b3f005a83363d323e00b499756d6ecc277574.zip
Merge dev and dev-graphics
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);