DVDThread: Fix thread safety

GetFileSystem will read from the volume the first time it is
called, so it should only be called after WaitUntilIdle.
This commit is contained in:
JosJuice 2020-07-17 22:16:43 +02:00
commit e97b78d8c7

View file

@ -396,16 +396,19 @@ static void DVDThread()
}
}
void ReadFile(std::string& fileName, std::vector<u8>& buf) {
if (HasDisc()) {
void ReadFile(std::string& fileName, std::vector<u8>& buf)
{
if (HasDisc())
{
WaitUntilIdle();
const DiscIO::FileSystem* filesystem = s_disc->GetFileSystem(DiscIO::PARTITION_NONE);
auto fileInfo = filesystem->FindFileInfo(fileName);
auto fileSize = fileInfo->GetSize();
WaitUntilIdle();
buf.resize(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());
}
}