Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a75189ef authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix segfault in capture state registration"

parents 2d1d604b a46b6d3e
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -1641,16 +1641,17 @@ public:
    CaptureStateListenerImpl(
            const sp<IAudioPolicyService>& aps,
            const sp<AudioSystem::CaptureStateListener>& listener)
            : mAps(aps), mListener(listener) {
            : mAps(aps), mListener(listener) {}

    void init() {
        bool active;
        status_t status = aps->registerSoundTriggerCaptureStateListener(this, &active);
        status_t status = mAps->registerSoundTriggerCaptureStateListener(this, &active);
        if (status != NO_ERROR) {
            mListener->onServiceDied();
            return;
        }
        mListener->onStateChanged(active);
        sp<IBinder> binder = IInterface::asBinder(aps);
        binder->linkToDeath(this);
        IInterface::asBinder(mAps)->linkToDeath(this);
    }

    binder::Status setCaptureState(bool active) override {
@@ -1683,6 +1684,7 @@ status_t AudioSystem::registerSoundTriggerCaptureStateListener(

    Mutex::Autolock _l(gSoundTriggerCaptureStateListenerLock);
    gSoundTriggerCaptureStateListener = new CaptureStateListenerImpl(aps, listener);
    gSoundTriggerCaptureStateListener->init();

    return NO_ERROR;
}