diff options
| author | 2022-04-07 19:36:31 +0100 | |
|---|---|---|
| committer | 2022-04-07 19:44:07 +0100 | |
| commit | d79274a5d973f6000e20df6261d7624c89cbff59 (patch) | |
| tree | 03441e1c98ae9fe49a406b3d869a39262ae291a2 | |
| parent | yuzu/util: Replace lock_guard with scoped_lock (diff) | |
| download | yuzu-d79274a5d973f6000e20df6261d7624c89cbff59.tar.gz yuzu-d79274a5d973f6000e20df6261d7624c89cbff59.tar.xz yuzu-d79274a5d973f6000e20df6261d7624c89cbff59.zip | |
core/hle: Standardize scoped_lock initializers
5 files changed, 23 insertions, 23 deletions
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 | ||
| 42 | Status BufferItemConsumer::ReleaseBuffer(const BufferItem& item, Fence& release_fence) { | 42 | Status 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 | ||
| 20 | Status BufferQueueConsumer::AcquireBuffer(BufferItem* out_buffer, | 20 | Status 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; | |||
| 15 | BufferQueueCore::~BufferQueueCore() = default; | 15 | BufferQueueCore::~BufferQueueCore() = default; |
| 16 | 16 | ||
| 17 | void BufferQueueCore::NotifyShutdown() { | 17 | void 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() { | |||
| 38 | Status BufferQueueProducer::RequestBuffer(s32 slot, std::shared_ptr<GraphicBuffer>* buf) { | 38 | Status 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 | |||
| 320 | Status BufferQueueProducer::DetachBuffer(s32 slot) { | 320 | Status 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, | |||
| 597 | void BufferQueueProducer::CancelBuffer(s32 slot, const Fence& fence) { | 597 | void 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 | ||
| 625 | Status BufferQueueProducer::Query(NativeWindow what, s32* out_value) { | 625 | Status 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) { | |||
| 673 | Status BufferQueueProducer::Connect(const std::shared_ptr<IProducerListener>& listener, | 673 | Status 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 | ||
| 20 | ConsumerBase::~ConsumerBase() { | 20 | ConsumerBase::~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 | ||
| 46 | void ConsumerBase::OnBuffersReleased() { | 46 | void 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 | ||