From 90ac0d28da215c5fbf6134ef5efb4e563ab513ad Mon Sep 17 00:00:00 2001 From: Maufeat Date: Mon, 29 Dec 2025 22:31:01 +0100 Subject: [PATCH] [nvnflinger] Partially revert #152 --- .../nvnflinger/buffer_queue_producer.cpp | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp index 4f6cdd6945..f2742eadf9 100644 --- a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp @@ -724,26 +724,22 @@ Status BufferQueueProducer::Connect(const std::shared_ptr& li return status; } -// https://android.googlesource.com/platform/frameworks/native/%2B/master/libs/gui/BufferQueueProducer.cpp#1457 Status BufferQueueProducer::Disconnect(NativeWindowApi api) { - LOG_DEBUG(Service_Nvnflinger, "disconnect api = {}", api); + LOG_DEBUG(Service_Nvnflinger, "api = {}", api); - std::shared_ptr listener; Status status = Status::NoError; + std::shared_ptr listener; { std::scoped_lock lock{core->mutex}; + core->WaitWhileAllocatingLocked(); if (core->is_abandoned) { + // Disconnecting after the surface has been abandoned is a no-op. return Status::NoError; } - if (core->connected_api == NativeWindowApi::NoConnectedApi) { - LOG_DEBUG(Service_Nvnflinger, "disconnect: not connected (req = {})", api); - return Status::NoInit; - } - switch (api) { case NativeWindowApi::Egl: case NativeWindowApi::Cpu: @@ -758,20 +754,20 @@ Status BufferQueueProducer::Disconnect(NativeWindowApi api) { buffer_wait_event->Signal(); listener = core->consumer_listener; } else { - LOG_ERROR(Service_Nvnflinger, - "disconnect: still connected to another api (cur = {} req = {})", + LOG_ERROR(Service_Nvnflinger, "still connected to another api (cur = {} req = {})", core->connected_api, api); status = Status::BadValue; } break; default: - LOG_ERROR(Service_Nvnflinger, "disconnect: unknown api = {}", api); + LOG_ERROR(Service_Nvnflinger, "unknown api = {}", api); status = Status::BadValue; break; } } - if (listener) { + // Call back without lock held + if (listener != nullptr) { listener->OnBuffersReleased(); } @@ -930,7 +926,7 @@ void BufferQueueProducer::Transact(u32 code, std::span parcel_data, break; } case TransactionId::GetBufferHistory: - LOG_WARNING(Service_Nvnflinger, "(STUBBED) called, transaction=GetBufferHistory"); + LOG_DEBUG(Service_Nvnflinger, "(STUBBED) called, transaction=GetBufferHistory"); break; default: ASSERT_MSG(false, "Unimplemented TransactionId {}", code);