FileMonitor: Move file system parsing to DVD thread

This commit is contained in:
JosJuice 2017-02-12 13:06:29 +01:00
parent b470fa5454
commit 98b4ff12f4
1 changed files with 19 additions and 3 deletions

View File

@ -21,6 +21,7 @@
namespace FileMonitor namespace FileMonitor
{ {
static const DiscIO::IVolume* s_volume = nullptr;
static bool s_wii_disc; static bool s_wii_disc;
static std::unique_ptr<DiscIO::IFileSystem> s_filesystem; static std::unique_ptr<DiscIO::IFileSystem> s_filesystem;
static std::string s_previous_file; static std::string s_previous_file;
@ -53,9 +54,13 @@ static bool IsSoundFile(const std::string& filename)
void SetFileSystem(const DiscIO::IVolume* volume) void SetFileSystem(const DiscIO::IVolume* volume)
{ {
s_wii_disc = volume->GetVolumeType() == DiscIO::Platform::WII_DISC; // Instead of creating the file system object right away, we will let Log
s_filesystem = DiscIO::CreateFileSystem(volume); // create it later once we know that it actually will get used
s_previous_file.clear(); 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 // 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)) if (!LogManager::GetInstance()->IsEnabled(LogTypes::FILEMON, LogTypes::LWARNING))
return; 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 // For Wii discs, FileSystemGCWii will only load file systems from encrypted partitions
if (decrypt != s_wii_disc) if (decrypt != s_wii_disc)
return; return;