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

Commit 57bd6342 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "AAudio: fix NotificationClient linkToDeath error" into main

parents 72a4c786 869eb4f1
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -74,16 +74,28 @@ aaudio_result_t AAudioClientTracker::registerClient(pid_t pid,
    }

    const std::lock_guard<std::mutex> lock(mLock);
    sp<NotificationClient> notificationClient;
    status_t status;
    sp<IBinder> binder = IInterface::asBinder(client);
    if (mNotificationClients.count(pid) == 0) {
        const sp<IBinder> binder = IInterface::asBinder(client);
        const sp<NotificationClient> notificationClient = new NotificationClient(pid, binder);
        notificationClient = new NotificationClient(pid, binder);
        mNotificationClients[pid] = notificationClient;

        const status_t status = binder->linkToDeath(notificationClient);
        status = binder->linkToDeath(notificationClient);
        ALOGW_IF(status != NO_ERROR, "registerClient() linkToDeath = %d\n", status);
        return AAudioConvert_androidToAAudioResult(status);
    } else {
        ALOGW("registerClient(%d) already registered!", pid);
        notificationClient = mNotificationClients[pid];
        if (notificationClient-> isBinderNull()) {
            ALOGW("registerClient() need to linkToDeath as notificationClient binder is null");
            status = binder->linkToDeath(notificationClient);
            if (status != NO_ERROR) {
                ALOGE("registerClient() linkToDeath status = %d\n", status);
            } else {
                notificationClient->setBinder(binder);
            }
        }
        return AAUDIO_OK; // TODO should this be considered an error
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -104,6 +104,14 @@ private:
            return mExclusiveEnabled;
        }

        bool isBinderNull() {
            return mBinder == nullptr;
        }

        void setBinder(android::sp<IBinder>& binder) {
            mBinder = binder;
        }

        // IBinder::DeathRecipient
        void binderDied(const android::wp<IBinder>& who) override;