AkFilePackage.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include "BFPlatform.h"
  2. #ifdef BF_WWISE_ENABLED
  3. //////////////////////////////////////////////////////////////////////
  4. //
  5. // AkFilePackage.h
  6. //
  7. // This class represents a file package that was created with the
  8. // AkFilePackager utility app (located in ($WWISESDK)/samples/FilePackager/).
  9. // It holds a system file handle and a look-up table (CAkFilePackageLUT).
  10. //
  11. // CAkFilePackage objects can be chained together using the ListFilePackages
  12. // typedef defined below.
  13. //
  14. // Copyright (c) 2007-2009 Audiokinetic Inc. / All Rights Reserved
  15. //
  16. //////////////////////////////////////////////////////////////////////
  17. #include "Common.h"
  18. #include "AkFilePackage.h"
  19. // Destroy file package and free memory / destroy pool.
  20. void CAkFilePackage::Destroy()
  21. {
  22. // Cache memory pointer and pool ID because memory pool is destroyed _after_ deleting this.
  23. AkMemPoolId poolID = m_poolID;
  24. void * pToRelease = m_pToRelease;
  25. bool bIsInternalPool = m_bIsInternalPool;
  26. // Call destructor.
  27. this->~CAkFilePackage();
  28. // Free memory.
  29. ClearMemory( poolID, pToRelease, bIsInternalPool );
  30. }
  31. void CAkFilePackage::ClearMemory(
  32. AkMemPoolId in_poolID, // Pool to destroy.
  33. void * in_pMemToRelease, // Memory block to free before destroying pool.
  34. bool in_bIsInternalPool // Pool was created internally (and needs to be destroyed).
  35. )
  36. {
  37. if ( in_poolID != AK_INVALID_POOL_ID )
  38. {
  39. if ( in_pMemToRelease )
  40. {
  41. if ( in_bIsInternalPool )
  42. {
  43. AK::MemoryMgr::ReleaseBlock( in_poolID, in_pMemToRelease );
  44. // Destroy pool
  45. AKVERIFY( AK::MemoryMgr::DestroyPool( in_poolID ) == AK_Success );
  46. }
  47. else
  48. {
  49. if ( AK::MemoryMgr::GetPoolAttributes( in_poolID ) & AkBlockMgmtMask )
  50. AK::MemoryMgr::ReleaseBlock( in_poolID, in_pMemToRelease );
  51. else
  52. AkFree( in_poolID, in_pMemToRelease );
  53. }
  54. }
  55. else
  56. AKASSERT( !in_bIsInternalPool ); // Internal pools allocation is guaranteed.
  57. }
  58. }
  59. #endif