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

Commit 5d53b6f2 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "aaudio: initialize the callback buffer" into rvc-dev am: 398fe58c am:...

Merge "aaudio: initialize the callback buffer" into rvc-dev am: 398fe58c am: bde84110 am: 25741601

Change-Id: Iaf2fe0cc59f0d00688ffc38a77c7d6615a9253e5
parents 565c2723 25741601
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -230,7 +230,7 @@ aaudio_result_t AudioStreamInternal::open(const AudioStreamBuilder &builder) {
        }
        }


        const int32_t callbackBufferSize = mCallbackFrames * getBytesPerFrame();
        const int32_t callbackBufferSize = mCallbackFrames * getBytesPerFrame();
        mCallbackBuffer = new uint8_t[callbackBufferSize];
        mCallbackBuffer = std::make_unique<uint8_t[]>(callbackBufferSize);
    }
    }


    // For debugging and analyzing the distribution of MMAP timestamps.
    // For debugging and analyzing the distribution of MMAP timestamps.
@@ -279,8 +279,7 @@ aaudio_result_t AudioStreamInternal::release_l() {
        mServiceStreamHandle = AAUDIO_HANDLE_INVALID;
        mServiceStreamHandle = AAUDIO_HANDLE_INVALID;


        mServiceInterface.closeStream(serviceStreamHandle);
        mServiceInterface.closeStream(serviceStreamHandle);
        delete[] mCallbackBuffer;
        mCallbackBuffer.reset();
        mCallbackBuffer = nullptr;
        result = mEndPointParcelable.close();
        result = mEndPointParcelable.close();
        aaudio_result_t result2 = AudioStream::release_l();
        aaudio_result_t result2 = AudioStream::release_l();
        return (result != AAUDIO_OK) ? result : result2;
        return (result != AAUDIO_OK) ? result : result2;
+1 −1
Original line number Original line Diff line number Diff line
@@ -164,7 +164,7 @@ protected:
    // Offset from underlying frame position.
    // Offset from underlying frame position.
    int64_t                  mFramesOffsetFromService = 0; // offset for timestamps
    int64_t                  mFramesOffsetFromService = 0; // offset for timestamps


    uint8_t                 *mCallbackBuffer = nullptr;
    std::unique_ptr<uint8_t[]> mCallbackBuffer;
    int32_t                  mCallbackFrames = 0;
    int32_t                  mCallbackFrames = 0;


    // The service uses this for SHARED mode.
    // The service uses this for SHARED mode.
+2 −2
Original line number Original line Diff line number Diff line
@@ -243,7 +243,7 @@ void *AudioStreamInternalCapture::callbackLoop() {
        int64_t timeoutNanos = calculateReasonableTimeout(mCallbackFrames);
        int64_t timeoutNanos = calculateReasonableTimeout(mCallbackFrames);


        // This is a BLOCKING READ!
        // This is a BLOCKING READ!
        result = read(mCallbackBuffer, mCallbackFrames, timeoutNanos);
        result = read(mCallbackBuffer.get(), mCallbackFrames, timeoutNanos);
        if ((result != mCallbackFrames)) {
        if ((result != mCallbackFrames)) {
            ALOGE("callbackLoop: read() returned %d", result);
            ALOGE("callbackLoop: read() returned %d", result);
            if (result >= 0) {
            if (result >= 0) {
@@ -255,7 +255,7 @@ void *AudioStreamInternalCapture::callbackLoop() {
        }
        }


        // Call application using the AAudio callback interface.
        // Call application using the AAudio callback interface.
        callbackResult = maybeCallDataCallback(mCallbackBuffer, mCallbackFrames);
        callbackResult = maybeCallDataCallback(mCallbackBuffer.get(), mCallbackFrames);


        if (callbackResult == AAUDIO_CALLBACK_RESULT_STOP) {
        if (callbackResult == AAUDIO_CALLBACK_RESULT_STOP) {
            ALOGD("%s(): callback returned AAUDIO_CALLBACK_RESULT_STOP", __func__);
            ALOGD("%s(): callback returned AAUDIO_CALLBACK_RESULT_STOP", __func__);
+2 −2
Original line number Original line Diff line number Diff line
@@ -268,11 +268,11 @@ void *AudioStreamInternalPlay::callbackLoop() {
    // result might be a frame count
    // result might be a frame count
    while (mCallbackEnabled.load() && isActive() && (result >= 0)) {
    while (mCallbackEnabled.load() && isActive() && (result >= 0)) {
        // Call application using the AAudio callback interface.
        // Call application using the AAudio callback interface.
        callbackResult = maybeCallDataCallback(mCallbackBuffer, mCallbackFrames);
        callbackResult = maybeCallDataCallback(mCallbackBuffer.get(), mCallbackFrames);


        if (callbackResult == AAUDIO_CALLBACK_RESULT_CONTINUE) {
        if (callbackResult == AAUDIO_CALLBACK_RESULT_CONTINUE) {
            // Write audio data to stream. This is a BLOCKING WRITE!
            // Write audio data to stream. This is a BLOCKING WRITE!
            result = write(mCallbackBuffer, mCallbackFrames, timeoutNanos);
            result = write(mCallbackBuffer.get(), mCallbackFrames, timeoutNanos);
            if ((result != mCallbackFrames)) {
            if ((result != mCallbackFrames)) {
                if (result >= 0) {
                if (result >= 0) {
                    // Only wrote some of the frames requested. Must have timed out.
                    // Only wrote some of the frames requested. Must have timed out.