From 98b4ff12f4e42c302c69ac20903b198876fad836 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 12 Feb 2017 13:06:29 +0100 Subject: [PATCH] FileMonitor: Move file system parsing to DVD thread --- Source/Core/Core/FileMonitor.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/FileMonitor.cpp b/Source/Core/Core/FileMonitor.cpp index e5a4b3bc49..bb223cc578 100644 --- a/Source/Core/Core/FileMonitor.cpp +++ b/Source/Core/Core/FileMonitor.cpp @@ -21,6 +21,7 @@ namespace FileMonitor { +static const DiscIO::IVolume* s_volume = nullptr; static bool s_wii_disc; static std::unique_ptr s_filesystem; static std::string s_previous_file; @@ -53,9 +54,13 @@ static bool IsSoundFile(const std::string& filename) void SetFileSystem(const DiscIO::IVolume* volume) { - s_wii_disc = volume->GetVolumeType() == DiscIO::Platform::WII_DISC; - s_filesystem = DiscIO::CreateFileSystem(volume); - s_previous_file.clear(); + // Instead of creating the file system object right away, we will let Log + // create it later once we know that it actually will get used + s_volume = volume; + + // If the volume that was passed in was nullptr, Log won't try to create a + // file system object later, so we have to set s_filesystem to nullptr right away + s_filesystem = nullptr; } // Logs access to files in the file system set by SetFileSystem @@ -65,6 +70,17 @@ void Log(u64 offset, bool decrypt) if (!LogManager::GetInstance()->IsEnabled(LogTypes::FILEMON, LogTypes::LWARNING)) return; + // If a new volume has been set, use the file system of that volume + if (s_volume) + { + s_wii_disc = s_volume->GetVolumeType() == DiscIO::Platform::WII_DISC; + if (decrypt != s_wii_disc) + return; + s_filesystem = DiscIO::CreateFileSystem(s_volume); + s_volume = nullptr; + s_previous_file.clear(); + } + // For Wii discs, FileSystemGCWii will only load file systems from encrypted partitions if (decrypt != s_wii_disc) return;