FileIOHandler_wwise_Default.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <FileIOHandler_wwise.h>
  9. #include <AzCore/IO/FileIO.h>
  10. #include <IAudioInterfacesCommonData.h>
  11. #include <AK/Tools/Common/AkPlatformFuncs.h>
  12. #include <AudioEngineWwise_Traits_Platform.h>
  13. namespace Audio::Platform
  14. {
  15. AkFileHandle GetAkFileHandle(AZ::IO::HandleType realFileHandle)
  16. {
  17. return (AkFileHandle)static_cast<uintptr_t>(realFileHandle);
  18. }
  19. AZ::IO::HandleType GetRealFileHandle(AkFileHandle akFileHandle)
  20. {
  21. // On 64 bit systems, strict compilers throw an error trying to reinterpret_cast
  22. // from AkFileHandle (a 64 bit pointer) to AZ::IO::HandleType (a uint32_t) because:
  23. //
  24. // cast from pointer to smaller type 'AZ::IO::HandleType' (aka 'unsigned int') loses information
  25. //
  26. // However, this is safe because AkFileHandle is a "blind" type that serves as a token.
  27. // We create the token and hand it off, and it is handed back whenever file IO is done.
  28. return static_cast<AZ::IO::HandleType>((uintptr_t)akFileHandle);
  29. }
  30. void SetThreadProperties(AkThreadProperties& threadProperties)
  31. {
  32. threadProperties.dwAffinityMask = AZ_TRAIT_AUDIOENGINEWWISE_FILEIO_AKDEVICE_THREAD_AFFINITY_MASK;
  33. }
  34. } // namespace Audio::Platform