sfxDSDevice.h

Engine/source/sfx/dsound/sfxDSDevice.h

More...

Classes:

class

The DirectSound device implementation exposes a couple of settings to script that you should be aware of:

Public Defines

define
DS_FUNCTION(fn_name, fn_return, fn_args)    typedef fn_return ( *DSFNPTR##fn_name##)##fn_args##;
define
DS_FUNCTION(fn_name, fn_return, fn_args)    DSFNPTR##fn_name fn_name;

Public Functions

DSAssert(HRESULT hr, const char * info)

Helper for asserting on dsound HRESULTS.

Detailed Description

Public Defines

DS_FUNCTION(fn_name, fn_return, fn_args)    typedef fn_return ( *DSFNPTR##fn_name##)##fn_args##;
DS_FUNCTION(fn_name, fn_return, fn_args)    DSFNPTR##fn_name fn_name;

Public Functions

DSAssert(HRESULT hr, const char * info)

Helper for asserting on dsound HRESULTS.

  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 _SFXDSDEVICE_H_
 25#define _SFXDSDEVICE_H_
 26
 27#ifndef _STRINGFUNCTIONS_H_
 28#  include "core/strings/stringFunctions.h"
 29#endif
 30#ifndef _SFXDEVICE_H_
 31   #include "sfx/sfxDevice.h"
 32#endif
 33#ifndef _SFXDSVOICE_H_
 34   #include "sfx/dsound/sfxDSVoice.h"
 35#endif
 36#ifndef OS_DLIBRARY_H
 37   #include "platform/platformDlibrary.h"
 38#endif
 39
 40#include <dsound.h>
 41
 42// Typedefs
 43#define DS_FUNCTION(fn_name, fn_return, fn_args) \
 44   typedef fn_return (WINAPI *DSFNPTR##fn_name##)##fn_args##;
 45#include "sfx/dsound/dsFunctions.h"
 46#undef DS_FUNCTION
 47
 48// Function table
 49struct DSoundFNTable
 50{
 51   DSoundFNTable() : isLoaded( false ) {};
 52   bool isLoaded;
 53   DLibraryRef dllRef;
 54
 55#define DS_FUNCTION(fn_name, fn_return, fn_args) \
 56   DSFNPTR##fn_name fn_name;
 57#include "sfx/dsound/dsFunctions.h"
 58#undef DS_FUNCTION
 59};
 60
 61
 62/// Helper for asserting on dsound HRESULTS.
 63inline void DSAssert( HRESULT hr, const char *info ) 
 64{
 65   #ifdef TORQUE_DEBUG
 66
 67      if( FAILED( hr ) ) 
 68      {
 69         char buf[256];
 70         dSprintf( buf, 256, "Error code: %x\n%s", hr, info );
 71         AssertFatal( false, buf );
 72      }
 73
 74   #endif
 75}
 76
 77
 78/// The DirectSound device implementation exposes a couple
 79/// of settings to script that you should be aware of:
 80///
 81///   $DirectSound::dopplerFactor - This controls the scale of 
 82///   the doppler effect.  Valid factors are 0.0 to 10.0 and it
 83///   defaults to 0.75.
 84///
 85///   $DirectSound::distanceFactor - This sets the unit conversion
 86///   for 
 87///
 88///   $DirectSound::rolloffFactor - ;
 89///
 90///
 91class SFXDSDevice : public SFXDevice
 92{
 93      typedef SFXDevice Parent;
 94   
 95      friend class SFXDSVoice;
 96      friend class SFXDSProvider; // _init
 97
 98   public:
 99
100      //explicit SFXDSDevice();
101
102      SFXDSDevice(   SFXProvider* provider, 
103                     DSoundFNTable *dsFnTbl, 
104                     GUID* guid, 
105                     String name, 
106                     bool useHardware, 
107                     S32 maxBuffers );
108
109      virtual ~SFXDSDevice();
110
111   protected:
112
113      IDirectSound8 *mDSound;
114
115      IDirectSound3DListener8 *mListener;
116
117      IDirectSoundBuffer *mPrimaryBuffer;
118
119      DSoundFNTable *mDSoundTbl;
120
121      DSCAPS mCaps;
122
123      GUID* mGUID;
124
125      bool _init();
126
127      /// Called from SFXDSVoice to commit any deferred
128      /// settings before playback begins.
129      void _commitDeferred();
130
131   public:
132
133      // SFXDevice
134      virtual SFXBuffer* createBuffer( const ThreadSafeRef< SFXStream>& stream, SFXDescription* description );
135      virtual SFXVoice* createVoice( bool is3D, SFXBuffer *buffer );
136      virtual void update();
137      virtual void setListener( U32 index, const SFXListenerProperties& listener );
138      virtual void setDistanceModel( SFXDistanceModel mode );
139      virtual void setDopplerFactor( F32 factor );
140      virtual void setRolloffFactor( F32 factor );
141};
142
143#endif // _SFXDSDEVICE_H_
144