summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2025-11-19 13:43:05 -0600
committerGitHub <noreply@github.com>2025-11-19 13:43:05 -0600
commitd0341b3bfcc6315d84fbeb09d14733f683e408dc (patch)
tree54ad8db7ac1ab575ae01fe5c1901bbc618aaca23 /Source
parenta80f371326b55e53b08d99c34a947a81327211a9 (diff)
parent6380ad6abb574a573cd674539b58b2c9aba5cd27 (diff)
Merge pull request #14127 from jordan-woyak/movie-cpu-thread-guard
Movie: Replace a blocking RunOnCPUThread call with a CPUThreadGuard.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/Movie.cpp126
1 files changed, 63 insertions, 63 deletions
diff --git a/Source/Core/Core/Movie.cpp b/Source/Core/Core/Movie.cpp
index aee5e4707a..c62130e18c 100644
--- a/Source/Core/Core/Movie.cpp
+++ b/Source/Core/Core/Movie.cpp
@@ -493,80 +493,80 @@ bool MovieManager::BeginRecordingInput(const ControllerTypeArray& controllers,
(controllers == ControllerTypeArray{} && wiimotes == WiimoteEnabledArray{}))
return false;
- const auto start_recording = [this, controllers, wiimotes] {
- m_controllers = controllers;
- m_wiimotes = wiimotes;
- m_current_frame = m_total_frames = 0;
- m_current_lag_count = m_total_lag_count = 0;
- m_current_input_count = m_total_input_count = 0;
- m_total_tick_count = m_tick_count_at_last_input = 0;
- m_bongos = 0;
- m_memcards = 0;
- if (NetPlay::IsNetPlayRunning())
- {
- m_net_play = true;
- m_recording_start_time = ExpansionInterface::CEXIIPL::NetPlay_GetEmulatedTime();
- }
- else if (Config::Get(Config::MAIN_CUSTOM_RTC_ENABLE))
- {
- m_recording_start_time = Config::Get(Config::MAIN_CUSTOM_RTC_VALUE);
- }
- else
- {
- m_recording_start_time = Common::Timer::GetLocalTimeSinceJan1970();
- }
+ Core::DisplayMessage("Starting movie recording", 2000);
- m_rerecords = 0;
+ Core::CPUThreadGuard cpu_thread_guard{m_system};
+
+ m_controllers = controllers;
+ m_wiimotes = wiimotes;
+ m_current_frame = m_total_frames = 0;
+ m_current_lag_count = m_total_lag_count = 0;
+ m_current_input_count = m_total_input_count = 0;
+ m_total_tick_count = m_tick_count_at_last_input = 0;
+ m_bongos = 0;
+ m_memcards = 0;
+ if (NetPlay::IsNetPlayRunning())
+ {
+ m_net_play = true;
+ m_recording_start_time = ExpansionInterface::CEXIIPL::NetPlay_GetEmulatedTime();
+ }
+ else if (Config::Get(Config::MAIN_CUSTOM_RTC_ENABLE))
+ {
+ m_recording_start_time = Config::Get(Config::MAIN_CUSTOM_RTC_VALUE);
+ }
+ else
+ {
+ m_recording_start_time = Common::Timer::GetLocalTimeSinceJan1970();
+ }
- for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i)
- {
- const SerialInterface::SIDevices si_device = Config::Get(Config::GetInfoForSIDevice(i));
- if (si_device == SerialInterface::SIDEVICE_GC_TARUKONGA)
- m_bongos |= (1 << i);
- }
+ m_rerecords = 0;
- if (Core::IsRunning(m_system))
- {
- const std::string save_path = File::GetUserPath(D_STATESAVES_IDX) + "dtm.sav";
- if (File::Exists(save_path))
- File::Delete(save_path);
+ for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i)
+ {
+ const SerialInterface::SIDevices si_device = Config::Get(Config::GetInfoForSIDevice(i));
+ if (si_device == SerialInterface::SIDEVICE_GC_TARUKONGA)
+ m_bongos |= (1 << i);
+ }
- State::SaveAs(m_system, save_path);
- m_recording_from_save_state = true;
+ if (Core::IsRunning(m_system))
+ {
+ const std::string save_path = File::GetUserPath(D_STATESAVES_IDX) + "dtm.sav";
+ if (File::Exists(save_path))
+ File::Delete(save_path);
- std::thread md5thread(&MovieManager::GetMD5, this);
- md5thread.detach();
- GetSettings();
- }
+ State::SaveAs(m_system, save_path);
+ m_recording_from_save_state = true;
- // Wiimotes cause desync issues if they're not reset before launching the game
- if (!Core::IsRunning(m_system))
- {
- // This will also reset the Wiimotes for GameCube games, but that shouldn't do anything
- ::Wiimote::ResetAllWiimotes();
- }
+ std::thread md5thread(&MovieManager::GetMD5, this);
+ md5thread.detach();
+ GetSettings();
+ }
- m_play_mode = PlayMode::Recording;
- m_author = Config::Get(Config::MAIN_MOVIE_MOVIE_AUTHOR);
- m_temp_input.clear();
+ // Wiimotes cause desync issues if they're not reset before launching the game
+ if (!Core::IsRunning(m_system))
+ {
+ // This will also reset the Wiimotes for GameCube games, but that shouldn't do anything
+ ::Wiimote::ResetAllWiimotes();
+ }
- m_current_byte = 0;
+ m_play_mode = PlayMode::Recording;
+ m_author = Config::Get(Config::MAIN_MOVIE_MOVIE_AUTHOR);
+ m_temp_input.clear();
- // This is a bit of a hack, SYSCONF movie code expects the movie layer active for both recording
- // and playback. That layer is really only designed for playback, not recording. Also, we can't
- // know if we're using a Wii at this point. So, we'll assume a Wii is used here. In practice,
- // this shouldn't affect anything for GC (as its only unique setting is language, which will be
- // taken from base settings as expected)
- static DTMHeader header = {.bWii = true};
- ConfigLoaders::SaveToDTM(&header);
- Config::AddLayer(ConfigLoaders::GenerateMovieConfigLoader(&header));
+ m_current_byte = 0;
- if (Core::IsRunning(m_system))
- Core::UpdateWantDeterminism(m_system);
- };
- Core::RunOnCPUThread(m_system, start_recording, true);
+ // This is a bit of a hack, SYSCONF movie code expects the movie layer active for both recording
+ // and playback. That layer is really only designed for playback, not recording. Also, we can't
+ // know if we're using a Wii at this point. So, we'll assume a Wii is used here. In practice,
+ // this shouldn't affect anything for GC (as its only unique setting is language, which will be
+ // taken from base settings as expected)
+ static DTMHeader header = {.bWii = true};
+ ConfigLoaders::SaveToDTM(&header);
+ Config::AddLayer(ConfigLoaders::GenerateMovieConfigLoader(&header));
+
+ if (Core::IsRunning(m_system))
+ Core::UpdateWantDeterminism(m_system);
- Core::DisplayMessage("Starting movie recording", 2000);
return true;
}