sfxALDevice.h

Engine/source/sfx/openal/sfxALDevice.h

More...

Classes:

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _SFXALDEVICE_H_
 25#define _SFXALDEVICE_H_
 26
 27class SFXProvider;
 28
 29#ifndef _SFXDEVICE_H_
 30#  include "sfx/sfxDevice.h"
 31#endif
 32
 33#ifndef _SFXPROVIDER_H_
 34#  include "sfx/sfxProvider.h"
 35#endif
 36
 37#ifndef _SFXALBUFFER_H_
 38#  include "sfx/openal/sfxALBuffer.h"
 39#endif
 40
 41#ifndef _SFXALVOICE_H_
 42#  include "sfx/openal/sfxALVoice.h"
 43#endif
 44
 45#ifndef _OPENALFNTABLE
 46#  include "sfx/openal/LoadOAL.h"
 47#endif
 48
 49
 50class SFXALDevice : public SFXDevice
 51{
 52   public:
 53
 54      typedef SFXDevice Parent;
 55      friend class SFXALVoice; // mDistanceFactor, mRolloffFactor
 56
 57      SFXALDevice(   SFXProvider *provider, 
 58                     const OPENALFNTABLE &openal, 
 59                     String name, 
 60                     bool useHardware, 
 61                     S32 maxBuffers );
 62
 63      virtual ~SFXALDevice();
 64
 65   protected:
 66
 67      OPENALFNTABLE mOpenAL;
 68
 69      ALCcontext *mContext;
 70
 71      ALCdevice *mDevice;
 72      
 73      SFXDistanceModel mDistanceModel;
 74      F32 mDistanceFactor;
 75      F32 mRolloffFactor;
 76      F32 mUserRolloffFactor;
 77      
 78      void _setRolloffFactor( F32 factor );
 79
 80   public:
 81
 82      // SFXDevice.
 83      virtual SFXBuffer* createBuffer( const ThreadSafeRef< SFXStream>& stream, SFXDescription* description );
 84      virtual SFXVoice* createVoice( bool is3D, SFXBuffer *buffer );
 85      virtual void setListener( U32 index, const SFXListenerProperties& listener );
 86      virtual void setDistanceModel( SFXDistanceModel model );
 87      virtual void setDopplerFactor( F32 factor );
 88      virtual void setRolloffFactor( F32 factor );
 89#if defined(AL_ALEXT_PROTOTYPES)
 90      //function for openAL to open slots
 91      virtual void openSlots();
 92      //slots
 93      ALuint   effectSlot[4] = { 0 };
 94      ALuint   effect[2] = { 0 };
 95      ALuint   uLoop;
 96      //get values from sfxreverbproperties and pass it to openal device
 97      virtual void setReverb(const SFXReverbProperties& reverb);
 98#endif
 99      virtual void resetReverb() {}
100};
101
102#endif // _SFXALDEVICE_H_
103