summaryrefslogtreecommitdiffstats
path: root/src/sound/oalsound/channel.cpp
diff options
context:
space:
mode:
authorerihel <erihel@gmail.com>2014-01-18 03:42:07 +0100
committererihel <erihel@gmail.com>2014-01-18 03:42:07 +0100
commitc5ae2610b57e54216ee55214bd74368c9c7e22ee (patch)
tree25dae6ea13879af464ffbb807c6d93eff552c66e /src/sound/oalsound/channel.cpp
parent652dc6081df8dc73bc9f57c031420e498be71451 (diff)
downloadcolobot-c5ae2610b57e54216ee55214bd74368c9c7e22ee.tar.gz
colobot-c5ae2610b57e54216ee55214bd74368c9c7e22ee.tar.bz2
colobot-c5ae2610b57e54216ee55214bd74368c9c7e22ee.zip
Minor changes to sound support.
* changed channel limit from 64 to 2048 that will decrease if error is found while trying to play sound * added id to each channel to avoid collisions when more than 1 object tries to modify a sound * minor formatting changes
Diffstat (limited to 'src/sound/oalsound/channel.cpp')
-rw-r--r--src/sound/oalsound/channel.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/sound/oalsound/channel.cpp b/src/sound/oalsound/channel.cpp
index e58ab54..7021c2f 100644
--- a/src/sound/oalsound/channel.cpp
+++ b/src/sound/oalsound/channel.cpp
@@ -23,7 +23,7 @@ Channel::Channel()
if (alCheck())
{
- GetLogger()->Warn("Failed to create sound source. Code: %d\n", alGetCode());
+ GetLogger()->Debug("Failed to create sound source. Code: %d\n", alGetCode());
m_ready = false;
}
else
@@ -40,6 +40,7 @@ Channel::Channel()
m_startFrequency = 0.0f;
m_changeFrequency = 0.0f;
m_volume = 0.0f;
+ m_id = 0;
}
@@ -51,7 +52,7 @@ Channel::~Channel()
alSourcei(m_source, AL_BUFFER, 0);
alDeleteSources(1, &m_source);
if (alCheck())
- GetLogger()->Warn("Failed to delete sound source. Code: %d\n", alGetCode());
+ GetLogger()->Debug("Failed to delete sound source. Code: %d\n", alGetCode());
}
}
@@ -69,7 +70,7 @@ bool Channel::Play()
alSourcePlay(m_source);
if (alCheck())
{
- GetLogger()->Warn("Could not play audio sound source. Code: %d\n", alGetCode());
+ GetLogger()->Debug("Could not play audio sound source. Code: %d\n", alGetCode());
}
return true;
}
@@ -84,7 +85,7 @@ bool Channel::Pause()
alSourcePause(m_source);
if (alCheck())
{
- GetLogger()->Warn("Could not pause audio sound source. Code: %d\n", alGetCode());
+ GetLogger()->Debug("Could not pause audio sound source. Code: %d\n", alGetCode());
}
return true;
}
@@ -100,7 +101,7 @@ bool Channel::SetPosition(const Math::Vector &pos)
alSource3f(m_source, AL_POSITION, pos.x, pos.y, pos.z);
if (alCheck())
{
- GetLogger()->Warn("Could not set sound position. Code: %d\n", alGetCode());
+ GetLogger()->Debug("Could not set sound position. Code: %d\n", alGetCode());
return false;
}
return true;
@@ -117,7 +118,7 @@ bool Channel::SetFrequency(float freq)
alSourcef(m_source, AL_PITCH, freq);
if (alCheck())
{
- GetLogger()->Warn("Could not set sound pitch to '%f'. Code: %d\n", freq, alGetCode());
+ GetLogger()->Debug("Could not set sound pitch to '%f'. Code: %d\n", freq, alGetCode());
return false;
}
return true;
@@ -135,7 +136,7 @@ float Channel::GetFrequency()
alGetSourcef(m_source, AL_PITCH, &freq);
if (alCheck())
{
- GetLogger()->Warn("Could not get sound pitch. Code: %d\n", alGetCode());
+ GetLogger()->Debug("Could not get sound pitch. Code: %d\n", alGetCode());
return 0;
}
@@ -153,7 +154,7 @@ bool Channel::SetVolume(float vol)
alSourcef(m_source, AL_GAIN, vol);
if (alCheck())
{
- GetLogger()->Warn("Could not set sound volume to '%f'. Code: %d\n", vol, alGetCode());
+ GetLogger()->Debug("Could not set sound volume to '%f'. Code: %d\n", vol, alGetCode());
return false;
}
return true;
@@ -171,7 +172,7 @@ float Channel::GetVolume()
alGetSourcef(m_source, AL_GAIN, &vol);
if (alCheck())
{
- GetLogger()->Warn("Could not get sound volume. Code: %d\n", alGetCode());
+ GetLogger()->Debug("Could not get sound volume. Code: %d\n", alGetCode());
return 0;
}
@@ -434,3 +435,15 @@ bool Channel::IsMuted()
return m_mute;
}
+
+void Channel::Reset()
+{
+ m_id++;
+}
+
+
+int Channel::GetId()
+{
+ return m_id;
+}
+