Merge pull request #6072 from JosJuice/eject-disc

Add an option to eject the disc
This commit is contained in:
Leo Lam
2017-09-18 12:47:47 +02:00
committed by GitHub
12 changed files with 30 additions and 20 deletions

View File

@ -19,7 +19,6 @@
#include "Common/Logging/Log.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
#include "Core/HW/AudioInterface.h"
#include "Core/HW/DVD/DVDMath.h"
@ -451,10 +450,6 @@ bool IsDiscInside()
return DVDThread::HasDisc();
}
// Take care of all logic of "swapping discs"
// We want this in the "backend", NOT the gui
// any !empty string will be deleted to ensure
// that the userdata string exists when called
static void EjectDiscCallback(u64 userdata, s64 cyclesLate)
{
SetDisc(nullptr);
@ -473,14 +468,14 @@ static void InsertDiscCallback(u64 userdata, s64 cyclesLate)
s_disc_path_to_insert.clear();
}
// Can only be called by the host thread
void ChangeDiscAsHost(const std::string& new_path)
// Must only be called on the CPU thread
void EjectDisc()
{
Core::RunAsCPUThread([&] { ChangeDiscAsCPU(new_path); });
CoreTiming::ScheduleEvent(0, s_eject_disc);
}
// Can only be called by the CPU thread
void ChangeDiscAsCPU(const std::string& new_path)
// Must only be called on the CPU thread
void ChangeDisc(const std::string& new_path)
{
if (!s_disc_path_to_insert.empty())
{
@ -488,10 +483,10 @@ void ChangeDiscAsCPU(const std::string& new_path)
return;
}
s_disc_path_to_insert = new_path;
CoreTiming::ScheduleEvent(0, s_eject_disc);
CoreTiming::ScheduleEvent(SystemTimers::GetTicksPerSecond(), s_insert_disc);
EjectDisc();
s_disc_path_to_insert = new_path;
CoreTiming::ScheduleEvent(SystemTimers::GetTicksPerSecond(), s_insert_disc);
Movie::SignalDiscChange(new_path);
}

View File

@ -113,8 +113,8 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base);
void SetDisc(std::unique_ptr<DiscIO::Volume> disc);
bool IsDiscInside();
void ChangeDiscAsHost(const std::string& new_path); // Can only be called by the host thread
void ChangeDiscAsCPU(const std::string& new_path); // Can only be called by the CPU thread
void EjectDisc(); // Must only be called on the CPU thread
void ChangeDisc(const std::string& new_path); // Must only be called on the CPU thread
// This function returns true and calls SConfig::SetRunningGameMetadata(Volume&, Partition&)
// if both of the following conditions are true:

View File

@ -23,6 +23,7 @@
const std::string hotkey_labels[] = {
_trans("Open"),
_trans("Change Disc"),
_trans("Eject Disc"),
_trans("Refresh List"),
_trans("Toggle Pause"),
_trans("Stop"),

View File

@ -21,6 +21,7 @@ enum Hotkey
{
HK_OPEN,
HK_CHANGE_DISC,
HK_EJECT_DISC,
HK_REFRESH_LIST,
HK_PLAY_PAUSE,
HK_STOP,

View File

@ -1180,7 +1180,7 @@ void PlayController(GCPadStatus* PadStatus, int controllerID)
}
if (found)
{
DVDInterface::ChangeDiscAsCPU(path);
Core::RunAsCPUThread([&path] { DVDInterface::ChangeDisc(path); });
}
else
{