Merge pull request #37 from JosJuice/dvd-thread-safety

DVDThread: Fix thread safety
This commit is contained in:
David Liu 2020-07-17 22:11:17 -04:00 committed by GitHub
commit 4b0e7a2e99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -396,16 +396,19 @@ static void DVDThread()
} }
} }
void ReadFile(std::string& fileName, std::vector<u8>& buf) { void ReadFile(std::string& fileName, std::vector<u8>& buf)
if (HasDisc()) { {
if (HasDisc())
{
WaitUntilIdle();
const DiscIO::FileSystem* filesystem = s_disc->GetFileSystem(DiscIO::PARTITION_NONE); const DiscIO::FileSystem* filesystem = s_disc->GetFileSystem(DiscIO::PARTITION_NONE);
auto fileInfo = filesystem->FindFileInfo(fileName); auto fileInfo = filesystem->FindFileInfo(fileName);
auto fileSize = fileInfo->GetSize(); auto fileSize = fileInfo->GetSize();
WaitUntilIdle();
buf.resize(fileSize); buf.resize(fileSize);
DiscIO::ReadFile(*s_disc, DiscIO::PARTITION_NONE, fileInfo.get(), buf.data(), fileSize); DiscIO::ReadFile(*s_disc, DiscIO::PARTITION_NONE, fileInfo.get(), buf.data(), fileSize);
} }
else { else
{
INFO_LOG(SLIPPI, "Failed to open file: %s", fileName.c_str()); INFO_LOG(SLIPPI, "Failed to open file: %s", fileName.c_str());
} }
} }