PageRenderTime 10ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llaudio/lllistener_openal.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 110 lines | 61 code | 18 blank | 31 comment | 0 complexity | 523b501681d72adcbad6fabe5eb2d6cd MD5 | raw file
  1/**
  2 * @file audioengine_openal.cpp
  3 * @brief implementation of audio engine using OpenAL
  4 * support as a OpenAL 3D implementation
  5 *
  6 * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  7 * Second Life Viewer Source Code
  8 * Copyright (C) 2010, Linden Research, Inc.
  9 * 
 10 * This library is free software; you can redistribute it and/or
 11 * modify it under the terms of the GNU Lesser General Public
 12 * License as published by the Free Software Foundation;
 13 * version 2.1 of the License only.
 14 * 
 15 * This library is distributed in the hope that it will be useful,
 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 18 * Lesser General Public License for more details.
 19 * 
 20 * You should have received a copy of the GNU Lesser General Public
 21 * License along with this library; if not, write to the Free Software
 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 23 * 
 24 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 25 * $/LicenseInfo$
 26 */
 27
 28#include "linden_common.h"
 29#include "llaudioengine.h"
 30
 31#include "lllistener_openal.h"
 32
 33LLListener_OpenAL::LLListener_OpenAL()
 34{
 35	init();
 36}
 37
 38LLListener_OpenAL::~LLListener_OpenAL()
 39{
 40}
 41
 42void LLListener_OpenAL::translate(LLVector3 offset)
 43{
 44	//llinfos << "LLListener_OpenAL::translate() : " << offset << llendl;
 45	LLListener::translate(offset);
 46}
 47
 48void LLListener_OpenAL::setPosition(LLVector3 pos)
 49{
 50	//llinfos << "LLListener_OpenAL::setPosition() : " << pos << llendl;
 51	LLListener::setPosition(pos);
 52}
 53
 54void LLListener_OpenAL::setVelocity(LLVector3 vel)
 55{
 56	LLListener::setVelocity(vel);
 57}
 58
 59void LLListener_OpenAL::orient(LLVector3 up, LLVector3 at)
 60{
 61	//llinfos << "LLListener_OpenAL::orient() up: " << up << " at: " << at << llendl;
 62	LLListener::orient(up, at);
 63}
 64
 65void LLListener_OpenAL::commitDeferredChanges()
 66{
 67	ALfloat orientation[6];
 68	orientation[0] = mListenAt.mV[0];
 69	orientation[1] = mListenAt.mV[1];
 70	orientation[2] = mListenAt.mV[2];
 71	orientation[3] = mListenUp.mV[0];
 72	orientation[4] = mListenUp.mV[1];
 73	orientation[5] = mListenUp.mV[2];
 74
 75	ALfloat velocity[3];
 76	velocity[0] = mVelocity.mV[0];
 77	velocity[1] = mVelocity.mV[1];
 78	velocity[2] = mVelocity.mV[2];
 79
 80	alListenerfv(AL_ORIENTATION, orientation);
 81	alListenerfv(AL_POSITION, mPosition.mV);
 82	alListenerfv(AL_VELOCITY, velocity);
 83}
 84
 85void LLListener_OpenAL::setDopplerFactor(F32 factor)
 86{
 87	//llinfos << "LLListener_OpenAL::setDopplerFactor() : " << factor << llendl;
 88	alDopplerFactor(factor);
 89}
 90
 91F32 LLListener_OpenAL::getDopplerFactor()
 92{
 93	ALfloat factor;
 94	factor = alGetFloat(AL_DOPPLER_FACTOR);
 95	//llinfos << "LLListener_OpenAL::getDopplerFactor() : " << factor << llendl;
 96	return factor;
 97}
 98
 99
100void LLListener_OpenAL::setRolloffFactor(F32 factor)
101{
102	mRolloffFactor = factor;
103}
104
105F32 LLListener_OpenAL::getRolloffFactor()
106{
107	return mRolloffFactor;
108}
109
110