System: Fix audio CD images not showing title

This commit is contained in:
Stenzek 2024-11-22 16:00:02 +10:00
parent 0079f7a285
commit b984f343ae
No known key found for this signature in database
1 changed files with 36 additions and 25 deletions

View File

@ -187,7 +187,7 @@ static void UpdateDisplayVSync();
static bool UpdateGameSettingsLayer(); static bool UpdateGameSettingsLayer();
static void UpdateInputSettingsLayer(std::string input_profile_name, std::unique_lock<std::mutex>& lock); static void UpdateInputSettingsLayer(std::string input_profile_name, std::unique_lock<std::mutex>& lock);
static void UpdateRunningGame(const std::string_view path, CDImage* image, bool booting); static void UpdateRunningGame(const std::string& path, CDImage* image, bool booting);
static bool CheckForRequiredSubQ(Error* error); static bool CheckForRequiredSubQ(Error* error);
static void UpdateControllers(); static void UpdateControllers();
@ -1780,7 +1780,7 @@ bool System::BootSystem(SystemBootParameters parameters, Error* error)
} }
// Update running game, this will apply settings as well. // Update running game, this will apply settings as well.
UpdateRunningGame(disc ? disc->GetPath().c_str() : parameters.filename.c_str(), disc.get(), true); UpdateRunningGame(disc ? disc->GetPath() : parameters.filename, disc.get(), true);
// Get boot EXE override. // Get boot EXE override.
if (!parameters.override_exe.empty()) if (!parameters.override_exe.empty())
@ -3981,7 +3981,7 @@ void System::RemoveMedia()
ClearMemorySaveStates(); ClearMemorySaveStates();
} }
void System::UpdateRunningGame(const std::string_view path, CDImage* image, bool booting) void System::UpdateRunningGame(const std::string& path, CDImage* image, bool booting)
{ {
if (!booting && s_state.running_game_path == path) if (!booting && s_state.running_game_path == path)
return; return;
@ -4032,8 +4032,10 @@ void System::UpdateRunningGame(const std::string_view path, CDImage* image, bool
} }
} }
} }
// Check for an audio CD. Those shouldn't set any title. else if (image)
else if (image && image->GetTrack(1).mode != CDImage::TrackMode::Audio) {
// Data discs should try to pull the title from the serial.
if (image->GetTrack(1).mode != CDImage::TrackMode::Audio)
{ {
std::string id; std::string id;
GetGameDetailsFromImage(image, &id, &s_state.running_game_hash); GetGameDetailsFromImage(image, &id, &s_state.running_game_hash);
@ -4048,7 +4050,9 @@ void System::UpdateRunningGame(const std::string_view path, CDImage* image, bool
else else
{ {
s_state.running_game_serial = std::move(id); s_state.running_game_serial = std::move(id);
if (s_state.running_game_title.empty())
// Don't display device names for unknown physical discs.
if (s_state.running_game_title.empty() && !CDImage::IsDeviceName(path.c_str()))
s_state.running_game_title = Path::GetFileTitle(FileSystem::GetDisplayNameFromPath(path)); s_state.running_game_title = Path::GetFileTitle(FileSystem::GetDisplayNameFromPath(path));
} }
@ -4062,6 +4066,13 @@ void System::UpdateRunningGame(const std::string_view path, CDImage* image, bool
} }
} }
} }
else
{
// Audio CDs can get the path from the filename, assuming it's not a physical disc.
if (!CDImage::IsDeviceName(path.c_str()))
s_state.running_game_title = Path::GetFileTitle(FileSystem::GetDisplayNameFromPath(path));
}
}
} }
if (!booting) if (!booting)