diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 5ce793168..ad21aefbe 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -78,16 +78,16 @@ class OpenAL_SoundStream : public Sound { // This should be something sane, like 4, but currently cell loads tend to // cause the stream to underrun - static const ALuint NumBuffers = 150; - static const ALuint BufferSize = 32768; + static const ALuint sNumBuffers = 150; + static const ALuint sBufferSize = 32768; - ALuint Source; - ALuint Buffers[NumBuffers]; + ALuint mSource; + ALuint mBuffers[sNumBuffers]; - ALenum Format; - ALsizei SampleRate; + ALenum mFormat; + ALsizei mSampleRate; - DecoderPtr Decoder; + DecoderPtr mDecoder; public: OpenAL_SoundStream(DecoderPtr decoder); @@ -102,8 +102,8 @@ public: class OpenAL_Sound : public Sound { public: - ALuint Source; - ALuint Buffer; + ALuint mSource; + ALuint mBuffer; OpenAL_Sound(ALuint src, ALuint buf); virtual ~OpenAL_Sound(); @@ -115,20 +115,20 @@ public: OpenAL_SoundStream::OpenAL_SoundStream(DecoderPtr decoder) - : Decoder(decoder) + : mDecoder(decoder) { throwALerror(); - alGenSources(1, &Source); + alGenSources(1, &mSource); throwALerror(); try { - alGenBuffers(NumBuffers, Buffers); + alGenBuffers(sNumBuffers, mBuffers); throwALerror(); } catch(std::exception &e) { - alDeleteSources(1, &Source); + alDeleteSources(1, &mSource); alGetError(); throw; } @@ -139,53 +139,53 @@ OpenAL_SoundStream::OpenAL_SoundStream(DecoderPtr decoder) Sound_Decoder::ChannelConfig chans; Sound_Decoder::SampleType type; - Decoder->GetInfo(&srate, &chans, &type); - Format = getALFormat(chans, type); - SampleRate = srate; + mDecoder->GetInfo(&srate, &chans, &type); + mFormat = getALFormat(chans, type); + mSampleRate = srate; } catch(std::exception &e) { - alDeleteSources(1, &Source); - alDeleteBuffers(NumBuffers, Buffers); + alDeleteSources(1, &mSource); + alDeleteBuffers(sNumBuffers, mBuffers); alGetError(); throw; } } OpenAL_SoundStream::~OpenAL_SoundStream() { - alDeleteSources(1, &Source); - alDeleteBuffers(NumBuffers, Buffers); + alDeleteSources(1, &mSource); + alDeleteBuffers(sNumBuffers, mBuffers); alGetError(); - Decoder->Close(); + mDecoder->Close(); } void OpenAL_SoundStream::Play(float volume, float pitch) { - std::vector data(BufferSize); + std::vector data(sBufferSize); - alSourceStop(Source); - alSourcei(Source, AL_BUFFER, 0); - alSourcef(Source, AL_GAIN, volume); - alSourcef(Source, AL_PITCH, pitch); + alSourceStop(mSource); + alSourcei(mSource, AL_BUFFER, 0); + alSourcef(mSource, AL_GAIN, volume); + alSourcef(mSource, AL_PITCH, pitch); throwALerror(); - for(ALuint i = 0;i < NumBuffers;i++) + for(ALuint i = 0;i < sNumBuffers;i++) { size_t got; - got = Decoder->Read(&data[0], data.size()); - alBufferData(Buffers[i], Format, &data[0], got, SampleRate); + got = mDecoder->Read(&data[0], data.size()); + alBufferData(mBuffers[i], mFormat, &data[0], got, mSampleRate); } throwALerror(); - alSourceQueueBuffers(Source, NumBuffers, Buffers); - alSourcePlay(Source); + alSourceQueueBuffers(mSource, sNumBuffers, mBuffers); + alSourcePlay(mSource); throwALerror(); } void OpenAL_SoundStream::Stop() { - alSourceStop(Source); - alSourcei(Source, AL_BUFFER, 0); + alSourceStop(mSource); + alSourcei(mSource, AL_BUFFER, 0); throwALerror(); // FIXME: Rewind decoder } @@ -194,25 +194,25 @@ bool OpenAL_SoundStream::isPlaying() { ALint processed, state; - alGetSourcei(Source, AL_SOURCE_STATE, &state); - alGetSourcei(Source, AL_BUFFERS_PROCESSED, &processed); + alGetSourcei(mSource, AL_SOURCE_STATE, &state); + alGetSourcei(mSource, AL_BUFFERS_PROCESSED, &processed); throwALerror(); if(processed > 0) { - std::vector data(BufferSize); + std::vector data(sBufferSize); do { ALuint bufid; size_t got; - alSourceUnqueueBuffers(Source, 1, &bufid); + alSourceUnqueueBuffers(mSource, 1, &bufid); processed--; - got = Decoder->Read(&data[0], data.size()); + got = mDecoder->Read(&data[0], data.size()); if(got > 0) { - alBufferData(bufid, Format, &data[0], got, SampleRate); - alSourceQueueBuffers(Source, 1, &bufid); + alBufferData(bufid, mFormat, &data[0], got, mSampleRate); + alSourceQueueBuffers(mSource, 1, &bufid); } } while(processed > 0); throwALerror(); @@ -222,12 +222,12 @@ bool OpenAL_SoundStream::isPlaying() { ALint queued; - alGetSourcei(Source, AL_BUFFERS_QUEUED, &queued); + alGetSourcei(mSource, AL_BUFFERS_QUEUED, &queued); throwALerror(); if(queued == 0) return false; - alSourcePlay(Source); + alSourcePlay(mSource); throwALerror(); } @@ -236,27 +236,27 @@ bool OpenAL_SoundStream::isPlaying() void OpenAL_SoundStream::Update(const float *pos) { - alSource3f(Source, AL_POSITION, pos[0], pos[2], -pos[1]); - alSource3f(Source, AL_DIRECTION, 0.0f, 0.0f, 0.0f); - alSource3f(Source, AL_VELOCITY, 0.0f, 0.0f, 0.0f); + alSource3f(mSource, AL_POSITION, pos[0], pos[2], -pos[1]); + alSource3f(mSource, AL_DIRECTION, 0.0f, 0.0f, 0.0f); + alSource3f(mSource, AL_VELOCITY, 0.0f, 0.0f, 0.0f); throwALerror(); } OpenAL_Sound::OpenAL_Sound(ALuint src, ALuint buf) - : Source(src), Buffer(buf) + : mSource(src), mBuffer(buf) { } OpenAL_Sound::~OpenAL_Sound() { - alDeleteSources(1, &Source); - alDeleteBuffers(1, &Buffer); + alDeleteSources(1, &mSource); + alDeleteBuffers(1, &mBuffer); alGetError(); } void OpenAL_Sound::Stop() { - alSourceStop(Source); + alSourceStop(mSource); throwALerror(); } @@ -264,7 +264,7 @@ bool OpenAL_Sound::isPlaying() { ALint state; - alGetSourcei(Source, AL_SOURCE_STATE, &state); + alGetSourcei(mSource, AL_SOURCE_STATE, &state); throwALerror(); return state==AL_PLAYING; @@ -272,35 +272,35 @@ bool OpenAL_Sound::isPlaying() void OpenAL_Sound::Update(const float *pos) { - alSource3f(Source, AL_POSITION, pos[0], pos[2], -pos[1]); - alSource3f(Source, AL_DIRECTION, 0.0f, 0.0f, 0.0f); - alSource3f(Source, AL_VELOCITY, 0.0f, 0.0f, 0.0f); + alSource3f(mSource, AL_POSITION, pos[0], pos[2], -pos[1]); + alSource3f(mSource, AL_DIRECTION, 0.0f, 0.0f, 0.0f); + alSource3f(mSource, AL_VELOCITY, 0.0f, 0.0f, 0.0f); throwALerror(); } -bool OpenAL_Output::Initialize(const std::string &devname) +bool OpenAL_Output::init(const std::string &devname) { - if(Context) + if(mContext) fail("Device already initialized"); - Device = alcOpenDevice(devname.c_str()); - if(!Device) + mDevice = alcOpenDevice(devname.c_str()); + if(!mDevice) { std::cout << "Failed to open \""<Open(fname); ALuint src=0, buf=0; @@ -368,12 +368,12 @@ Sound* OpenAL_Output::PlaySound(const std::string &fname, float volume, float pi return sound.release(); } -Sound* OpenAL_Output::PlaySound3D(const std::string &fname, const float *pos, float volume, float pitch, +Sound* OpenAL_Output::playSound3D(const std::string &fname, const float *pos, float volume, float pitch, float min, float max, bool loop) { throwALerror(); - DecoderPtr decoder = mgr.getDecoder(); + DecoderPtr decoder = mManager.getDecoder(); decoder->Open(fname); ALuint src=0, buf=0; @@ -417,11 +417,11 @@ Sound* OpenAL_Output::PlaySound3D(const std::string &fname, const float *pos, fl } -Sound* OpenAL_Output::StreamSound(const std::string &fname, float volume, float pitch) +Sound* OpenAL_Output::streamSound(const std::string &fname, float volume, float pitch) { std::auto_ptr sound; - DecoderPtr decoder = mgr.getDecoder(); + DecoderPtr decoder = mManager.getDecoder(); decoder->Open(fname); sound.reset(new OpenAL_SoundStream(decoder)); @@ -431,7 +431,7 @@ Sound* OpenAL_Output::StreamSound(const std::string &fname, float volume, float } -void OpenAL_Output::UpdateListener(const float *pos, const float *atdir, const float *updir) +void OpenAL_Output::updateListener(const float *pos, const float *atdir, const float *updir) { float orient[6] = { atdir[0], atdir[2], -atdir[1], @@ -445,13 +445,13 @@ void OpenAL_Output::UpdateListener(const float *pos, const float *atdir, const f OpenAL_Output::OpenAL_Output(SoundManager &mgr) - : Sound_Output(mgr), Device(0), Context(0) + : Sound_Output(mgr), mDevice(0), mContext(0) { } OpenAL_Output::~OpenAL_Output() { - Deinitialize(); + deinit(); } } diff --git a/apps/openmw/mwsound/openal_output.hpp b/apps/openmw/mwsound/openal_output.hpp index 7d5bd25f6..25c414c6d 100644 --- a/apps/openmw/mwsound/openal_output.hpp +++ b/apps/openmw/mwsound/openal_output.hpp @@ -16,19 +16,19 @@ namespace MWSound class OpenAL_Output : public Sound_Output { - ALCdevice *Device; - ALCcontext *Context; + ALCdevice *mDevice; + ALCcontext *mContext; - virtual bool Initialize(const std::string &devname=""); - virtual void Deinitialize(); + virtual bool init(const std::string &devname=""); + virtual void deinit(); - virtual Sound *PlaySound(const std::string &fname, float volume, float pitch, bool loop); - virtual Sound *PlaySound3D(const std::string &fname, const float *pos, float volume, float pitch, + virtual Sound *playSound(const std::string &fname, float volume, float pitch, bool loop); + virtual Sound *playSound3D(const std::string &fname, const float *pos, float volume, float pitch, float min, float max, bool loop); - virtual Sound *StreamSound(const std::string &fname, float volume, float pitch); + virtual Sound *streamSound(const std::string &fname, float volume, float pitch); - virtual void UpdateListener(const float *pos, const float *atdir, const float *updir); + virtual void updateListener(const float *pos, const float *atdir, const float *updir); OpenAL_Output(SoundManager &mgr); virtual ~OpenAL_Output(); diff --git a/apps/openmw/mwsound/sound_output.hpp b/apps/openmw/mwsound/sound_output.hpp index 8dfc0f21e..6497cc1bd 100644 --- a/apps/openmw/mwsound/sound_output.hpp +++ b/apps/openmw/mwsound/sound_output.hpp @@ -14,19 +14,19 @@ namespace MWSound class Sound_Output { - SoundManager &mgr; + SoundManager &mManager; - virtual bool Initialize(const std::string &devname="") = 0; - virtual void Deinitialize() = 0; + virtual bool init(const std::string &devname="") = 0; + virtual void deinit() = 0; - virtual Sound *PlaySound(const std::string &fname, float volume, float pitch, bool loop) = 0; - virtual Sound *PlaySound3D(const std::string &fname, const float *pos, float volume, float pitch, + virtual Sound *playSound(const std::string &fname, float volume, float pitch, bool loop) = 0; + virtual Sound *playSound3D(const std::string &fname, const float *pos, float volume, float pitch, float min, float max, bool loop) = 0; - virtual Sound *StreamSound(const std::string &fname, float volume, float pitch) = 0; + virtual Sound *streamSound(const std::string &fname, float volume, float pitch) = 0; - virtual void UpdateListener(const float *pos, const float *atdir, const float *updir) = 0; + virtual void updateListener(const float *pos, const float *atdir, const float *updir) = 0; - Sound_Output(SoundManager &mgr) : mgr(mgr) { } + Sound_Output(SoundManager &mgr) : mManager(mgr) { } public: virtual ~Sound_Output() { } diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index d78251ef1..c496701c7 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -48,7 +48,7 @@ namespace MWSound std::cout << "Sound decoder: " << SOUND_IN << std::endl; mOutput.reset(new DEFAULT_OUTPUT(*this)); - if(!mOutput->Initialize()) + if(!mOutput->init()) { mOutput.reset(); return; @@ -130,7 +130,7 @@ namespace MWSound { Sound *sound; const ESM::Position &pos = ptr.getCellRef().pos; - sound = mOutput->PlaySound3D(file, pos.pos, volume, pitch, min, max, loop); + sound = mOutput->playSound3D(file, pos.pos, volume, pitch, min, max, loop); if(untracked) mLooseSounds[id] = SoundPtr(sound); else @@ -167,7 +167,7 @@ namespace MWSound { if(mMusic) mMusic->Stop(); - mMusic.reset(mOutput->StreamSound(filename, 0.4f, 1.0f)); + mMusic.reset(mOutput->streamSound(filename, 0.4f, 1.0f)); } void SoundManager::streamMusic(const std::string& filename) @@ -277,7 +277,7 @@ namespace MWSound try { Sound *sound; - sound = mOutput->PlaySound(file, volume, pitch, loop); + sound = mOutput->playSound(file, volume, pitch, loop); mLooseSounds[soundId] = SoundPtr(sound); } catch(std::exception &e) @@ -443,7 +443,7 @@ namespace MWSound float pos[3] = { nPos[0], -nPos[2], nPos[1] }; float at[3] = { nDir[0], -nDir[2], nDir[1] }; float up[3] = { nUp[0], -nUp[2], nUp[1] }; - mOutput->UpdateListener(pos, at, up); + mOutput->updateListener(pos, at, up); // Check if any "untracked" sounds are finished playing, and trash // them