Use std::optional for UpdateRunningGameMetadata
This commit is contained in:
parent
4af514bb3c
commit
1e5c83b3a9
|
@ -5,6 +5,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "AudioCommon/AudioCommon.h"
|
#include "AudioCommon/AudioCommon.h"
|
||||||
|
@ -506,7 +507,7 @@ void SetLidOpen()
|
||||||
GenerateDIInterrupt(INT_CVRINT);
|
GenerateDIInterrupt(INT_CVRINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UpdateRunningGameMetadata(u64 title_id)
|
bool UpdateRunningGameMetadata(std::optional<u64> title_id)
|
||||||
{
|
{
|
||||||
if (!DVDThread::HasDisc())
|
if (!DVDThread::HasDisc())
|
||||||
return false;
|
return false;
|
||||||
|
@ -518,18 +519,6 @@ bool UpdateRunningGameMetadata(u64 title_id)
|
||||||
return DVDThread::UpdateRunningGameMetadata(partition, 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)
|
void ChangePartition(const DiscIO::Partition& partition)
|
||||||
{
|
{
|
||||||
s_current_partition = partition;
|
s_current_partition = partition;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -114,12 +115,11 @@ bool IsDiscInside();
|
||||||
void ChangeDiscAsHost(const std::string& new_path); // Can only be called by the host thread
|
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 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
|
// This function returns true and calls SConfig::SetRunningGameMetadata(IVolume&, Partition&)
|
||||||
// calls SConfig::SetRunningGameMetadata(IVolume&, Partition&). Otherwise, returns false.
|
// if both of the following conditions are true:
|
||||||
bool UpdateRunningGameMetadata(u64 title_id);
|
// - A disc is inserted
|
||||||
// If a disc is inserted, returns true and calls
|
// - The title_id argument doesn't contain a value, or its value matches the disc's title ID
|
||||||
// SConfig::SetRunningGameMetadata(IVolume&, Partition&). Otherwise, returns false.
|
bool UpdateRunningGameMetadata(std::optional<u64> title_id = {});
|
||||||
bool UpdateRunningGameMetadata();
|
|
||||||
|
|
||||||
// Direct access to DI for IOS HLE (simpler to implement than how real IOS accesses DI,
|
// 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)
|
// and lets us skip encrypting/decrypting in some cases)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <optional>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -209,30 +210,22 @@ IOS::ES::TicketReader GetTicket(const DiscIO::Partition& partition)
|
||||||
return s_disc->GetTicket(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)
|
if (!s_disc)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
WaitUntilIdle();
|
WaitUntilIdle();
|
||||||
|
|
||||||
u64 volume_title_id;
|
if (title_id)
|
||||||
if (!s_disc->GetTitleID(&volume_title_id, partition))
|
{
|
||||||
return false;
|
u64 volume_title_id;
|
||||||
|
if (!s_disc->GetTitleID(&volume_title_id, partition))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (volume_title_id != title_id)
|
if (volume_title_id != *title_id)
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
SConfig::GetInstance().SetRunningGameMetadata(*s_disc, partition);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UpdateRunningGameMetadata(const DiscIO::Partition& partition)
|
|
||||||
{
|
|
||||||
if (!s_disc)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
DVDThread::WaitUntilIdle();
|
|
||||||
|
|
||||||
SConfig::GetInstance().SetRunningGameMetadata(*s_disc, partition);
|
SConfig::GetInstance().SetRunningGameMetadata(*s_disc, partition);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
@ -44,12 +45,12 @@ bool HasDisc();
|
||||||
DiscIO::Platform GetDiscType();
|
DiscIO::Platform GetDiscType();
|
||||||
IOS::ES::TMDReader GetTMD(const DiscIO::Partition& partition);
|
IOS::ES::TMDReader GetTMD(const DiscIO::Partition& partition);
|
||||||
IOS::ES::TicketReader GetTicket(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
|
// This function returns true and calls SConfig::SetRunningGameMetadata(IVolume&, Partition&)
|
||||||
// calls SConfig::SetRunningGameMetadata(IVolume&, Partition&). Otherwise, returns false.
|
// if both of the following conditions are true:
|
||||||
bool UpdateRunningGameMetadata(const DiscIO::Partition& partition, u64 title_id);
|
// - A disc is inserted
|
||||||
// If a disc is inserted, returns true and calls
|
// - The title_id argument doesn't contain a value, or its value matches the disc's title ID
|
||||||
// SConfig::SetRunningGameMetadata(IVolume&, Partition&). Otherwise, returns false.
|
bool UpdateRunningGameMetadata(const DiscIO::Partition& partition,
|
||||||
bool UpdateRunningGameMetadata(const DiscIO::Partition& partition);
|
std::optional<u64> title_id = {});
|
||||||
|
|
||||||
void StartRead(u64 dvd_offset, u32 length, const DiscIO::Partition& partition,
|
void StartRead(u64 dvd_offset, u32 length, const DiscIO::Partition& partition,
|
||||||
DVDInterface::ReplyType reply_type, s64 ticks_until_completion);
|
DVDInterface::ReplyType reply_type, s64 ticks_until_completion);
|
||||||
|
|
Loading…
Reference in New Issue