Loading services/audiopolicy/service/CaptureStateNotifier.cpp +17 −8 Original line number Diff line number Diff line #include "CaptureStateNotifier.h" #define LOG_TAG "CaptureStateNotifier" #include "CaptureStateNotifier.h" #include <android/media/ICaptureStateListener.h> #include <binder/IBinder.h> #include <utils/Log.h> Loading @@ -22,9 +22,9 @@ private: CaptureStateNotifier* const mNotifier; }; CaptureStateNotifier::CaptureStateNotifier(bool initialActive) { mActive = initialActive; } CaptureStateNotifier::CaptureStateNotifier(bool initialActive) : mDeathRecipient(new DeathRecipient(this)), mActive( initialActive) {} CaptureStateNotifier::~CaptureStateNotifier() { LOG_ALWAYS_FATAL_IF(mListener != nullptr); Loading @@ -33,11 +33,20 @@ CaptureStateNotifier::~CaptureStateNotifier() { bool CaptureStateNotifier::RegisterListener(const sp<ICaptureStateListener>& listener) { std::lock_guard<std::mutex> _l(mMutex); LOG_ALWAYS_FATAL_IF(mListener != nullptr); LOG_ALWAYS_FATAL_IF(listener == nullptr); ALOGI("Registering a listener"); sp<IBinder> binder = IInterface::asBinder(listener); if (binder != nullptr) { status_t status = binder->linkToDeath(mDeathRecipient); if (status == NO_ERROR) { mListener = listener; sp<IBinder> binder = IInterface::asBinder(mListener); binder->linkToDeath(new DeathRecipient(this)); } else { ALOGE("Failed to register death listener: %u", status); } } else { ALOGE("Listener failed to cast to a binder."); } return mActive; } Loading services/audiopolicy/service/CaptureStateNotifier.h +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #pragma once #include <mutex> #include <binder/IBinder.h> #include <utils/StrongPointer.h> namespace android { Loading Loading @@ -63,6 +64,7 @@ public: private: std::mutex mMutex; sp<media::ICaptureStateListener> mListener; sp<IBinder::DeathRecipient> mDeathRecipient; bool mActive; class DeathRecipient; Loading Loading
services/audiopolicy/service/CaptureStateNotifier.cpp +17 −8 Original line number Diff line number Diff line #include "CaptureStateNotifier.h" #define LOG_TAG "CaptureStateNotifier" #include "CaptureStateNotifier.h" #include <android/media/ICaptureStateListener.h> #include <binder/IBinder.h> #include <utils/Log.h> Loading @@ -22,9 +22,9 @@ private: CaptureStateNotifier* const mNotifier; }; CaptureStateNotifier::CaptureStateNotifier(bool initialActive) { mActive = initialActive; } CaptureStateNotifier::CaptureStateNotifier(bool initialActive) : mDeathRecipient(new DeathRecipient(this)), mActive( initialActive) {} CaptureStateNotifier::~CaptureStateNotifier() { LOG_ALWAYS_FATAL_IF(mListener != nullptr); Loading @@ -33,11 +33,20 @@ CaptureStateNotifier::~CaptureStateNotifier() { bool CaptureStateNotifier::RegisterListener(const sp<ICaptureStateListener>& listener) { std::lock_guard<std::mutex> _l(mMutex); LOG_ALWAYS_FATAL_IF(mListener != nullptr); LOG_ALWAYS_FATAL_IF(listener == nullptr); ALOGI("Registering a listener"); sp<IBinder> binder = IInterface::asBinder(listener); if (binder != nullptr) { status_t status = binder->linkToDeath(mDeathRecipient); if (status == NO_ERROR) { mListener = listener; sp<IBinder> binder = IInterface::asBinder(mListener); binder->linkToDeath(new DeathRecipient(this)); } else { ALOGE("Failed to register death listener: %u", status); } } else { ALOGE("Listener failed to cast to a binder."); } return mActive; } Loading
services/audiopolicy/service/CaptureStateNotifier.h +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #pragma once #include <mutex> #include <binder/IBinder.h> #include <utils/StrongPointer.h> namespace android { Loading Loading @@ -63,6 +64,7 @@ public: private: std::mutex mMutex; sp<media::ICaptureStateListener> mListener; sp<IBinder::DeathRecipient> mDeathRecipient; bool mActive; class DeathRecipient; Loading