From 9836a108daee3e28f8e9f05c5a75de81fb3594a4 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 10 Mar 2023 21:04:55 -0500 Subject: [PATCH] Avoid VDP access races. --- Machines/MasterSystem/MasterSystem.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Machines/MasterSystem/MasterSystem.cpp b/Machines/MasterSystem/MasterSystem.cpp index 30c20e672..8136049f6 100644 --- a/Machines/MasterSystem/MasterSystem.cpp +++ b/Machines/MasterSystem/MasterSystem.cpp @@ -181,24 +181,27 @@ template class ConcreteMachine: } void set_scan_target(Outputs::Display::ScanTarget *scan_target) final { - vdp_->set_tv_standard( + vdp_.last_valid()->set_tv_standard( (region_ == Target::Region::Europe) ? TI::TMS::TVStandard::PAL : TI::TMS::TVStandard::NTSC); - time_until_debounce_ = vdp_->get_time_until_line(-1); - vdp_->set_scan_target(scan_target); + // Doing the following would be technically correct, but isn't + // especially thread-safe and won't make a substantial difference. +// time_until_debounce_ = vdp_->get_time_until_line(-1); + + vdp_.last_valid()->set_scan_target(scan_target); } Outputs::Display::ScanStatus get_scaled_scan_status() const final { - return vdp_->get_scaled_scan_status(); + return vdp_.last_valid()->get_scaled_scan_status(); } void set_display_type(Outputs::Display::DisplayType display_type) final { - vdp_->set_display_type(display_type); + vdp_.last_valid()->set_display_type(display_type); } Outputs::Display::DisplayType get_display_type() const final { - return vdp_->get_display_type(); + return vdp_.last_valid()->get_display_type(); } Outputs::Speaker::Speaker *get_speaker() final {