diff options
author | krzys-h <krzys_h@interia.pl> | 2014-07-01 12:15:38 +0200 |
---|---|---|
committer | krzys-h <krzys_h@interia.pl> | 2014-07-01 12:16:32 +0200 |
commit | d9fee8b2adad613cf8c10d153cd5cd7b261b7863 (patch) | |
tree | f6b71cc2daa719c10c1ce31cf738e1c6ec934a73 /src/sound/oalsound/channel.cpp | |
parent | 0f2adf05fd2b2b38c2b84aa8d72b3fd756dcfcd4 (diff) | |
parent | 1835d2ae580525603308206f7b8e6b4552b3ca0f (diff) | |
download | colobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.tar.gz colobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.tar.bz2 colobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.zip |
Release 0.1.3-alpha
Diffstat (limited to 'src/sound/oalsound/channel.cpp')
-rw-r--r-- | src/sound/oalsound/channel.cpp | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/src/sound/oalsound/channel.cpp b/src/sound/oalsound/channel.cpp index 4d89df5..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,38 +70,41 @@ 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; } - -bool Channel::SetPan(Math::Vector pos) +bool Channel::Pause() { - if (!m_ready || m_buffer == nullptr) + if(!m_ready || !IsPlaying()) { return false; } - - alSource3f(m_source, AL_POSITION, pos.x, pos.y, pos.z); + + alSourcePause(m_source); if (alCheck()) { - GetLogger()->Warn("Could not set sound position. Code: %d\n", alGetCode()); - return false; + GetLogger()->Debug("Could not pause audio sound source. Code: %d\n", alGetCode()); } return true; } -void Channel::SetPosition(Math::Vector pos) +bool Channel::SetPosition(const Math::Vector &pos) { - m_position = pos; -} - + if (!m_ready || m_buffer == nullptr) + { + return false; + } -Math::Vector Channel::GetPosition() -{ - return m_position; + alSource3f(m_source, AL_POSITION, pos.x, pos.y, pos.z); + if (alCheck()) + { + GetLogger()->Debug("Could not set sound position. Code: %d\n", alGetCode()); + return false; + } + return true; } @@ -114,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; @@ -132,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; } @@ -150,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; @@ -168,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; } @@ -431,3 +435,15 @@ bool Channel::IsMuted() return m_mute; } + +void Channel::Reset() +{ + m_id++; +} + + +int Channel::GetId() +{ + return m_id; +} + |