Merge pull request #22983 from hrydgard/umd-swap-and-audio-stream

UMD swap: Own the loader ResolveFileLoaderTarget returns
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2026-11-08 09:16:29 +01:00
commit bfd58279e2
1 file changed
+10 -5
+10 -5
View File
@@ -388,14 +388,12 @@ bool UmdMount(const Path &filepath, FileLoader **fileLoader, std::string &error)
delete loadedFile;
return false;
}
UpdateLoadedFile(loadedFile);
std::string errorString;
IdentifiedFileType fileType;
// Can delete loadedFile and return another, or return a ZipFileLoader that owns it, so what it
// returns is what g_loadedFile owns.
loadedFile = ResolveFileLoaderTarget(loadedFile, &fileType, &errorString);
*fileLoader = loadedFile;
switch (fileType) {
case IdentifiedFileType::PSP_ISO:
case IdentifiedFileType::PSP_ISO_NP:
@@ -403,14 +401,21 @@ bool UmdMount(const Path &filepath, FileLoader **fileLoader, std::string &error)
case IdentifiedFileType::PSP_UMD_VIDEO_ISO:
if (!MountGameISO(loadedFile, &error)) {
error = "mounting the ISO failed: " + error;
delete loadedFile;
return false;
}
break;
default:
error = "Unsupported file type: " + std::string(IdentifiedFileTypeToString(fileType)) + " " + errorString;
delete loadedFile;
return false;
break;
}
// Only now, with the old disc's file systems replaced, is the old loader unused: a swap that
// fails leaves the old disc mounted. Reads hold pspFileSystem's lock, which Mount takes, so none
// is still going on the IO thread either.
UpdateLoadedFile(loadedFile);
*fileLoader = loadedFile;
return true;
}