WwiseMediaManagerImpl.cpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #include "Wwise/WwiseMediaManagerImpl.h"
  16. #include "Wwise/WwiseMediaFileState.h"
  17. #include "Wwise/Stats/FileHandler.h"
  18. FWwiseMediaManagerImpl::FWwiseMediaManagerImpl()
  19. {
  20. }
  21. FWwiseMediaManagerImpl::~FWwiseMediaManagerImpl()
  22. {
  23. }
  24. void FWwiseMediaManagerImpl::LoadMedia(const FWwiseMediaCookedData& InMediaCookedData, const FString& InRootPath, FLoadMediaCallback&& InCallback)
  25. {
  26. SCOPED_WWISEFILEHANDLER_EVENT_4(TEXT("FWwiseMediaManagerImpl::LoadMedia"));
  27. IncrementFileStateUseAsync(InMediaCookedData.MediaId, EWwiseFileStateOperationOrigin::Loading, [this, InMediaCookedData, InRootPath]() mutable
  28. {
  29. return CreateOp(InMediaCookedData, InRootPath);
  30. }, [InCallback = MoveTemp(InCallback)](const FWwiseFileStateSharedPtr, bool bInResult)
  31. {
  32. InCallback(bInResult);
  33. });
  34. }
  35. void FWwiseMediaManagerImpl::UnloadMedia(const FWwiseMediaCookedData& InMediaCookedData, const FString& InRootPath, FUnloadMediaCallback&& InCallback)
  36. {
  37. SCOPED_WWISEFILEHANDLER_EVENT_4(TEXT("FWwiseMediaManagerImpl::UnloadMedia"));
  38. DecrementFileStateUseAsync(InMediaCookedData.MediaId, nullptr, EWwiseFileStateOperationOrigin::Loading, MoveTemp(InCallback));
  39. }
  40. void FWwiseMediaManagerImpl::SetGranularity(AkUInt32 InStreamingGranularity)
  41. {
  42. SCOPED_WWISEFILEHANDLER_EVENT_4(TEXT("FWwiseMediaManagerImpl::SetGranularity"));
  43. StreamingGranularity = InStreamingGranularity;
  44. }
  45. FWwiseFileStateSharedPtr FWwiseMediaManagerImpl::CreateOp(const FWwiseMediaCookedData& InMediaCookedData, const FString& InRootPath)
  46. {
  47. if (InMediaCookedData.bStreaming)
  48. {
  49. return FWwiseFileStateSharedPtr(new FWwiseStreamedMediaFileState(InMediaCookedData, InRootPath, StreamingGranularity));
  50. }
  51. else
  52. {
  53. return FWwiseFileStateSharedPtr(new FWwiseInMemoryMediaFileState(InMediaCookedData, InRootPath));
  54. }
  55. }