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

Commit 6a9d20ee authored by Steven Moreland's avatar Steven Moreland Committed by Gerrit Code Review
Browse files

Merge "oboeservice: hold onto linked binder"

parents 58205951 37a6163f
Loading
Loading
Loading
Loading
+5 −5
Original line number Original line Diff line number Diff line
@@ -75,10 +75,10 @@ aaudio_result_t AAudioClientTracker::registerClient(pid_t pid,


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


        sp<IBinder> binder = IInterface::asBinder(client);
        status_t status = binder->linkToDeath(notificationClient);
        status_t status = binder->linkToDeath(notificationClient);
        ALOGW_IF(status != NO_ERROR, "registerClient() linkToDeath = %d\n", status);
        ALOGW_IF(status != NO_ERROR, "registerClient() linkToDeath = %d\n", status);
        return AAudioConvert_androidToAAudioResult(status);
        return AAudioConvert_androidToAAudioResult(status);
@@ -113,7 +113,7 @@ AAudioClientTracker::registerClientStream(pid_t pid, sp<AAudioServiceStreamBase>
    if (notificationClient == 0) {
    if (notificationClient == 0) {
        // This will get called the first time the audio server registers an internal stream.
        // This will get called the first time the audio server registers an internal stream.
        ALOGV("registerClientStream(%d,) unrecognized pid\n", pid);
        ALOGV("registerClientStream(%d,) unrecognized pid\n", pid);
        notificationClient = new NotificationClient(pid);
        notificationClient = new NotificationClient(pid, nullptr);
        mNotificationClients[pid] = notificationClient;
        mNotificationClients[pid] = notificationClient;
    }
    }
    notificationClient->registerClientStream(serviceStream);
    notificationClient->registerClientStream(serviceStream);
@@ -136,8 +136,8 @@ AAudioClientTracker::unregisterClientStream(pid_t pid,
    return AAUDIO_OK;
    return AAUDIO_OK;
}
}


AAudioClientTracker::NotificationClient::NotificationClient(pid_t pid)
AAudioClientTracker::NotificationClient::NotificationClient(pid_t pid, const sp<IBinder>& binder)
        : mProcessId(pid) {
        : mProcessId(pid), mBinder(binder) {
}
}


AAudioClientTracker::NotificationClient::~NotificationClient() {
AAudioClientTracker::NotificationClient::~NotificationClient() {
+3 −1
Original line number Original line Diff line number Diff line
@@ -73,7 +73,7 @@ private:
     */
     */
    class NotificationClient : public IBinder::DeathRecipient {
    class NotificationClient : public IBinder::DeathRecipient {
    public:
    public:
        NotificationClient(pid_t pid);
        NotificationClient(pid_t pid, const android::sp<IBinder>& binder);
        virtual ~NotificationClient();
        virtual ~NotificationClient();


        int32_t getStreamCount();
        int32_t getStreamCount();
@@ -91,6 +91,8 @@ private:
        mutable std::mutex                              mLock;
        mutable std::mutex                              mLock;
        const pid_t                                     mProcessId;
        const pid_t                                     mProcessId;
        std::set<android::sp<AAudioServiceStreamBase>>  mStreams;
        std::set<android::sp<AAudioServiceStreamBase>>  mStreams;
        // hold onto binder to receive death notifications
        android::sp<IBinder>                            mBinder;
    };
    };


    mutable std::mutex                               mLock;
    mutable std::mutex                               mLock;