diff options
| author | JosJuice <josjuice@gmail.com> | 2016-09-24 12:29:13 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2017-05-13 22:56:11 +0200 |
| commit | 807e242d051935cf733d271ddbfc2939f0e13337 (patch) | |
| tree | 43f90a189ef1b77505845d455953812b9ba445f0 /Source | |
| parent | 460459fb7d59064797440b7ca125e2dd5fd6ddb8 (diff) | |
DVDInterface: Replace SetVolume functions
It's better to just let the calling code provide a volume
object instead of needing one SetVolume for each way of
creating a volume. This simplifies InsertDiscCallback and
is needed for the following commits.
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/Core/Boot/Boot.cpp | 19 | ||||
| -rw-r--r-- | Source/Core/Core/HW/DVD/DVDInterface.cpp | 35 | ||||
| -rw-r--r-- | Source/Core/Core/HW/DVD/DVDInterface.h | 4 |
3 files changed, 22 insertions, 36 deletions
diff --git a/Source/Core/Core/Boot/Boot.cpp b/Source/Core/Core/Boot/Boot.cpp index 5caf025da5..816e58c0f1 100644 --- a/Source/Core/Core/Boot/Boot.cpp +++ b/Source/Core/Core/Boot/Boot.cpp @@ -37,6 +37,7 @@ #include "DiscIO/Enums.h" #include "DiscIO/NANDContentLoader.h" #include "DiscIO/Volume.h" +#include "DiscIO/VolumeCreator.h" bool CBoot::DVDRead(u64 dvd_offset, u32 output_address, u32 length, bool decrypt) { @@ -277,7 +278,7 @@ bool CBoot::BootUp() { case SConfig::BOOT_ISO: { - DVDInterface::SetVolumeName(_StartupPara.m_strFilename); + DVDInterface::SetDisc(DiscIO::CreateVolumeFromFilename(_StartupPara.m_strFilename)); if (!DVDInterface::IsDiscInside()) return false; @@ -333,13 +334,14 @@ bool CBoot::BootUp() if (!_StartupPara.m_strDVDRoot.empty()) { NOTICE_LOG(BOOT, "Setting DVDRoot %s", _StartupPara.m_strDVDRoot.c_str()); - DVDInterface::SetVolumeDirectory(_StartupPara.m_strDVDRoot, dolWii, - _StartupPara.m_strApploader, _StartupPara.m_strFilename); + DVDInterface::SetDisc(DiscIO::CreateVolumeFromDirectory(_StartupPara.m_strDVDRoot, dolWii, + _StartupPara.m_strApploader, + _StartupPara.m_strFilename)); } else if (!_StartupPara.m_strDefaultISO.empty()) { NOTICE_LOG(BOOT, "Loading default ISO %s", _StartupPara.m_strDefaultISO.c_str()); - DVDInterface::SetVolumeName(_StartupPara.m_strDefaultISO); + DVDInterface::SetDisc(DiscIO::CreateVolumeFromFilename(_StartupPara.m_strDefaultISO)); } if (!EmulatedBS2(dolWii)) @@ -369,12 +371,13 @@ bool CBoot::BootUp() if (!_StartupPara.m_strDVDRoot.empty()) { NOTICE_LOG(BOOT, "Setting DVDRoot %s", _StartupPara.m_strDVDRoot.c_str()); - DVDInterface::SetVolumeDirectory(_StartupPara.m_strDVDRoot, _StartupPara.bWii); + DVDInterface::SetDisc( + DiscIO::CreateVolumeFromDirectory(_StartupPara.m_strDVDRoot, _StartupPara.bWii)); } else if (!_StartupPara.m_strDefaultISO.empty()) { NOTICE_LOG(BOOT, "Loading default ISO %s", _StartupPara.m_strDefaultISO.c_str()); - DVDInterface::SetVolumeName(_StartupPara.m_strDefaultISO); + DVDInterface::SetDisc(DiscIO::CreateVolumeFromFilename(_StartupPara.m_strDefaultISO)); } // Poor man's bootup @@ -409,9 +412,9 @@ bool CBoot::BootUp() // load default image or create virtual drive from directory if (!_StartupPara.m_strDVDRoot.empty()) - DVDInterface::SetVolumeDirectory(_StartupPara.m_strDVDRoot, true); + DVDInterface::SetDisc(DiscIO::CreateVolumeFromDirectory(_StartupPara.m_strDVDRoot, true)); else if (!_StartupPara.m_strDefaultISO.empty()) - DVDInterface::SetVolumeName(_StartupPara.m_strDefaultISO); + DVDInterface::SetDisc(DiscIO::CreateVolumeFromFilename(_StartupPara.m_strDefaultISO)); break; diff --git a/Source/Core/Core/HW/DVD/DVDInterface.cpp b/Source/Core/Core/HW/DVD/DVDInterface.cpp index 404b855f16..3754c06fdb 100644 --- a/Source/Core/Core/HW/DVD/DVDInterface.cpp +++ b/Source/Core/Core/HW/DVD/DVDInterface.cpp @@ -456,30 +456,18 @@ void Shutdown() FileMonitor::SetFileSystem(nullptr); } -const DiscIO::IVolume& GetVolume() -{ - _assert_(IsDiscInside()); - return *s_inserted_volume; -} - -bool SetVolumeName(const std::string& disc_path) +void SetDisc(std::unique_ptr<DiscIO::IVolume> disc) { DVDThread::WaitUntilIdle(); - s_inserted_volume = DiscIO::CreateVolumeFromFilename(disc_path); + s_inserted_volume = std::move(disc); FileMonitor::SetFileSystem(s_inserted_volume.get()); SetLidOpen(); - return IsDiscInside(); } -bool SetVolumeDirectory(const std::string& full_path, bool is_wii, - const std::string& apploader_path, const std::string& DOL_path) +const DiscIO::IVolume& GetVolume() { - DVDThread::WaitUntilIdle(); - s_inserted_volume = - DiscIO::CreateVolumeFromDirectory(full_path, is_wii, apploader_path, DOL_path); - FileMonitor::SetFileSystem(s_inserted_volume.get()); - SetLidOpen(); - return IsDiscInside(); + _assert_(IsDiscInside()); + return *s_inserted_volume; } bool IsDiscInside() @@ -501,16 +489,13 @@ static void EjectDiscCallback(u64 userdata, s64 cyclesLate) static void InsertDiscCallback(u64 userdata, s64 cyclesLate) { - const std::string& old_path = SConfig::GetInstance().m_strFilename; + std::unique_ptr<DiscIO::IVolume> new_volume = + DiscIO::CreateVolumeFromFilename(s_disc_path_to_insert); - if (!SetVolumeName(s_disc_path_to_insert)) - { - // Put back the old one - SetVolumeName(old_path); + if (new_volume) + SetDisc(std::move(new_volume)); + else PanicAlertT("The disc that was about to be inserted couldn't be found."); - } - - s_disc_path_to_insert.clear(); } // Can only be called by the host thread diff --git a/Source/Core/Core/HW/DVD/DVDInterface.h b/Source/Core/Core/HW/DVD/DVDInterface.h index 64c4bc1efb..fc06684ac8 100644 --- a/Source/Core/Core/HW/DVD/DVDInterface.h +++ b/Source/Core/Core/HW/DVD/DVDInterface.h @@ -109,10 +109,8 @@ void DoState(PointerWrap& p); void RegisterMMIO(MMIO::Mapping* mmio, u32 base); // Disc access (don't call GetVolume unless you know that IsDiscInside() == true) +void SetDisc(std::unique_ptr<DiscIO::IVolume> disc); const DiscIO::IVolume& GetVolume(); -bool SetVolumeName(const std::string& disc_path); -bool SetVolumeDirectory(const std::string& disc_path, bool is_wii, - const std::string& apploader_path = "", const std::string& DOL_path = ""); 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 |
