mirror of https://github.com/PCSX2/pcsx2.git
Misc: Clean up the last places exceptions were used
This commit is contained in:
parent
a889acb332
commit
2ae78f6e2f
|
@ -156,15 +156,8 @@ bool StartKeepAliveThread()
|
|||
if (s_keepalive_is_open == false)
|
||||
{
|
||||
s_keepalive_is_open = true;
|
||||
try
|
||||
{
|
||||
s_keepalive_thread = std::thread(keepAliveThread);
|
||||
}
|
||||
catch (std::system_error&)
|
||||
{
|
||||
s_keepalive_is_open = false;
|
||||
}
|
||||
}
|
||||
|
||||
return s_keepalive_is_open;
|
||||
}
|
||||
|
@ -190,21 +183,15 @@ s32 CALLBACK DISCopen(const char* pTitle)
|
|||
return -1;
|
||||
|
||||
// open device file
|
||||
try
|
||||
{
|
||||
src = std::unique_ptr<IOCtlSrc>(new IOCtlSrc(drive));
|
||||
}
|
||||
catch (std::runtime_error&)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
//setup threading manager
|
||||
if (!cdvdStartThread())
|
||||
src = std::make_unique<IOCtlSrc>(std::move(drive));
|
||||
if (!src->Reopen())
|
||||
{
|
||||
src.reset();
|
||||
return -1;
|
||||
}
|
||||
|
||||
//setup threading manager
|
||||
cdvdStartThread();
|
||||
StartKeepAliveThread();
|
||||
|
||||
return cdvdRefreshData();
|
||||
|
@ -312,17 +299,11 @@ s32 CALLBACK DISCgetTD(u8 Track, cdvdTD* Buffer)
|
|||
{
|
||||
if (src == nullptr)
|
||||
return -1;
|
||||
try
|
||||
{
|
||||
|
||||
Buffer->lsn = src->GetSectorCount();
|
||||
Buffer->type = 0;
|
||||
return 0;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (Track < strack)
|
||||
return -1;
|
||||
|
|
|
@ -64,12 +64,13 @@ class IOCtlSrc
|
|||
|
||||
bool ReadDVDInfo();
|
||||
bool ReadCDInfo();
|
||||
bool Reopen();
|
||||
|
||||
public:
|
||||
IOCtlSrc(std::string filename);
|
||||
~IOCtlSrc();
|
||||
|
||||
bool Reopen();
|
||||
|
||||
u32 GetSectorCount() const;
|
||||
const std::vector<toc_entry>& ReadTOC() const;
|
||||
bool ReadSectors2048(u32 sector, u32 count, u8* buffer) const;
|
||||
|
@ -90,7 +91,7 @@ extern bool weAreInNewDiskCB;
|
|||
|
||||
extern void (*newDiscCB)();
|
||||
|
||||
bool cdvdStartThread();
|
||||
void cdvdStartThread();
|
||||
void cdvdStopThread();
|
||||
void cdvdRequestSector(u32 sector, s32 mode);
|
||||
u8* cdvdGetSector(u32 sector, s32 mode);
|
||||
|
|
|
@ -261,25 +261,15 @@ void cdvdThread()
|
|||
printf(" * CDVD: IO thread finished.\n");
|
||||
}
|
||||
|
||||
bool cdvdStartThread()
|
||||
void cdvdStartThread()
|
||||
{
|
||||
if (cdvd_is_open == false)
|
||||
{
|
||||
cdvd_is_open = true;
|
||||
try
|
||||
{
|
||||
s_thread = std::thread(cdvdThread);
|
||||
}
|
||||
catch (std::system_error&)
|
||||
{
|
||||
cdvd_is_open = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
cdvdCacheReset();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void cdvdStopThread()
|
||||
|
@ -349,15 +339,8 @@ s32 cdvdDirectReadSector(u32 sector, s32 mode, u8* buffer)
|
|||
if (src == nullptr)
|
||||
return -1;
|
||||
|
||||
try
|
||||
{
|
||||
if (sector >= src->GetSectorCount())
|
||||
return -1;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Align to cache block
|
||||
u32 sector_block = sector & ~(sectors_per_read - 1);
|
||||
|
|
|
@ -29,11 +29,9 @@
|
|||
#include <cerrno>
|
||||
#include <cstring>
|
||||
|
||||
IOCtlSrc::IOCtlSrc(decltype(m_filename) filename)
|
||||
: m_filename(filename)
|
||||
IOCtlSrc::IOCtlSrc(std::string filename)
|
||||
: m_filename(std::move(filename))
|
||||
{
|
||||
if (!Reopen())
|
||||
throw std::runtime_error(" * CDVD: Error opening source.\n");
|
||||
}
|
||||
|
||||
IOCtlSrc::~IOCtlSrc()
|
||||
|
|
|
@ -26,11 +26,9 @@
|
|||
#include <climits>
|
||||
#include <cstring>
|
||||
|
||||
IOCtlSrc::IOCtlSrc(decltype(m_filename) filename)
|
||||
: m_filename(filename)
|
||||
IOCtlSrc::IOCtlSrc(std::string filename)
|
||||
: m_filename(std::move(filename))
|
||||
{
|
||||
if (!Reopen())
|
||||
throw std::runtime_error(" * CDVD: Error opening source.\n");
|
||||
}
|
||||
|
||||
IOCtlSrc::~IOCtlSrc()
|
||||
|
|
|
@ -36,8 +36,6 @@
|
|||
IOCtlSrc::IOCtlSrc(std::string filename)
|
||||
: m_filename(std::move(filename))
|
||||
{
|
||||
if (!Reopen())
|
||||
throw std::runtime_error(" * CDVD: Error opening source.\n");
|
||||
}
|
||||
|
||||
IOCtlSrc::~IOCtlSrc()
|
||||
|
|
|
@ -908,17 +908,15 @@ void GameDatabaseSchema::GameEntry::applyGSHardwareFixes(Pcsx2Config::GSOptions&
|
|||
void GameDatabase::initDatabase()
|
||||
{
|
||||
ryml::Callbacks rymlCallbacks = ryml::get_callbacks();
|
||||
rymlCallbacks.m_error = [](const char* msg, size_t msg_len, ryml::Location loc, void*) {
|
||||
throw std::runtime_error(fmt::format("[YAML] Parsing error at {}:{} (bufpos={}): {}",
|
||||
loc.line, loc.col, loc.offset, msg));
|
||||
rymlCallbacks.m_error = [](const char* msg, size_t msg_len, ryml::Location loc, void* userdata) {
|
||||
Console.Error(fmt::format("[GameDB YAML] Parsing error at {}:{} (bufpos={}): {}",
|
||||
loc.line, loc.col, loc.offset, std::string_view(msg, msg_len)));
|
||||
};
|
||||
ryml::set_callbacks(rymlCallbacks);
|
||||
c4::set_error_callback([](const char* msg, size_t msg_size) {
|
||||
throw std::runtime_error(fmt::format("[YAML] Internal Parsing error: {}",
|
||||
msg));
|
||||
Console.Error(fmt::format("[GameDB YAML] Internal Parsing error: {}", std::string_view(msg, msg_size)));
|
||||
});
|
||||
try
|
||||
{
|
||||
|
||||
auto buf = Host::ReadResourceFileToString(GAMEDB_YAML_FILE_NAME);
|
||||
if (!buf.has_value())
|
||||
{
|
||||
|
@ -929,7 +927,7 @@ void GameDatabase::initDatabase()
|
|||
ryml::Tree tree = ryml::parse_in_arena(c4::to_csubstr(buf.value()));
|
||||
ryml::NodeRef root = tree.rootref();
|
||||
|
||||
for (const auto& n : root.children())
|
||||
for (const ryml::NodeRef& n : root.children())
|
||||
{
|
||||
auto serial = StringUtil::toLower(std::string(n.key().str, n.key().len));
|
||||
|
||||
|
@ -942,16 +940,13 @@ void GameDatabase::initDatabase()
|
|||
Console.Error(fmt::format("[GameDB] Duplicate serial '{}' found in GameDB. Skipping, Serials are case-insensitive!", serial));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (n.is_map())
|
||||
{
|
||||
parseAndInsert(serial, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
Console.Error(fmt::format("[GameDB] Error occured when initializing GameDB: {}", e.what()));
|
||||
}
|
||||
|
||||
ryml::reset_callbacks();
|
||||
}
|
||||
|
||||
|
|
|
@ -40,43 +40,37 @@
|
|||
#include <mutex>
|
||||
#include <optional>
|
||||
|
||||
static ryml::Tree parseYamlStr(const std::string& str)
|
||||
{
|
||||
ryml::Callbacks rymlCallbacks = ryml::get_callbacks();
|
||||
rymlCallbacks.m_error = [](const char* msg, size_t msg_len, ryml::Location loc, void*) {
|
||||
throw std::runtime_error(fmt::format("[YAML] Parsing error at {}:{} (bufpos={}): {}",
|
||||
loc.line, loc.col, loc.offset, msg));
|
||||
};
|
||||
ryml::set_callbacks(rymlCallbacks);
|
||||
c4::set_error_callback([](const char* msg, size_t msg_size) {
|
||||
throw std::runtime_error(fmt::format("[YAML] Internal Parsing error: {}",
|
||||
msg));
|
||||
});
|
||||
ryml::Tree tree = ryml::parse_in_arena(c4::to_csubstr(str));
|
||||
|
||||
ryml::reset_callbacks();
|
||||
return tree;
|
||||
}
|
||||
|
||||
// A helper function to parse the YAML file
|
||||
static std::optional<ryml::Tree> loadYamlFile(const char* filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::optional<std::string> buffer = FileSystem::ReadFileToString(filePath);
|
||||
if (!buffer.has_value())
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
ryml::Tree tree = parseYamlStr(buffer.value());
|
||||
return std::make_optional(tree);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
Console.Error(fmt::format("[MemoryCard] Error occured when parsing folder memory card at path '{}': {}", filePath, e.what()));
|
||||
|
||||
static u32 errorCount;
|
||||
errorCount = 0;
|
||||
|
||||
ryml::Callbacks rymlCallbacks = ryml::get_callbacks();
|
||||
rymlCallbacks.m_error = [](const char* msg, size_t msg_len, ryml::Location loc, void* userdata) {
|
||||
Console.Error(fmt::format("[YAML] Parsing error at {}:{} (bufpos={}): {}",
|
||||
loc.line, loc.col, loc.offset, std::string_view(msg, msg_len)));
|
||||
errorCount++;
|
||||
};
|
||||
ryml::set_callbacks(rymlCallbacks);
|
||||
c4::set_error_callback([](const char* msg, size_t msg_size) {
|
||||
Console.Error(fmt::format("[YAML] Internal Parsing error: {}", std::string_view(msg, msg_size)));
|
||||
errorCount++;
|
||||
});
|
||||
|
||||
ryml::Tree tree = ryml::parse_in_arena(c4::to_csubstr(buffer.value()));
|
||||
ryml::reset_callbacks();
|
||||
if (errorCount > 0)
|
||||
{
|
||||
Console.Error(fmt::format("[MemoryCard] Error occured when parsing folder memory card at path '{}'.", filePath));
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
/// A helper function to write a YAML file
|
||||
|
|
|
@ -366,7 +366,7 @@ extern void CPU_SET_DMASTALL(EE_EventType n, bool set);
|
|||
extern uint intcInterrupt();
|
||||
extern uint dmacInterrupt();
|
||||
|
||||
extern void cpuReset(); // can throw Exception::FileNotFound.
|
||||
extern void cpuReset();
|
||||
extern void cpuException(u32 code, u32 bd);
|
||||
extern void cpuTlbMissR(u32 addr, u32 bd);
|
||||
extern void cpuTlbMissW(u32 addr, u32 bd);
|
||||
|
|
|
@ -1178,9 +1178,6 @@ void PREF()
|
|||
|
||||
static void trap(u16 code=0)
|
||||
{
|
||||
// unimplemented?
|
||||
// throw R5900Exception::Trap(code);
|
||||
|
||||
cpuRegs.pc -= 4;
|
||||
Console.Warning("Trap exception at 0x%08x", cpuRegs.pc);
|
||||
cpuException(0x34, cpuRegs.branch);
|
||||
|
|
|
@ -339,34 +339,45 @@ namespace usb_eyetoy
|
|||
return 0;
|
||||
}
|
||||
|
||||
void DirectShow::Start()
|
||||
bool DirectShow::Start()
|
||||
{
|
||||
HRESULT hr = nullrenderer->Run(0);
|
||||
if (FAILED(hr))
|
||||
throw hr;
|
||||
{
|
||||
Console.Error("nullrenderer->Run() failed: %08X", hr);
|
||||
return false;
|
||||
}
|
||||
|
||||
hr = samplegrabberfilter->Run(0);
|
||||
if (FAILED(hr))
|
||||
throw hr;
|
||||
{
|
||||
Console.Error("samplegrabberfilter->Run() failed: %08X", hr);
|
||||
return false;
|
||||
}
|
||||
|
||||
hr = sourcefilter->Run(0);
|
||||
if (FAILED(hr))
|
||||
throw hr;
|
||||
{
|
||||
Console.Error("sourcefilter->Run() failed: %08X", hr);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DirectShow::Stop()
|
||||
{
|
||||
HRESULT hr = sourcefilter->Stop();
|
||||
if (FAILED(hr))
|
||||
throw hr;
|
||||
Console.Error("sourcefilter->Stop() failed: %08X", hr);
|
||||
|
||||
hr = samplegrabberfilter->Stop();
|
||||
if (FAILED(hr))
|
||||
throw hr;
|
||||
Console.Error("samplegrabberfilter->Stop() failed: %08X", hr);
|
||||
|
||||
hr = nullrenderer->Stop();
|
||||
if (FAILED(hr))
|
||||
throw hr;
|
||||
Console.Error("nullrenderer->Stop() failed: %08X", hr);
|
||||
}
|
||||
|
||||
void store_mpeg_frame(const unsigned char* data, const unsigned int len)
|
||||
|
@ -551,9 +562,14 @@ namespace usb_eyetoy
|
|||
}
|
||||
|
||||
pControl->Run();
|
||||
this->Stop();
|
||||
this->SetCallback(dshow_callback);
|
||||
this->Start();
|
||||
Stop();
|
||||
SetCallback(dshow_callback);
|
||||
if (!Start())
|
||||
{
|
||||
Console.Error("Camera: Failed to start");
|
||||
Stop();
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace usb_eyetoy
|
|||
|
||||
protected:
|
||||
void SetCallback(DShowVideoCaptureCallback cb) { callbackhandler->SetCallback(cb); }
|
||||
void Start();
|
||||
bool Start();
|
||||
void Stop();
|
||||
int InitializeDevice(std::wstring selectedDevice);
|
||||
|
||||
|
|
Loading…
Reference in New Issue