Skip to content

Commit

Permalink
Emu: fixup message when the application has crashed
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Nov 1, 2022
1 parent 68b68e6 commit 49cad88
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
24 changes: 20 additions & 4 deletions rpcs3/Emu/System.cpp
Expand Up @@ -2051,6 +2051,18 @@ bool Emulator::Pause(bool freeze_emulation)
return false;
}
}

// Perform the side effects of Resume here when transforming paused to frozen state
BlockingCallFromMainThread([this]()
{
for (auto& ref : m_pause_msgs_refs)
{
// Delete the message queued on pause
*ref = 0;
}

m_pause_msgs_refs.clear();
});
}

// Signal profilers to print results (if enabled)
Expand All @@ -2073,25 +2085,29 @@ bool Emulator::Pause(bool freeze_emulation)

BlockingCallFromMainThread([this]()
{
if (IsStopped())
const auto status = Emu.GetStatus(false);

if (status != system_state::paused && status != system_state::frozen)
{
return;
}

auto msg_ref = std::make_shared<atomic_t<u32>>(1);

// No timeout
rsx::overlays::queue_message(localized_string_id::EMULATION_PAUSED_RESUME_WITH_START, -1, msg_ref);
rsx::overlays::queue_message(status == system_state::paused ? localized_string_id::EMULATION_PAUSED_RESUME_WITH_START : localized_string_id::EMULATION_FROZEN, -1, msg_ref);
m_pause_msgs_refs.emplace_back(msg_ref);

auto refresh_l = [this, msg_ref]()
auto refresh_l = [this, msg_ref, status]()
{
while (*msg_ref && IsPaused())
while (*msg_ref && GetStatus(false) == status)
{
// Refresh Native UI
rsx::set_native_ui_flip();
thread_ctrl::wait_for(33'000);
}

msg_ref->release(0);
};

struct thread_t
Expand Down
1 change: 1 addition & 0 deletions rpcs3/Emu/localized_string_id.h
Expand Up @@ -149,4 +149,5 @@ enum class localized_string_id

EMULATION_PAUSED_RESUME_WITH_START,
EMULATION_RESUMING,
EMULATION_FROZEN,
};
11 changes: 7 additions & 4 deletions rpcs3/Input/pad_thread.cpp
Expand Up @@ -403,7 +403,7 @@ void pad_thread::operator()()

u64 pad_sleep = g_cfg.io.pad_sleep;

if (Emu.IsPaused())
if (Emu.GetStatus(false) == system_state::paused)
{
pad_sleep = std::max<u64>(pad_sleep, 30'000);

Expand Down Expand Up @@ -438,17 +438,20 @@ void pad_thread::operator()()
m_mask_start_press_to_unpause = 0;
m_track_start_press_begin_timestamp = 0;

sys_log.success("Unpausing emulation using the START button in a few seconds...");
rsx::overlays::queue_message(localized_string_id::EMULATION_RESUMING, 2'000'000);
sys_log.success("Resuming emulation using the START button in a few seconds...");

auto msg_ref = std::make_shared<atomic_t<u32>>(1);
rsx::overlays::queue_message(localized_string_id::EMULATION_RESUMING, 2'000'000, msg_ref);

m_resume_emulation_flag = true;

for (u32 i = 0; i < 40; i++)
{
if (!Emu.IsPaused())
if (Emu.GetStatus(false) != system_state::paused)
{
// Abort if emulation has been resumed by other means
m_resume_emulation_flag = false;
msg_ref->release(0);
break;
}

Expand Down
1 change: 1 addition & 0 deletions rpcs3/rpcs3qt/localized_emu.h
Expand Up @@ -169,6 +169,7 @@ class localized_emu : public QObject
case localized_string_id::RPCN_SUCCESS_LOGGED_ON: return tr("Successfully logged on RPCN!");
case localized_string_id::EMULATION_PAUSED_RESUME_WITH_START: return tr("Press and hold the START button to resume");
case localized_string_id::EMULATION_RESUMING: return tr("Resuming...!");
case localized_string_id::EMULATION_FROZEN: return tr("The PS3 application has likely crashed, you can close it.");
case localized_string_id::INVALID: return tr("Invalid");
default: return tr("Unknown");
}
Expand Down

0 comments on commit 49cad88

Please sign in to comment.