a few changes according to android docs
All checks were successful
eden-license / license-header (pull_request) Successful in 27s

This commit is contained in:
Maufeat 2025-07-25 02:16:24 +02:00 committed by crueter
parent a2b0b7e801
commit 4db92a6ea4

View file

@ -728,31 +728,24 @@ Status BufferQueueProducer::Connect(const std::shared_ptr<IProducerListener>& li
return status; return status;
} }
// https://android.googlesource.com/platform/frameworks/native/%2B/master/libs/gui/BufferQueueProducer.cpp#1457
Status BufferQueueProducer::Disconnect(NativeWindowApi api) { Status BufferQueueProducer::Disconnect(NativeWindowApi api) {
LOG_DEBUG(Service_Nvnflinger, "api = {}", api); LOG_DEBUG(Service_Nvnflinger, "disconnect api = {}", api);
Status status = Status::NoError;
std::shared_ptr<IConsumerListener> listener; std::shared_ptr<IConsumerListener> listener;
Status status = Status::NoError;
{ {
std::scoped_lock lock{core->mutex}; std::scoped_lock lock{core->mutex};
core->WaitWhileAllocatingLocked(); core->WaitWhileAllocatingLocked();
if (core->is_abandoned) { if (core->is_abandoned) {
// Disconnecting after the surface has been abandoned is a no-op.
return Status::NoError; return Status::NoError;
} }
if (core->connected_api == NativeWindowApi::NoConnectedApi) { if (core->connected_api == NativeWindowApi::NoConnectedApi) {
LOG_DEBUG(Service_Nvnflinger, "already disconnected (req = {})", api); LOG_DEBUG(Service_Nvnflinger, "disconnect: not connected (req = {})", api);
return Status::NoError; return Status::NoInit;
}
if (core->connected_api != api) {
LOG_WARNING(Service_Nvnflinger,
"Disconnect api mismatch (cur = {} req = {}) — forcing disconnect",
core->connected_api, api);
} }
switch (api) { switch (api) {
@ -769,13 +762,14 @@ Status BufferQueueProducer::Disconnect(NativeWindowApi api) {
buffer_wait_event->Signal(); buffer_wait_event->Signal();
listener = core->consumer_listener; listener = core->consumer_listener;
} else { } else {
LOG_ERROR(Service_Nvnflinger, "still connected to another api (cur = {} req = {})", LOG_ERROR(Service_Nvnflinger,
"disconnect: still connected to another api (cur = {} req = {})",
core->connected_api, api); core->connected_api, api);
status = Status::BadValue; status = Status::BadValue;
} }
break; break;
default: default:
LOG_ERROR(Service_Nvnflinger, "unknown api = {}", api); LOG_ERROR(Service_Nvnflinger, "disconnect: unknown api = {}", api);
status = Status::BadValue; status = Status::BadValue;
break; break;
} }