From c65d5ca77db88303bc62d0f92c52365229d0c306 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Mon, 10 Mar 2014 04:40:08 +0100 Subject: [PATCH] OPENAL BUG FIXED, FFS --- Escape-the-Dawn/Systems/SoundsSystem.cpp | 103 +---------------------- 1 file changed, 2 insertions(+), 101 deletions(-) diff --git a/Escape-the-Dawn/Systems/SoundsSystem.cpp b/Escape-the-Dawn/Systems/SoundsSystem.cpp index af04006..aac7de2 100644 --- a/Escape-the-Dawn/Systems/SoundsSystem.cpp +++ b/Escape-the-Dawn/Systems/SoundsSystem.cpp @@ -6,7 +6,6 @@ Systems::SoundSystem::SoundSystem(World* world) : System(world) { - //initialize OpenAL ALCdevice* Device = alcOpenDevice(NULL); @@ -21,7 +20,6 @@ Systems::SoundSystem::SoundSystem(World* world) } alGetError(); - } void Systems::SoundSystem::Update(double dt) @@ -51,54 +49,18 @@ void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID par //Listener alListenerfv(AL_POSITION, listenerPos); - ALenum error; - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - } alListenerfv(AL_VELOCITY, listenerVel); - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - } alListenerfv(AL_ORIENTATION, listenerOri); - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - } } auto soundEmitter = m_World->GetComponent(entity, "SoundEmitter"); if(soundEmitter != nullptr) { ALuint source = m_Source[soundEmitter.get()]; - - ALenum error; - alSourcef(source, AL_GAIN, soundEmitter->Gain); //Volume - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - } alSourcei(source, AL_MAX_DISTANCE, soundEmitter->MaxDistance); - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - } alSourcei(source, AL_REFERENCE_DISTANCE, soundEmitter->ReferenceDistance); - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - } alSourcef(source, AL_PITCH, soundEmitter->Pitch); - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - } alSourcei(source, AL_LOOPING, soundEmitter->Loop); - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - } glm::vec3 emitterPos = transformComponent->Position; ALfloat sourcePos[3] = { emitterPos.x, emitterPos.y, emitterPos.z }; @@ -107,17 +69,7 @@ void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID par ALfloat sourceVel[3] = { emitterVel.x, emitterVel.y, emitterVel.z }; alSourcefv(source, AL_POSITION, sourcePos); - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - } alSourcefv(source, AL_VELOCITY, sourceVel); - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - } - - } } @@ -126,19 +78,7 @@ void Systems::SoundSystem::PlaySound(std::shared_ptr e ALuint buffer = LoadFile(fileName); ALuint source = m_Source[emitter.get()]; alSourcei(source, AL_BUFFER, buffer); - ALenum error; - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - exit(EXIT_FAILURE); - } alSourcePlay(m_Source[emitter.get()]); - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - exit(EXIT_FAILURE); - - } } void Systems::SoundSystem::OnComponentCreated(std::string type, std::shared_ptr component) @@ -215,21 +155,10 @@ ALuint Systems::SoundSystem::LoadFile(std::string fileName) else if (channels == 2) format = AL_FORMAT_STEREO16; } + ALuint buffer; alGenBuffers(1, &buffer); - ALenum error; - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - exit(EXIT_FAILURE); - } alBufferData(buffer, format, buf, dataSize, sampleRate); - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - exit(EXIT_FAILURE); - - } //delete[] buf; m_BufferCache[fileName] = buffer; @@ -239,41 +168,13 @@ ALuint Systems::SoundSystem::LoadFile(std::string fileName) ALuint Systems::SoundSystem::CreateSource() { ALuint source; - alGenBuffers((ALuint)1, &source); - - ALenum error; - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - exit(EXIT_FAILURE); - - } + alGenSources((ALuint)1, &source); alSourcef(source, AL_GAIN, 1); //Volume - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - } alSourcef(source, AL_PITCH, 1); - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - } alSourcei(source, AL_LOOPING, AL_FALSE); - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - } alSource3f(source, AL_POSITION, 0, 0, 0); - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - } alSource3f(source, AL_VELOCITY, 0, 0, 0); - if ((error = alGetError()) != AL_NO_ERROR) - { - LOG_ERROR("AL Error: %d", error); - } return source; } \ No newline at end of file