diff options
-rw-r--r-- | hwc3/Composer.cpp | 12 | ||||
-rw-r--r-- | hwc3/Composer.h | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/hwc3/Composer.cpp b/hwc3/Composer.cpp index e3d714d..afd2602 100644 --- a/hwc3/Composer.cpp +++ b/hwc3/Composer.cpp @@ -42,7 +42,7 @@ ndk::ScopedAStatus Composer::createClient(std::shared_ptr<IComposerClient>* outC auto clientDestroyed = [this]() { onClientDestroyed(); }; client->setOnClientDestroyed(clientDestroyed); - mClient = client; + mClientAlive = true; *outClient = client; return ndk::ScopedAStatus::ok(); @@ -60,7 +60,7 @@ ndk::ScopedAStatus Composer::getCapabilities(std::vector<Capability>* caps) { } bool Composer::waitForClientDestroyedLocked(std::unique_lock<std::mutex>& lock) { - if (!mClient.expired()) { + if (mClientAlive) { using namespace std::chrono_literals; // In surface flinger we delete a composer client on one thread and @@ -71,18 +71,18 @@ bool Composer::waitForClientDestroyedLocked(std::unique_lock<std::mutex>& lock) // see if the existing client is destroyed. LOG(DEBUG) << "waiting for previous client to be destroyed"; mClientDestroyedCondition.wait_for(lock, 1s, - [this]() -> bool { return mClient.expired(); }); - if (!mClient.expired()) { + [this]() -> bool { return !mClientAlive; }); + if (mClientAlive) { LOG(DEBUG) << "previous client was not destroyed"; } } - return mClient.expired() ; + return !mClientAlive; } void Composer::onClientDestroyed() { std::lock_guard<std::mutex> lock(mClientMutex); - mClient.reset(); + mClientAlive = false; mClientDestroyedCondition.notify_all(); } diff --git a/hwc3/Composer.h b/hwc3/Composer.h index 91f8589..218465c 100644 --- a/hwc3/Composer.h +++ b/hwc3/Composer.h @@ -42,7 +42,7 @@ private: const std::unique_ptr<IComposerHal> mHal; std::mutex mClientMutex; - std::weak_ptr<ComposerClient> mClient GUARDED_BY(mClientMutex); + bool mClientAlive GUARDED_BY(mClientMutex) = false; std::condition_variable mClientDestroyedCondition; }; |