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

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

Merge "Use a separate thread to disconnect registered streams."

parents 72a4bcb4 6604ce9e
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -66,8 +66,7 @@ void *AAudioServiceEndpointCapture::callbackLoop() {
                getFramesPerBurst(), timeoutNanos);
        if (result == AAUDIO_ERROR_DISCONNECTED) {
            ALOGD("%s() read() returned AAUDIO_ERROR_DISCONNECTED", __func__);
            // We do not need the returned vector.
            (void) AAudioServiceEndpointShared::disconnectRegisteredStreams();
            AAudioServiceEndpointShared::handleDisconnectRegisteredStreamsAsync();
            break;
        } else if (result != getFramesPerBurst()) {
            ALOGW("callbackLoop() read %d / %d",
+1 −2
Original line number Diff line number Diff line
@@ -147,8 +147,7 @@ void *AAudioServiceEndpointPlay::callbackLoop() {
                                            getFramesPerBurst(), timeoutNanos);
        if (result == AAUDIO_ERROR_DISCONNECTED) {
            ALOGD("%s() write() returned AAUDIO_ERROR_DISCONNECTED", __func__);
            // We do not need the returned vector.
            (void) AAudioServiceEndpointShared::disconnectRegisteredStreams();
            AAudioServiceEndpointShared::handleDisconnectRegisteredStreamsAsync();
            break;
        } else if (result != getFramesPerBurst()) {
            ALOGW("callbackLoop() wrote %d / %d",
+9 −0
Original line number Diff line number Diff line
@@ -214,3 +214,12 @@ aaudio_result_t AAudioServiceEndpointShared::getTimestamp(int64_t *positionFrame
    }
    return result;
}

void AAudioServiceEndpointShared::handleDisconnectRegisteredStreamsAsync() {
    android::sp<AAudioServiceEndpointShared> holdEndpoint(this);
    std::thread asyncTask([holdEndpoint]() {
        // We do not need the returned vector.
        holdEndpoint->disconnectRegisteredStreams();
    });
    asyncTask.detach();
}
+2 −0
Original line number Diff line number Diff line
@@ -69,6 +69,8 @@ protected:

    aaudio_result_t          stopSharingThread();

    void                     handleDisconnectRegisteredStreamsAsync();

    // An MMAP stream that is shared by multiple clients.
    android::sp<AudioStreamInternal> mStreamInternal;