summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorLeo Lam <leolino.lam@gmail.com>2017-06-03 17:14:39 +0200
committerGitHub <noreply@github.com>2017-06-03 17:14:39 +0200
commit0ff8e2b36f95653cf524cbf23ba6c2f69b201e0d (patch)
tree3b62ab64af7928cc4e4a391386860c7bd8cf8ae3 /Source
parent4af514bb3c65789b00e9c144eaf79aea4380b4fd (diff)
parent1e5c83b3a95c667eff32ef7bdd47f546307d9be9 (diff)
Merge pull request #5514 from JosJuice/updaterunninggamemetadata-optional
Use std::optional for UpdateRunningGameMetadata
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/HW/DVD/DVDInterface.cpp15
-rw-r--r--Source/Core/Core/HW/DVD/DVDInterface.h12
-rw-r--r--Source/Core/Core/HW/DVD/DVDThread.cpp27
-rw-r--r--Source/Core/Core/HW/DVD/DVDThread.h13
4 files changed, 25 insertions, 42 deletions
diff --git a/Source/Core/Core/HW/DVD/DVDInterface.cpp b/Source/Core/Core/HW/DVD/DVDInterface.cpp
index 0e9f31992f..ac509c8be2 100644
--- a/Source/Core/Core/HW/DVD/DVDInterface.cpp
+++ b/Source/Core/Core/HW/DVD/DVDInterface.cpp
@@ -5,6 +5,7 @@
#include <algorithm>
#include <cinttypes>
#include <memory>
+#include <optional>
#include <string>
#include "AudioCommon/AudioCommon.h"
@@ -506,7 +507,7 @@ void SetLidOpen()
GenerateDIInterrupt(INT_CVRINT);
}
-bool UpdateRunningGameMetadata(u64 title_id)
+bool UpdateRunningGameMetadata(std::optional<u64> title_id)
{
if (!DVDThread::HasDisc())
return false;
@@ -518,18 +519,6 @@ bool UpdateRunningGameMetadata(u64 title_id)
return DVDThread::UpdateRunningGameMetadata(partition, title_id);
}
-bool UpdateRunningGameMetadata()
-{
- if (!DVDThread::HasDisc())
- return false;
-
- const DiscIO::Partition& partition = DVDThread::GetDiscType() == DiscIO::Platform::WII_DISC ?
- s_current_partition :
- DiscIO::PARTITION_NONE;
-
- return DVDThread::UpdateRunningGameMetadata(partition);
-}
-
void ChangePartition(const DiscIO::Partition& partition)
{
s_current_partition = partition;
diff --git a/Source/Core/Core/HW/DVD/DVDInterface.h b/Source/Core/Core/HW/DVD/DVDInterface.h
index d3c8ba5ad8..bb6bb3f7a3 100644
--- a/Source/Core/Core/HW/DVD/DVDInterface.h
+++ b/Source/Core/Core/HW/DVD/DVDInterface.h
@@ -4,6 +4,7 @@
#pragma once
+#include <optional>
#include <string>
#include <vector>
@@ -114,12 +115,11 @@ 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
-// If a disc is inserted and its title ID is equal to the title_id argument, returns true and
-// calls SConfig::SetRunningGameMetadata(IVolume&, Partition&). Otherwise, returns false.
-bool UpdateRunningGameMetadata(u64 title_id);
-// If a disc is inserted, returns true and calls
-// SConfig::SetRunningGameMetadata(IVolume&, Partition&). Otherwise, returns false.
-bool UpdateRunningGameMetadata();
+// This function returns true and calls SConfig::SetRunningGameMetadata(IVolume&, Partition&)
+// if both of the following conditions are true:
+// - A disc is inserted
+// - The title_id argument doesn't contain a value, or its value matches the disc's title ID
+bool UpdateRunningGameMetadata(std::optional<u64> title_id = {});
// Direct access to DI for IOS HLE (simpler to implement than how real IOS accesses DI,
// and lets us skip encrypting/decrypting in some cases)
diff --git a/Source/Core/Core/HW/DVD/DVDThread.cpp b/Source/Core/Core/HW/DVD/DVDThread.cpp
index bc7bf60447..a55abae4a9 100644
--- a/Source/Core/Core/HW/DVD/DVDThread.cpp
+++ b/Source/Core/Core/HW/DVD/DVDThread.cpp
@@ -6,6 +6,7 @@
#include <map>
#include <memory>
#include <mutex>
+#include <optional>
#include <thread>
#include <utility>
#include <vector>
@@ -209,30 +210,22 @@ IOS::ES::TicketReader GetTicket(const DiscIO::Partition& partition)
return s_disc->GetTicket(partition);
}
-bool UpdateRunningGameMetadata(const DiscIO::Partition& partition, u64 title_id)
+bool UpdateRunningGameMetadata(const DiscIO::Partition& partition, std::optional<u64> title_id)
{
if (!s_disc)
return false;
WaitUntilIdle();
- u64 volume_title_id;
- if (!s_disc->GetTitleID(&volume_title_id, partition))
- return false;
-
- if (volume_title_id != title_id)
- return false;
-
- SConfig::GetInstance().SetRunningGameMetadata(*s_disc, partition);
- return true;
-}
-
-bool UpdateRunningGameMetadata(const DiscIO::Partition& partition)
-{
- if (!s_disc)
- return false;
+ if (title_id)
+ {
+ u64 volume_title_id;
+ if (!s_disc->GetTitleID(&volume_title_id, partition))
+ return false;
- DVDThread::WaitUntilIdle();
+ if (volume_title_id != *title_id)
+ return false;
+ }
SConfig::GetInstance().SetRunningGameMetadata(*s_disc, partition);
return true;
diff --git a/Source/Core/Core/HW/DVD/DVDThread.h b/Source/Core/Core/HW/DVD/DVDThread.h
index cc10480e92..76874004c5 100644
--- a/Source/Core/Core/HW/DVD/DVDThread.h
+++ b/Source/Core/Core/HW/DVD/DVDThread.h
@@ -5,6 +5,7 @@
#pragma once
#include <memory>
+#include <optional>
#include <vector>
#include "Common/CommonTypes.h"
@@ -44,12 +45,12 @@ bool HasDisc();
DiscIO::Platform GetDiscType();
IOS::ES::TMDReader GetTMD(const DiscIO::Partition& partition);
IOS::ES::TicketReader GetTicket(const DiscIO::Partition& partition);
-// If a disc is inserted and its title ID is equal to the title_id argument, returns true and
-// calls SConfig::SetRunningGameMetadata(IVolume&, Partition&). Otherwise, returns false.
-bool UpdateRunningGameMetadata(const DiscIO::Partition& partition, u64 title_id);
-// If a disc is inserted, returns true and calls
-// SConfig::SetRunningGameMetadata(IVolume&, Partition&). Otherwise, returns false.
-bool UpdateRunningGameMetadata(const DiscIO::Partition& partition);
+// This function returns true and calls SConfig::SetRunningGameMetadata(IVolume&, Partition&)
+// if both of the following conditions are true:
+// - A disc is inserted
+// - The title_id argument doesn't contain a value, or its value matches the disc's title ID
+bool UpdateRunningGameMetadata(const DiscIO::Partition& partition,
+ std::optional<u64> title_id = {});
void StartRead(u64 dvd_offset, u32 length, const DiscIO::Partition& partition,
DVDInterface::ReplyType reply_type, s64 ticks_until_completion);