Removing dependencies on legacy code (#2358)

* Removes use of gEnv->mMainThreadId

Save off the thread id that was used when initializing audio system and
connecting EBuses, use that instead of gEnv.

Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com>

* Replace uses of gEnv->pCryPak with AZ::IO

Updated uses of pCryPak to instead go through the AZ::IO::FileIOBase
instance.

Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com>
This commit is contained in:
amzn-phist
2021-07-26 15:29:00 -05:00
committed by GitHub
parent 61f91d4a9a
commit 900cc08510
3 changed files with 80 additions and 63 deletions
@@ -9,12 +9,12 @@
#include <FileCacheManager.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/IO/IStreamer.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/std/string/conversions.h>
#include <AzCore/std/parallel/binary_semaphore.h>
#include <AzCore/StringFunc/StringFunc.h>
#include <AzFramework/Archive/IArchive.h>
#include <AudioAllocators.h>
#include <AudioInternalInterfaces.h>
@@ -115,9 +115,9 @@ namespace Audio
newAudioFileEntry->m_dataScope = dataScope;
AZStd::to_lower(newAudioFileEntry->m_filePath.begin(), newAudioFileEntry->m_filePath.end());
const size_t fileSize = gEnv->pCryPak->FGetSize(newAudioFileEntry->m_filePath.c_str());
if (fileSize > 0)
auto fileIO = AZ::IO::FileIOBase::GetInstance();
if (AZ::u64 fileSize = 0;
fileIO->Size(newAudioFileEntry->m_filePath.c_str(), fileSize) && fileSize != 0)
{
newAudioFileEntry->m_fileSize = fileSize;
newAudioFileEntry->m_flags.ClearFlags(eAFF_NOTFOUND);
@@ -770,9 +770,12 @@ namespace Audio
}
AZStd::to_lower(audioFileEntry->m_filePath.begin(), audioFileEntry->m_filePath.end());
audioFileEntry->m_fileSize = gEnv->pCryPak->FGetSize(audioFileEntry->m_filePath.c_str());
AZ::u64 fileSize = 0;
auto fileIO = AZ::IO::FileIOBase::GetInstance();
fileIO->Size(audioFileEntry->m_filePath.c_str(), fileSize);
audioFileEntry->m_fileSize = fileSize;
AZ_Assert(audioFileEntry->m_fileSize > 0, "FileCacheManager - UpdateLocalizedFileEntryData expected file size to be greater than zero!");
AZ_Assert(audioFileEntry->m_fileSize != 0, "FileCacheManager - UpdateLocalizedFileEntryData expected file size to be greater than zero!");
}
///////////////////////////////////////////////////////////////////////////////////////////////