Use generic libpdx event bits facility in libvrflinger and bufferhubd.
Use the generic event bits abstraction to support UDS and ServiceFS
backends properly.
Bug: 34466748
Test: start/stop basicvr repeatedly; observe stable bufferhub counts.
Change-Id: I9f2ea67c25860ad7fb931938991a29a37f3391fc
diff --git a/libs/vr/libbufferhub/include/private/dvr/buffer_hub_client.h b/libs/vr/libbufferhub/include/private/dvr/buffer_hub_client.h
index b6ff5b6..cefde7b 100644
--- a/libs/vr/libbufferhub/include/private/dvr/buffer_hub_client.h
+++ b/libs/vr/libbufferhub/include/private/dvr/buffer_hub_client.h
@@ -71,6 +71,15 @@
}
using Client::event_fd;
+
+ Status<int> GetEventMask(int events) {
+ if (auto* client_channel = GetChannel()) {
+ return client_channel->GetEventMask(events);
+ } else {
+ return pdx::ErrorStatus(EINVAL);
+ }
+ }
+
native_handle_t* native_handle() const {
return const_cast<native_handle_t*>(slices_[0].handle());
}
@@ -158,8 +167,9 @@
int Post(const LocalHandle& ready_fence) {
return Post(ready_fence, nullptr, 0);
}
- template <typename Meta, typename = typename std::enable_if<
- !std::is_void<Meta>::value>::type>
+ template <
+ typename Meta,
+ typename = typename std::enable_if<!std::is_void<Meta>::value>::type>
int Post(const LocalHandle& ready_fence, const Meta& meta) {
return Post(ready_fence, &meta, sizeof(meta));
}
diff --git a/libs/vr/libvrflinger/display_surface.cpp b/libs/vr/libvrflinger/display_surface.cpp
index dff08b5..e1729f8 100644
--- a/libs/vr/libvrflinger/display_surface.cpp
+++ b/libs/vr/libvrflinger/display_surface.cpp
@@ -396,6 +396,16 @@
void DisplaySurface::HandleConsumerEvents(
const std::shared_ptr<BufferConsumer>& consumer, int events) {
+ auto status = consumer->GetEventMask(events);
+ if (!status) {
+ ALOGW(
+ "DisplaySurface::HandleConsumerEvents: Failed to get event mask for "
+ "consumer: %s",
+ status.GetErrorMessage().c_str());
+ return;
+ }
+
+ events = status.get();
if (events & EPOLLHUP) {
ALOGD_IF(TRACE,
"DisplaySurface::HandleConsumerEvents: removing event handler for "