drm_hwcomposer: refactor Worker
Make use of standard library mutex and conditions which simplifies use
of condition variables and benefits from things like scoped locking.
Also add tests to make sure it runs as expected.
Change-Id: Iaf92e17e1f6757dce490eddee61f84cb1f953b0c
diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp
index bc0adbc..a1baed1 100644
--- a/drmdisplaycompositor.cpp
+++ b/drmdisplaycompositor.cpp
@@ -195,18 +195,14 @@
frame.composition = std::move(composition);
frame.status = status;
frame_queue_.push(std::move(frame));
- SignalLocked();
Unlock();
+ Signal();
}
void DrmDisplayCompositor::FrameWorker::Routine() {
- int ret = Lock();
- if (ret) {
- ALOGE("Failed to lock worker, %d", ret);
- return;
- }
-
int wait_ret = 0;
+
+ Lock();
if (frame_queue_.empty()) {
wait_ret = WaitForSignalOrExitLocked();
}
@@ -216,12 +212,7 @@
frame = std::move(frame_queue_.front());
frame_queue_.pop();
}
-
- ret = Unlock();
- if (ret) {
- ALOGE("Failed to unlock worker, %d", ret);
- return;
- }
+ Unlock();
if (wait_ret == -EINTR) {
return;