WwiseIOHookImpl.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*******************************************************************************
  2. The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
  3. Technology released in source code form as part of the game integration package.
  4. The content of this file may not be used without valid licenses to the
  5. AUDIOKINETIC Wwise Technology.
  6. Note that the use of the game engine is subject to the Unreal(R) Engine End User
  7. License Agreement at https://www.unrealengine.com/en-US/eula/unreal
  8. License Usage
  9. Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
  10. this file in accordance with the end user license agreement provided with the
  11. software or, alternatively, in accordance with the terms contained
  12. in a written agreement between you and Audiokinetic Inc.
  13. Copyright (c) 2023 Audiokinetic Inc.
  14. *******************************************************************************/
  15. #pragma once
  16. #include "Wwise/WwiseIOHook.h"
  17. #include "Wwise/WwiseExecutionQueue.h"
  18. #include "Templates/Atomic.h"
  19. class IWwiseStreamingManagerHooks;
  20. class WWISEFILEHANDLER_API FWwiseIOHookImpl : public FWwiseDefaultIOHook
  21. {
  22. public:
  23. FWwiseIOHookImpl();
  24. bool Init(const AkDeviceSettings& InDeviceSettings) override;
  25. /**
  26. * Opens a file, asynchronously.
  27. *
  28. * @param io_pOpenData File open information (name, flags, etc).
  29. * Also contain the callback to call when the open operation is completed,
  30. * and the AkFileDesc to fill out.
  31. */
  32. virtual void BatchOpen(
  33. AkUInt32 in_uNumFiles, // Number of files to open
  34. AkAsyncFileOpenData** in_ppItems // File open information (name, flags, etc)
  35. // Also contain the callback to call when the open operation is completed,
  36. // and the AkFileDesc to fill out.
  37. );
  38. /**
  39. * @brief Reads multiple data from multiple files (asynchronous).
  40. *
  41. * @param in_uNumTransfers Number of transfers to process
  42. * @param in_pTransferItems List of transfer items to process
  43. */
  44. virtual void BatchRead(
  45. AkUInt32 in_uNumTransfers,
  46. BatchIoTransferItem* in_pTransferItems
  47. ) override;
  48. /**
  49. * @brief Write multiple data from multiple files (asynchronous).
  50. *
  51. * @param in_uNumTransfers Number of transfers to process
  52. * @param in_pTransferItems List of transfer items to process
  53. */
  54. virtual void BatchWrite(
  55. AkUInt32 in_uNumTransfers,
  56. BatchIoTransferItem* in_pTransferItems
  57. ) override;
  58. /**
  59. * @brief Cancel IO from multiple files (asynchronous).
  60. *
  61. * @param in_uNumTransfers Number of transfers to process
  62. * @param in_pTransferItems List of transfer items to process
  63. */
  64. virtual void BatchCancel(
  65. AkUInt32 in_uNumTransfers,
  66. BatchIoTransferItem* in_pTransferItems,
  67. bool** io_ppbCancelAllTransfersForThisFile
  68. ) override;
  69. /**
  70. * Cleans up a file.
  71. *
  72. * @param in_fileDesc File descriptor.
  73. * @return AK_Success if operation was successful, error code otherwise
  74. */
  75. AKRESULT Close(AkFileDesc* in_pFileDesc) override;
  76. // Returns the block size for the file or its storage device.
  77. AkUInt32 GetBlockSize(AkFileDesc& in_fileDesc) override;
  78. // Returns a description for the streaming device above this low-level hook.
  79. void GetDeviceDesc(AkDeviceDesc& out_deviceDesc) override;
  80. // Returns custom profiling data: 1 if file opens are asynchronous, 0 otherwise.
  81. AkUInt32 GetDeviceData() override;
  82. protected:
  83. FWwiseExecutionQueue BatchExecutionQueue;
  84. AkDeviceID m_deviceID = AK_INVALID_DEVICE_ID;
  85. #ifndef AK_OPTIMIZED
  86. TAtomic<uint32> CurrentDeviceData;
  87. TAtomic<uint32> MaxDeviceData;
  88. #endif
  89. virtual IWwiseStreamingManagerHooks* GetStreamingHooks(const AkFileSystemFlags& InFileSystemFlag);
  90. virtual AKRESULT OpenFileForWrite(AkAsyncFileOpenData *io_pOpenData);
  91. virtual AKRESULT Open(AkAsyncFileOpenData* io_pOpenData);
  92. virtual AKRESULT Read(
  93. AkFileDesc& in_fileDesc,
  94. const AkIoHeuristics& in_heuristics,
  95. AkAsyncIOTransferInfo& io_transferInfo);
  96. virtual AKRESULT Write(
  97. AkFileDesc& in_fileDesc,
  98. const AkIoHeuristics& in_heuristics,
  99. AkAsyncIOTransferInfo& io_transferInfo);
  100. };