X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FSound.cc;fp=src%2FMoof%2FSound.cc;h=c78b35c613b972d919b51de87db0c4cbc215d503;hp=f8f05baf75717aa376ae85eaebc950fc79d8db5e;hb=837bae9f2bf7b25e1d3d2625eeaf39c1d2f48827;hpb=81ff940d1bea07447f8218ab9a764fbf393431e8 diff --git a/src/Moof/Sound.cc b/src/Moof/Sound.cc index f8f05ba..c78b35c 100644 --- a/src/Moof/Sound.cc +++ b/src/Moof/Sound.cc @@ -1,30 +1,13 @@ -/******************************************************************************* - - Copyright (c) 2009, Charles McGarvey - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*******************************************************************************/ +/*] Copyright (c) 2009-2010, Charles McGarvey [************************** +**] All rights reserved. +* +* vi:ts=4 sw=4 tw=75 +* +* Distributable under the terms and conditions of the 2-clause BSD license; +* see the file COPYING for a complete text of the license. +* +**************************************************************************/ #include #include @@ -98,7 +81,7 @@ public: if (result < 0) { logWarning << "couldn't load sound: " << path << std::endl; - throw Error(Error::UNKNOWN_AUDIO_FORMAT, path); + Error(Error::UNKNOWN_AUDIO_FORMAT, path).raise(); } vorbis_info* vorbisInfo = ov_info(&mOggStream, -1); @@ -338,7 +321,8 @@ public: { // nothing more to play, stopping... mIsPlaying = false; - std::remove(mBuffers.begin(), mBuffers.end(), bufferObj); + std::remove(mBuffers.begin(), mBuffers.end(), + bufferObj); } } } @@ -346,8 +330,8 @@ public: ALenum state; alGetSourcei(mSource, AL_SOURCE_STATE, &state); - // restart playing if we're stopped but supposed to be playing... this - // means we didn't queue enough and the audio skipped :-( + // restart playing if we're stopped but supposed to be playing... + // this means we didn't queue enough and the audio skipped :-( if (mIsPlaying && state != AL_PLAYING) { alSourcePlay(mSource); @@ -425,8 +409,8 @@ public: { // don't let the music die! update(); - // TODO - might be nice to also allow using threads for streaming rather - // than a timer, probably as a compile-time option + // TODO - might be nice to also allow using threads for streaming + // rather than a timer, probably as a compile-time option } static void retainBackend() @@ -446,7 +430,8 @@ public: { alcMakeContextCurrent(gAlContext); logInfo << "opened sound device `" - << alcGetString(gAlDevice, ALC_DEFAULT_DEVICE_SPECIFIER) + << alcGetString(gAlDevice, + ALC_DEFAULT_DEVICE_SPECIFIER) << "'" << std::endl; } } @@ -563,21 +548,18 @@ void Sound::setLooping(bool looping) void Sound::setListenerPosition(const Vector3& position) { - //alListener3f(AL_POSITION, float(position[0]), float(position[1]), - //float(position[2])); float vec[] = {position[0], position[1], position[2]}; alListenerfv(AL_POSITION, vec); } void Sound::setListenerVelocity(const Vector3& velocity) { - //alListener3f(AL_VELOCITY, float(velocity[0]), float(velocity[1]), - //float(velocity[2])); float vec[] = {velocity[0], velocity[1], velocity[2]}; alListenerfv(AL_VELOCITY, vec); } -void Sound::setListenerOrientation(const Vector3& forward, const Vector3& up) +void Sound::setListenerOrientation(const Vector3& forward, + const Vector3& up) { float vec[6]; vec[0] = float(forward[0]); @@ -606,7 +588,7 @@ std::string Sound::getPath(const std::string& name) } -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void SoundStream::enqueue(const std::string& name) @@ -625,5 +607,3 @@ void SoundStream::play() } // namespace Mf -/** vim: set ts=4 sw=4 tw=80: *************************************************/ -