From b608e80d8e5b3b99249b156369b9ceb1db4ad3d7 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Thu, 20 Dec 2018 17:52:41 +0100 Subject: [PATCH] Don't do automatic disc switching when running e.g. the Wii Menu We only want automatic disc switching to happen when the game actually is running, but software like the Wii Menu also uses DVDLowStopMotor. --- Source/Core/Core/HW/DVD/DVDInterface.cpp | 3 ++- Source/Core/Core/HW/DVD/DVDThread.cpp | 10 ++++++++++ Source/Core/Core/HW/DVD/DVDThread.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/HW/DVD/DVDInterface.cpp b/Source/Core/Core/HW/DVD/DVDInterface.cpp index b335be618c..f83aa54bbc 100644 --- a/Source/Core/Core/HW/DVD/DVDInterface.cpp +++ b/Source/Core/Core/HW/DVD/DVDInterface.cpp @@ -1039,7 +1039,8 @@ void ExecuteCommand(u32 command_0, u32 command_1, u32 command_2, u32 output_addr INFO_LOG(DVDINTERFACE, "DVDLowStopMotor %s %s", command_1 ? "eject" : "", command_2 ? "kill!" : ""); - bool auto_disc_change = Config::Get(Config::MAIN_AUTO_DISC_CHANGE) && !Movie::IsPlayingInput(); + bool auto_disc_change = Config::Get(Config::MAIN_AUTO_DISC_CHANGE) && + !Movie::IsPlayingInput() && DVDThread::IsInsertedDiscRunning(); if (auto_disc_change) auto_disc_change = AutoChangeDisc(); if (auto_disc_change) diff --git a/Source/Core/Core/HW/DVD/DVDThread.cpp b/Source/Core/Core/HW/DVD/DVDThread.cpp index 3693bb9fe3..27f6df8be6 100644 --- a/Source/Core/Core/HW/DVD/DVDThread.cpp +++ b/Source/Core/Core/HW/DVD/DVDThread.cpp @@ -216,6 +216,16 @@ IOS::ES::TicketReader GetTicket(const DiscIO::Partition& partition) return s_disc->GetTicket(partition); } +bool IsInsertedDiscRunning() +{ + if (!s_disc) + return false; + + WaitUntilIdle(); + + return SConfig::GetInstance().GetGameID() == s_disc->GetGameID(); +} + bool UpdateRunningGameMetadata(const DiscIO::Partition& partition, std::optional title_id) { if (!s_disc) diff --git a/Source/Core/Core/HW/DVD/DVDThread.h b/Source/Core/Core/HW/DVD/DVDThread.h index 3a158cad1c..cdf066cc46 100644 --- a/Source/Core/Core/HW/DVD/DVDThread.h +++ b/Source/Core/Core/HW/DVD/DVDThread.h @@ -47,6 +47,7 @@ DiscIO::Platform GetDiscType(); u64 PartitionOffsetToRawOffset(u64 offset, const DiscIO::Partition& partition); IOS::ES::TMDReader GetTMD(const DiscIO::Partition& partition); IOS::ES::TicketReader GetTicket(const DiscIO::Partition& partition); +bool IsInsertedDiscRunning(); // This function returns true and calls SConfig::SetRunningGameMetadata(Volume&, Partition&) // if both of the following conditions are true: // - A disc is inserted