void SFXFMODDevice::update()
{
   Parent::update();

   if( smEventSystem )
   {
      FModAssert( smFunc->FMOD_EventSystem_Update( smEventSystem ), "Failed to update event system!" );
   }
   else
   {
      FModAssert(smFunc->FMOD_System_Update(smSystem), "Failed to update system!");
   }
}
Esempio n. 2
0
void SFXFMODProvider::init()
{
#ifdef TORQUE_FMOD_STATIC

   // FMOD statically linked.
   
   mFMod.isLoaded = true;
   #define FMOD_FUNCTION(fn_name, fn_args) \
      (*(void**)&mFMod.fn_name.fn) = &fn_name;
   
   #ifndef TORQUE_FMOD_NO_EVENTS
   mFMod.eventIsLoaded = true;
      #define FMOD_EVENT_FUNCTION(fn_name, fn_args) \
         (*(void**)&mFMod.fn_name.fn) = &fn_name;
   #else
      #define FMOD_EVENT_FUNCTION( fn_name, fn_args )
   #endif

   #include FMOD_FN_FILE
   
   #undef FMOD_FUNCTION
   #undef FMOD_EVENT_FUNCTION
   
#else

   // FMOD dynamically linked.
   
   const char* dllName;
   const char* pDllName; // plugin-based DLL
   const char* eventDllName;
   
#ifdef TORQUE_OS_WIN32
   dllName = "fmodex.dll";
   pDllName = "fmodexp.dll";
   eventDllName = "fmod_event.dll";
#elif defined( TORQUE_OS_MAC )
   dllName = "libfmodex.dylib";
   pDllName = "libfmodexp.dylib";
   eventDllName = "libfmodevent.dylib";
#else
#  warning Need to set FMOD DLL filename for platform.
   return;
#endif

   // Grab the functions we'll want from the fmod DLL.
   mFMod.dllRef = OsLoadLibrary( dllName );

   // Try the plugin-based version.
   if( !mFMod.dllRef )
      mFMod.dllRef = OsLoadLibrary( pDllName );

   if(!mFMod.dllRef)
   {
      Con::warnf( "SFXFMODProvider - Could not locate '%s' or '%s' - FMOD  not available.", dllName, pDllName );
      return;
   }
   
   mFMod.eventDllRef = OsLoadLibrary( eventDllName );
   if(!mFMod.eventDllRef)
      Con::warnf( "SFXFMODProvider - Could not locate %s - FMOD Designer integration not available.", eventDllName );

   mFMod.isLoaded = true;
   mFMod.eventIsLoaded = true;

   #define FMOD_FUNCTION(fn_name, fn_args) \
      mFMod.isLoaded &= fmodBindFunction(mFMod.dllRef, *(void**)&mFMod.fn_name.fn, #fn_name);
   #define FMOD_EVENT_FUNCTION(fn_name, fn_args) \
      mFMod.eventIsLoaded &= fmodBindFunction(mFMod.eventDllRef, *(void**)&mFMod.fn_name.fn, #fn_name);
            
   #include FMOD_FN_FILE
   
   #undef FMOD_FUNCTION
   #undef FMOD_EVENT_FUNCTION

   if(mFMod.isLoaded == false)
   {
      Con::warnf("SFXFMODProvider - Could not load %s - FMOD not available.", dllName);
      return;
   }
   if( !mFMod.eventIsLoaded && mFMod.eventDllRef )
      Con::warnf("SFXFMODProvider - Could not load %s - FMOD Designer integration not available.", eventDllName);

#endif

   FMOD_RESULT res;

   // Create the FMOD system object.
      
   if( !_createSystem() )
      return;
      
   // Check that the Ex API version is OK.
   
   unsigned int version;
   res = mFMod.FMOD_System_GetVersion(SFXFMODDevice::smSystem, &version);
   FModAssert(res, "SFXFMODProvider - Failed to get FMOD version!");

   Con::printf( "SFXFMODProvider - FMOD Ex API version: %x.%x.%x",
      ( version & 0xffff0000 ) >> 16,
      ( version & 0x0000ff00 ) >> 8,
      ( version & 0x000000ff )
   );

   if(version < FMOD_VERSION)
   {
      Con::warnf("SFXFMODProvider - FMOD Ex API version in DLL is too old - FMOD  not available.");
      return;
   }
   
   // Check that the Designer API version is ok.
   
   if( mFMod.eventIsLoaded )
   {
      res = mFMod.FMOD_EventSystem_GetVersion( SFXFMODDevice::smEventSystem, &version );
      FModAssert(res, "SFXFMODProvider - Failed to get FMOD version!");
      
      Con::printf( "SFXFMODProvider - FMOD Designer API version: %x.%x.%x",
         ( version & 0xffff0000 ) >> 16,
         ( version & 0x0000ff00 ) >> 8,
         ( version & 0x000000ff )
      );

      if( version < FMOD_EVENT_VERSION )
      {
         Con::errorf( "SFXFMODProvider - FMOD Designer API version in DLL is too old!" );
         return;
      }
   }