summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar bunnei2022-04-08 14:01:42 -0700
committerGravatar GitHub2022-04-08 14:01:42 -0700
commit04efd729d6b86b133d1ccacfcab77235e247f766 (patch)
tree2a896020311d81e739adf0d2803d589f88ece313 /src/core
parentMerge pull request #8173 from Morph1984/msvc-warn-unused-fn (diff)
parentcore/hle: Standardize scoped_lock initializers (diff)
downloadyuzu-04efd729d6b86b133d1ccacfcab77235e247f766.tar.gz
yuzu-04efd729d6b86b133d1ccacfcab77235e247f766.tar.xz
yuzu-04efd729d6b86b133d1ccacfcab77235e247f766.zip
Merge pull request #8169 from merryhime/scoped_lock
Replace lock_guard with scoped_lock
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/kernel/kernel.cpp16
-rw-r--r--src/core/hle/kernel/time_manager.cpp4
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp2
-rw-r--r--src/core/hle/service/nvflinger/buffer_item_consumer.cpp4
-rw-r--r--src/core/hle/service/nvflinger/buffer_queue_consumer.cpp8
-rw-r--r--src/core/hle/service/nvflinger/buffer_queue_core.cpp2
-rw-r--r--src/core/hle/service/nvflinger/buffer_queue_producer.cpp28
-rw-r--r--src/core/hle/service/nvflinger/consumer_base.cpp4
-rw-r--r--src/core/hle/service/nvflinger/hos_binder_driver_server.cpp4
-rw-r--r--src/core/perf_stats.cpp10
-rw-r--r--src/core/tools/freezer.cpp18
11 files changed, 50 insertions, 50 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 6387d0c29..134a0b8e9 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -99,7 +99,7 @@ struct KernelCore::Impl {
99 // Close all open server ports. 99 // Close all open server ports.
100 std::unordered_set<KServerPort*> server_ports_; 100 std::unordered_set<KServerPort*> server_ports_;
101 { 101 {
102 std::lock_guard lk(server_ports_lock); 102 std::scoped_lock lk{server_ports_lock};
103 server_ports_ = server_ports; 103 server_ports_ = server_ports;
104 server_ports.clear(); 104 server_ports.clear();
105 } 105 }
@@ -157,7 +157,7 @@ struct KernelCore::Impl {
157 157
158 // Close kernel objects that were not freed on shutdown 158 // Close kernel objects that were not freed on shutdown
159 { 159 {
160 std::lock_guard lk(registered_in_use_objects_lock); 160 std::scoped_lock lk{registered_in_use_objects_lock};
161 if (registered_in_use_objects.size()) { 161 if (registered_in_use_objects.size()) {
162 for (auto& object : registered_in_use_objects) { 162 for (auto& object : registered_in_use_objects) {
163 object->Close(); 163 object->Close();
@@ -178,7 +178,7 @@ struct KernelCore::Impl {
178 178
179 // Track kernel objects that were not freed on shutdown 179 // Track kernel objects that were not freed on shutdown
180 { 180 {
181 std::lock_guard lk(registered_objects_lock); 181 std::scoped_lock lk{registered_objects_lock};
182 if (registered_objects.size()) { 182 if (registered_objects.size()) {
183 LOG_DEBUG(Kernel, "{} kernel objects were dangling on shutdown!", 183 LOG_DEBUG(Kernel, "{} kernel objects were dangling on shutdown!",
184 registered_objects.size()); 184 registered_objects.size());
@@ -660,7 +660,7 @@ struct KernelCore::Impl {
660 660
661 KClientPort* port = &search->second(system.ServiceManager(), system); 661 KClientPort* port = &search->second(system.ServiceManager(), system);
662 { 662 {
663 std::lock_guard lk(server_ports_lock); 663 std::scoped_lock lk{server_ports_lock};
664 server_ports.insert(&port->GetParent()->GetServerPort()); 664 server_ports.insert(&port->GetParent()->GetServerPort());
665 } 665 }
666 return port; 666 return port;
@@ -929,22 +929,22 @@ KClientPort* KernelCore::CreateNamedServicePort(std::string name) {
929} 929}
930 930
931void KernelCore::RegisterKernelObject(KAutoObject* object) { 931void KernelCore::RegisterKernelObject(KAutoObject* object) {
932 std::lock_guard lk(impl->registered_objects_lock); 932 std::scoped_lock lk{impl->registered_objects_lock};
933 impl->registered_objects.insert(object); 933 impl->registered_objects.insert(object);
934} 934}
935 935
936void KernelCore::UnregisterKernelObject(KAutoObject* object) { 936void KernelCore::UnregisterKernelObject(KAutoObject* object) {
937 std::lock_guard lk(impl->registered_objects_lock); 937 std::scoped_lock lk{impl->registered_objects_lock};
938 impl->registered_objects.erase(object); 938 impl->registered_objects.erase(object);
939} 939}
940 940
941void KernelCore::RegisterInUseObject(KAutoObject* object) { 941void KernelCore::RegisterInUseObject(KAutoObject* object) {
942 std::lock_guard lk(impl->registered_in_use_objects_lock); 942 std::scoped_lock lk{impl->registered_in_use_objects_lock};
943 impl->registered_in_use_objects.insert(object); 943 impl->registered_in_use_objects.insert(object);
944} 944}
945 945
946void KernelCore::UnregisterInUseObject(KAutoObject* object) { 946void KernelCore::UnregisterInUseObject(KAutoObject* object) {
947 std::lock_guard lk(impl->registered_in_use_objects_lock); 947 std::scoped_lock lk{impl->registered_in_use_objects_lock};
948 impl->registered_in_use_objects.erase(object); 948 impl->registered_in_use_objects.erase(object);
949} 949}
950 950
diff --git a/src/core/hle/kernel/time_manager.cpp b/src/core/hle/kernel/time_manager.cpp
index aa985d820..5b8fe8eae 100644
--- a/src/core/hle/kernel/time_manager.cpp
+++ b/src/core/hle/kernel/time_manager.cpp
@@ -24,7 +24,7 @@ TimeManager::TimeManager(Core::System& system_) : system{system_} {
24} 24}
25 25
26void TimeManager::ScheduleTimeEvent(KThread* thread, s64 nanoseconds) { 26void TimeManager::ScheduleTimeEvent(KThread* thread, s64 nanoseconds) {
27 std::lock_guard lock{mutex}; 27 std::scoped_lock lock{mutex};
28 if (nanoseconds > 0) { 28 if (nanoseconds > 0) {
29 ASSERT(thread); 29 ASSERT(thread);
30 ASSERT(thread->GetState() != ThreadState::Runnable); 30 ASSERT(thread->GetState() != ThreadState::Runnable);
@@ -35,7 +35,7 @@ void TimeManager::ScheduleTimeEvent(KThread* thread, s64 nanoseconds) {
35} 35}
36 36
37void TimeManager::UnscheduleTimeEvent(KThread* thread) { 37void TimeManager::UnscheduleTimeEvent(KThread* thread) {
38 std::lock_guard lock{mutex}; 38 std::scoped_lock lock{mutex};
39 system.CoreTiming().UnscheduleEvent(time_manager_event_type, 39 system.CoreTiming().UnscheduleEvent(time_manager_event_type,
40 reinterpret_cast<uintptr_t>(thread)); 40 reinterpret_cast<uintptr_t>(thread));
41} 41}
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp
index aa6cb34b7..4e17a952e 100644
--- a/src/core/hle/service/hid/controllers/npad.cpp
+++ b/src/core/hle/service/hid/controllers/npad.cpp
@@ -318,7 +318,7 @@ void Controller_NPad::OnRelease() {
318} 318}
319 319
320void Controller_NPad::RequestPadStateUpdate(Core::HID::NpadIdType npad_id) { 320void Controller_NPad::RequestPadStateUpdate(Core::HID::NpadIdType npad_id) {
321 std::lock_guard lock{mutex}; 321 std::scoped_lock lock{mutex};
322 auto& controller = GetControllerFromNpadIdType(npad_id); 322 auto& controller = GetControllerFromNpadIdType(npad_id);
323 const auto controller_type = controller.device->GetNpadStyleIndex(); 323 const auto controller_type = controller.device->GetNpadStyleIndex();
324 if (!controller.device->IsConnected()) { 324 if (!controller.device->IsConnected()) {
diff --git a/src/core/hle/service/nvflinger/buffer_item_consumer.cpp b/src/core/hle/service/nvflinger/buffer_item_consumer.cpp
index 93fa1ec10..d7ee5362b 100644
--- a/src/core/hle/service/nvflinger/buffer_item_consumer.cpp
+++ b/src/core/hle/service/nvflinger/buffer_item_consumer.cpp
@@ -21,7 +21,7 @@ Status BufferItemConsumer::AcquireBuffer(BufferItem* item, std::chrono::nanoseco
21 return Status::BadValue; 21 return Status::BadValue;
22 } 22 }
23 23
24 std::scoped_lock lock(mutex); 24 std::scoped_lock lock{mutex};
25 25
26 if (const auto status = AcquireBufferLocked(item, present_when); status != Status::NoError) { 26 if (const auto status = AcquireBufferLocked(item, present_when); status != Status::NoError) {
27 if (status != Status::NoBufferAvailable) { 27 if (status != Status::NoBufferAvailable) {
@@ -40,7 +40,7 @@ Status BufferItemConsumer::AcquireBuffer(BufferItem* item, std::chrono::nanoseco
40} 40}
41 41
42Status BufferItemConsumer::ReleaseBuffer(const BufferItem& item, Fence& release_fence) { 42Status BufferItemConsumer::ReleaseBuffer(const BufferItem& item, Fence& release_fence) {
43 std::scoped_lock lock(mutex); 43 std::scoped_lock lock{mutex};
44 44
45 if (const auto status = AddReleaseFenceLocked(item.buf, item.graphic_buffer, release_fence); 45 if (const auto status = AddReleaseFenceLocked(item.buf, item.graphic_buffer, release_fence);
46 status != Status::NoError) { 46 status != Status::NoError) {
diff --git a/src/core/hle/service/nvflinger/buffer_queue_consumer.cpp b/src/core/hle/service/nvflinger/buffer_queue_consumer.cpp
index c527c577e..3ab9a8c05 100644
--- a/src/core/hle/service/nvflinger/buffer_queue_consumer.cpp
+++ b/src/core/hle/service/nvflinger/buffer_queue_consumer.cpp
@@ -19,7 +19,7 @@ BufferQueueConsumer::~BufferQueueConsumer() = default;
19 19
20Status BufferQueueConsumer::AcquireBuffer(BufferItem* out_buffer, 20Status BufferQueueConsumer::AcquireBuffer(BufferItem* out_buffer,
21 std::chrono::nanoseconds expected_present) { 21 std::chrono::nanoseconds expected_present) {
22 std::scoped_lock lock(core->mutex); 22 std::scoped_lock lock{core->mutex};
23 23
24 // Check that the consumer doesn't currently have the maximum number of buffers acquired. 24 // Check that the consumer doesn't currently have the maximum number of buffers acquired.
25 const s32 num_acquired_buffers{ 25 const s32 num_acquired_buffers{
@@ -120,7 +120,7 @@ Status BufferQueueConsumer::ReleaseBuffer(s32 slot, u64 frame_number, const Fenc
120 120
121 std::shared_ptr<IProducerListener> listener; 121 std::shared_ptr<IProducerListener> listener;
122 { 122 {
123 std::scoped_lock lock(core->mutex); 123 std::scoped_lock lock{core->mutex};
124 124
125 // If the frame number has changed because the buffer has been reallocated, we can ignore 125 // If the frame number has changed because the buffer has been reallocated, we can ignore
126 // this ReleaseBuffer for the old buffer. 126 // this ReleaseBuffer for the old buffer.
@@ -180,7 +180,7 @@ Status BufferQueueConsumer::Connect(std::shared_ptr<IConsumerListener> consumer_
180 180
181 LOG_DEBUG(Service_NVFlinger, "controlled_by_app={}", controlled_by_app); 181 LOG_DEBUG(Service_NVFlinger, "controlled_by_app={}", controlled_by_app);
182 182
183 std::scoped_lock lock(core->mutex); 183 std::scoped_lock lock{core->mutex};
184 184
185 if (core->is_abandoned) { 185 if (core->is_abandoned) {
186 LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned"); 186 LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned");
@@ -199,7 +199,7 @@ Status BufferQueueConsumer::GetReleasedBuffers(u64* out_slot_mask) {
199 return Status::BadValue; 199 return Status::BadValue;
200 } 200 }
201 201
202 std::scoped_lock lock(core->mutex); 202 std::scoped_lock lock{core->mutex};
203 203
204 if (core->is_abandoned) { 204 if (core->is_abandoned) {
205 LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned"); 205 LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned");
diff --git a/src/core/hle/service/nvflinger/buffer_queue_core.cpp b/src/core/hle/service/nvflinger/buffer_queue_core.cpp
index 3a0481786..ec5aabaeb 100644
--- a/src/core/hle/service/nvflinger/buffer_queue_core.cpp
+++ b/src/core/hle/service/nvflinger/buffer_queue_core.cpp
@@ -15,7 +15,7 @@ BufferQueueCore::BufferQueueCore() = default;
15BufferQueueCore::~BufferQueueCore() = default; 15BufferQueueCore::~BufferQueueCore() = default;
16 16
17void BufferQueueCore::NotifyShutdown() { 17void BufferQueueCore::NotifyShutdown() {
18 std::scoped_lock lock(mutex); 18 std::scoped_lock lock{mutex};
19 19
20 is_shutting_down = true; 20 is_shutting_down = true;
21 21
diff --git a/src/core/hle/service/nvflinger/buffer_queue_producer.cpp b/src/core/hle/service/nvflinger/buffer_queue_producer.cpp
index 3d6e990c3..6f604a88e 100644
--- a/src/core/hle/service/nvflinger/buffer_queue_producer.cpp
+++ b/src/core/hle/service/nvflinger/buffer_queue_producer.cpp
@@ -38,7 +38,7 @@ BufferQueueProducer::~BufferQueueProducer() {
38Status BufferQueueProducer::RequestBuffer(s32 slot, std::shared_ptr<GraphicBuffer>* buf) { 38Status BufferQueueProducer::RequestBuffer(s32 slot, std::shared_ptr<GraphicBuffer>* buf) {
39 LOG_DEBUG(Service_NVFlinger, "slot {}", slot); 39 LOG_DEBUG(Service_NVFlinger, "slot {}", slot);
40 40
41 std::scoped_lock lock(core->mutex); 41 std::scoped_lock lock{core->mutex};
42 42
43 if (core->is_abandoned) { 43 if (core->is_abandoned) {
44 LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned"); 44 LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned");
@@ -65,7 +65,7 @@ Status BufferQueueProducer::SetBufferCount(s32 buffer_count) {
65 65
66 std::shared_ptr<IConsumerListener> listener; 66 std::shared_ptr<IConsumerListener> listener;
67 { 67 {
68 std::scoped_lock lock(core->mutex); 68 std::scoped_lock lock{core->mutex};
69 core->WaitWhileAllocatingLocked(); 69 core->WaitWhileAllocatingLocked();
70 70
71 if (core->is_abandoned) { 71 if (core->is_abandoned) {
@@ -236,7 +236,7 @@ Status BufferQueueProducer::DequeueBuffer(s32* out_slot, Fence* out_fence, bool
236 Status return_flags = Status::NoError; 236 Status return_flags = Status::NoError;
237 bool attached_by_consumer = false; 237 bool attached_by_consumer = false;
238 { 238 {
239 std::scoped_lock lock(core->mutex); 239 std::scoped_lock lock{core->mutex};
240 core->WaitWhileAllocatingLocked(); 240 core->WaitWhileAllocatingLocked();
241 241
242 if (format == PixelFormat::NoFormat) { 242 if (format == PixelFormat::NoFormat) {
@@ -295,7 +295,7 @@ Status BufferQueueProducer::DequeueBuffer(s32* out_slot, Fence* out_fence, bool
295 } 295 }
296 296
297 { 297 {
298 std::scoped_lock lock(core->mutex); 298 std::scoped_lock lock{core->mutex};
299 299
300 if (core->is_abandoned) { 300 if (core->is_abandoned) {
301 LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned"); 301 LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned");
@@ -320,7 +320,7 @@ Status BufferQueueProducer::DequeueBuffer(s32* out_slot, Fence* out_fence, bool
320Status BufferQueueProducer::DetachBuffer(s32 slot) { 320Status BufferQueueProducer::DetachBuffer(s32 slot) {
321 LOG_DEBUG(Service_NVFlinger, "slot {}", slot); 321 LOG_DEBUG(Service_NVFlinger, "slot {}", slot);
322 322
323 std::scoped_lock lock(core->mutex); 323 std::scoped_lock lock{core->mutex};
324 324
325 if (core->is_abandoned) { 325 if (core->is_abandoned) {
326 LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned"); 326 LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned");
@@ -356,7 +356,7 @@ Status BufferQueueProducer::DetachNextBuffer(std::shared_ptr<GraphicBuffer>* out
356 return Status::BadValue; 356 return Status::BadValue;
357 } 357 }
358 358
359 std::scoped_lock lock(core->mutex); 359 std::scoped_lock lock{core->mutex};
360 core->WaitWhileAllocatingLocked(); 360 core->WaitWhileAllocatingLocked();
361 361
362 if (core->is_abandoned) { 362 if (core->is_abandoned) {
@@ -399,7 +399,7 @@ Status BufferQueueProducer::AttachBuffer(s32* out_slot,
399 return Status::BadValue; 399 return Status::BadValue;
400 } 400 }
401 401
402 std::scoped_lock lock(core->mutex); 402 std::scoped_lock lock{core->mutex};
403 core->WaitWhileAllocatingLocked(); 403 core->WaitWhileAllocatingLocked();
404 404
405 Status return_flags = Status::NoError; 405 Status return_flags = Status::NoError;
@@ -460,7 +460,7 @@ Status BufferQueueProducer::QueueBuffer(s32 slot, const QueueBufferInput& input,
460 BufferItem item; 460 BufferItem item;
461 461
462 { 462 {
463 std::scoped_lock lock(core->mutex); 463 std::scoped_lock lock{core->mutex};
464 464
465 if (core->is_abandoned) { 465 if (core->is_abandoned) {
466 LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned"); 466 LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned");
@@ -576,7 +576,7 @@ Status BufferQueueProducer::QueueBuffer(s32 slot, const QueueBufferInput& input,
576 // Call back without the main BufferQueue lock held, but with the callback lock held so we can 576 // Call back without the main BufferQueue lock held, but with the callback lock held so we can
577 // ensure that callbacks occur in order 577 // ensure that callbacks occur in order
578 { 578 {
579 std::scoped_lock lock(callback_mutex); 579 std::scoped_lock lock{callback_mutex};
580 while (callback_ticket != current_callback_ticket) { 580 while (callback_ticket != current_callback_ticket) {
581 callback_condition.wait(callback_mutex); 581 callback_condition.wait(callback_mutex);
582 } 582 }
@@ -597,7 +597,7 @@ Status BufferQueueProducer::QueueBuffer(s32 slot, const QueueBufferInput& input,
597void BufferQueueProducer::CancelBuffer(s32 slot, const Fence& fence) { 597void BufferQueueProducer::CancelBuffer(s32 slot, const Fence& fence) {
598 LOG_DEBUG(Service_NVFlinger, "slot {}", slot); 598 LOG_DEBUG(Service_NVFlinger, "slot {}", slot);
599 599
600 std::scoped_lock lock(core->mutex); 600 std::scoped_lock lock{core->mutex};
601 601
602 if (core->is_abandoned) { 602 if (core->is_abandoned) {
603 LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned"); 603 LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned");
@@ -623,7 +623,7 @@ void BufferQueueProducer::CancelBuffer(s32 slot, const Fence& fence) {
623} 623}
624 624
625Status BufferQueueProducer::Query(NativeWindow what, s32* out_value) { 625Status BufferQueueProducer::Query(NativeWindow what, s32* out_value) {
626 std::scoped_lock lock(core->mutex); 626 std::scoped_lock lock{core->mutex};
627 627
628 if (out_value == nullptr) { 628 if (out_value == nullptr) {
629 LOG_ERROR(Service_NVFlinger, "outValue was nullptr"); 629 LOG_ERROR(Service_NVFlinger, "outValue was nullptr");
@@ -673,7 +673,7 @@ Status BufferQueueProducer::Query(NativeWindow what, s32* out_value) {
673Status BufferQueueProducer::Connect(const std::shared_ptr<IProducerListener>& listener, 673Status BufferQueueProducer::Connect(const std::shared_ptr<IProducerListener>& listener,
674 NativeWindowApi api, bool producer_controlled_by_app, 674 NativeWindowApi api, bool producer_controlled_by_app,
675 QueueBufferOutput* output) { 675 QueueBufferOutput* output) {
676 std::scoped_lock lock(core->mutex); 676 std::scoped_lock lock{core->mutex};
677 677
678 LOG_DEBUG(Service_NVFlinger, "api = {} producer_controlled_by_app = {}", api, 678 LOG_DEBUG(Service_NVFlinger, "api = {} producer_controlled_by_app = {}", api,
679 producer_controlled_by_app); 679 producer_controlled_by_app);
@@ -730,7 +730,7 @@ Status BufferQueueProducer::Disconnect(NativeWindowApi api) {
730 std::shared_ptr<IConsumerListener> listener; 730 std::shared_ptr<IConsumerListener> listener;
731 731
732 { 732 {
733 std::scoped_lock lock(core->mutex); 733 std::scoped_lock lock{core->mutex};
734 734
735 core->WaitWhileAllocatingLocked(); 735 core->WaitWhileAllocatingLocked();
736 736
@@ -780,7 +780,7 @@ Status BufferQueueProducer::SetPreallocatedBuffer(s32 slot,
780 return Status::BadValue; 780 return Status::BadValue;
781 } 781 }
782 782
783 std::scoped_lock lock(core->mutex); 783 std::scoped_lock lock{core->mutex};
784 784
785 slots[slot] = {}; 785 slots[slot] = {};
786 slots[slot].graphic_buffer = buffer; 786 slots[slot].graphic_buffer = buffer;
diff --git a/src/core/hle/service/nvflinger/consumer_base.cpp b/src/core/hle/service/nvflinger/consumer_base.cpp
index c2c80832c..30fc21acc 100644
--- a/src/core/hle/service/nvflinger/consumer_base.cpp
+++ b/src/core/hle/service/nvflinger/consumer_base.cpp
@@ -18,7 +18,7 @@ ConsumerBase::ConsumerBase(std::unique_ptr<BufferQueueConsumer> consumer_)
18 : consumer{std::move(consumer_)} {} 18 : consumer{std::move(consumer_)} {}
19 19
20ConsumerBase::~ConsumerBase() { 20ConsumerBase::~ConsumerBase() {
21 std::scoped_lock lock(mutex); 21 std::scoped_lock lock{mutex};
22 22
23 ASSERT_MSG(is_abandoned, "consumer is not abandoned!"); 23 ASSERT_MSG(is_abandoned, "consumer is not abandoned!");
24} 24}
@@ -44,7 +44,7 @@ void ConsumerBase::OnFrameReplaced(const BufferItem& item) {
44} 44}
45 45
46void ConsumerBase::OnBuffersReleased() { 46void ConsumerBase::OnBuffersReleased() {
47 std::scoped_lock lock(mutex); 47 std::scoped_lock lock{mutex};
48 48
49 LOG_DEBUG(Service_NVFlinger, "called"); 49 LOG_DEBUG(Service_NVFlinger, "called");
50 50
diff --git a/src/core/hle/service/nvflinger/hos_binder_driver_server.cpp b/src/core/hle/service/nvflinger/hos_binder_driver_server.cpp
index 0c937d682..094ba2542 100644
--- a/src/core/hle/service/nvflinger/hos_binder_driver_server.cpp
+++ b/src/core/hle/service/nvflinger/hos_binder_driver_server.cpp
@@ -14,7 +14,7 @@ HosBinderDriverServer::HosBinderDriverServer(Core::System& system_)
14HosBinderDriverServer::~HosBinderDriverServer() {} 14HosBinderDriverServer::~HosBinderDriverServer() {}
15 15
16u64 HosBinderDriverServer::RegisterProducer(std::unique_ptr<android::IBinder>&& binder) { 16u64 HosBinderDriverServer::RegisterProducer(std::unique_ptr<android::IBinder>&& binder) {
17 std::lock_guard lk{lock}; 17 std::scoped_lock lk{lock};
18 18
19 last_id++; 19 last_id++;
20 20
@@ -24,7 +24,7 @@ u64 HosBinderDriverServer::RegisterProducer(std::unique_ptr<android::IBinder>&&
24} 24}
25 25
26android::IBinder* HosBinderDriverServer::TryGetProducer(u64 id) { 26android::IBinder* HosBinderDriverServer::TryGetProducer(u64 id) {
27 std::lock_guard lk{lock}; 27 std::scoped_lock lk{lock};
28 28
29 if (auto search = producers.find(id); search != producers.end()) { 29 if (auto search = producers.find(id); search != producers.end()) {
30 return search->second.get(); 30 return search->second.get();
diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp
index 52c43c857..6ef459b7a 100644
--- a/src/core/perf_stats.cpp
+++ b/src/core/perf_stats.cpp
@@ -53,13 +53,13 @@ PerfStats::~PerfStats() {
53} 53}
54 54
55void PerfStats::BeginSystemFrame() { 55void PerfStats::BeginSystemFrame() {
56 std::lock_guard lock{object_mutex}; 56 std::scoped_lock lock{object_mutex};
57 57
58 frame_begin = Clock::now(); 58 frame_begin = Clock::now();
59} 59}
60 60
61void PerfStats::EndSystemFrame() { 61void PerfStats::EndSystemFrame() {
62 std::lock_guard lock{object_mutex}; 62 std::scoped_lock lock{object_mutex};
63 63
64 auto frame_end = Clock::now(); 64 auto frame_end = Clock::now();
65 const auto frame_time = frame_end - frame_begin; 65 const auto frame_time = frame_end - frame_begin;
@@ -79,7 +79,7 @@ void PerfStats::EndGameFrame() {
79} 79}
80 80
81double PerfStats::GetMeanFrametime() const { 81double PerfStats::GetMeanFrametime() const {
82 std::lock_guard lock{object_mutex}; 82 std::scoped_lock lock{object_mutex};
83 83
84 if (current_index <= IgnoreFrames) { 84 if (current_index <= IgnoreFrames) {
85 return 0; 85 return 0;
@@ -91,7 +91,7 @@ double PerfStats::GetMeanFrametime() const {
91} 91}
92 92
93PerfStatsResults PerfStats::GetAndResetStats(microseconds current_system_time_us) { 93PerfStatsResults PerfStats::GetAndResetStats(microseconds current_system_time_us) {
94 std::lock_guard lock{object_mutex}; 94 std::scoped_lock lock{object_mutex};
95 95
96 const auto now = Clock::now(); 96 const auto now = Clock::now();
97 // Walltime elapsed since stats were reset 97 // Walltime elapsed since stats were reset
@@ -120,7 +120,7 @@ PerfStatsResults PerfStats::GetAndResetStats(microseconds current_system_time_us
120} 120}
121 121
122double PerfStats::GetLastFrameTimeScale() const { 122double PerfStats::GetLastFrameTimeScale() const {
123 std::lock_guard lock{object_mutex}; 123 std::scoped_lock lock{object_mutex};
124 124
125 constexpr double FRAME_LENGTH = 1.0 / 60; 125 constexpr double FRAME_LENGTH = 1.0 / 60;
126 return duration_cast<DoubleSecs>(previous_frame_length).count() / FRAME_LENGTH; 126 return duration_cast<DoubleSecs>(previous_frame_length).count() / FRAME_LENGTH;
diff --git a/src/core/tools/freezer.cpp b/src/core/tools/freezer.cpp
index 032c71aff..c81dc0e52 100644
--- a/src/core/tools/freezer.cpp
+++ b/src/core/tools/freezer.cpp
@@ -80,7 +80,7 @@ bool Freezer::IsActive() const {
80} 80}
81 81
82void Freezer::Clear() { 82void Freezer::Clear() {
83 std::lock_guard lock{entries_mutex}; 83 std::scoped_lock lock{entries_mutex};
84 84
85 LOG_DEBUG(Common_Memory, "Clearing all frozen memory values."); 85 LOG_DEBUG(Common_Memory, "Clearing all frozen memory values.");
86 86
@@ -88,7 +88,7 @@ void Freezer::Clear() {
88} 88}
89 89
90u64 Freezer::Freeze(VAddr address, u32 width) { 90u64 Freezer::Freeze(VAddr address, u32 width) {
91 std::lock_guard lock{entries_mutex}; 91 std::scoped_lock lock{entries_mutex};
92 92
93 const auto current_value = MemoryReadWidth(memory, width, address); 93 const auto current_value = MemoryReadWidth(memory, width, address);
94 entries.push_back({address, width, current_value}); 94 entries.push_back({address, width, current_value});
@@ -101,7 +101,7 @@ u64 Freezer::Freeze(VAddr address, u32 width) {
101} 101}
102 102
103void Freezer::Unfreeze(VAddr address) { 103void Freezer::Unfreeze(VAddr address) {
104 std::lock_guard lock{entries_mutex}; 104 std::scoped_lock lock{entries_mutex};
105 105
106 LOG_DEBUG(Common_Memory, "Unfreezing memory for address={:016X}", address); 106 LOG_DEBUG(Common_Memory, "Unfreezing memory for address={:016X}", address);
107 107
@@ -109,13 +109,13 @@ void Freezer::Unfreeze(VAddr address) {
109} 109}
110 110
111bool Freezer::IsFrozen(VAddr address) const { 111bool Freezer::IsFrozen(VAddr address) const {
112 std::lock_guard lock{entries_mutex}; 112 std::scoped_lock lock{entries_mutex};
113 113
114 return FindEntry(address) != entries.cend(); 114 return FindEntry(address) != entries.cend();
115} 115}
116 116
117void Freezer::SetFrozenValue(VAddr address, u64 value) { 117void Freezer::SetFrozenValue(VAddr address, u64 value) {
118 std::lock_guard lock{entries_mutex}; 118 std::scoped_lock lock{entries_mutex};
119 119
120 const auto iter = FindEntry(address); 120 const auto iter = FindEntry(address);
121 121
@@ -132,7 +132,7 @@ void Freezer::SetFrozenValue(VAddr address, u64 value) {
132} 132}
133 133
134std::optional<Freezer::Entry> Freezer::GetEntry(VAddr address) const { 134std::optional<Freezer::Entry> Freezer::GetEntry(VAddr address) const {
135 std::lock_guard lock{entries_mutex}; 135 std::scoped_lock lock{entries_mutex};
136 136
137 const auto iter = FindEntry(address); 137 const auto iter = FindEntry(address);
138 138
@@ -144,7 +144,7 @@ std::optional<Freezer::Entry> Freezer::GetEntry(VAddr address) const {
144} 144}
145 145
146std::vector<Freezer::Entry> Freezer::GetEntries() const { 146std::vector<Freezer::Entry> Freezer::GetEntries() const {
147 std::lock_guard lock{entries_mutex}; 147 std::scoped_lock lock{entries_mutex};
148 148
149 return entries; 149 return entries;
150} 150}
@@ -165,7 +165,7 @@ void Freezer::FrameCallback(std::uintptr_t, std::chrono::nanoseconds ns_late) {
165 return; 165 return;
166 } 166 }
167 167
168 std::lock_guard lock{entries_mutex}; 168 std::scoped_lock lock{entries_mutex};
169 169
170 for (const auto& entry : entries) { 170 for (const auto& entry : entries) {
171 LOG_DEBUG(Common_Memory, 171 LOG_DEBUG(Common_Memory,
@@ -178,7 +178,7 @@ void Freezer::FrameCallback(std::uintptr_t, std::chrono::nanoseconds ns_late) {
178} 178}
179 179
180void Freezer::FillEntryReads() { 180void Freezer::FillEntryReads() {
181 std::lock_guard lock{entries_mutex}; 181 std::scoped_lock lock{entries_mutex};
182 182
183 LOG_DEBUG(Common_Memory, "Updating memory freeze entries to current values."); 183 LOG_DEBUG(Common_Memory, "Updating memory freeze entries to current values.");
184 184