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

Commit 265fb623 authored by Phil Burk's avatar Phil Burk
Browse files

aaudio: do error callback if thread registration fails

This can prevent a silent disconnect caused by a disconnect
happening right when the stream is started.

These mods were suggested by MediaTek.

Bug: 357011642
Test: atest AAudioTests
Test: OboeTester TEST DISCONNECT
Flag: EXEMPT bugfix
Change-Id: I754ad7d046fa932ed928ef54df8f9dfaa7b753c0
parent 610b1ac4
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -480,6 +480,10 @@ void* AudioStream::wrapUserThread() {
        // Run callback loop. This may take a very long time.
        procResult = mThreadProc(mThreadArg);
        mThreadRegistrationResult = unregisterThread();
    } else {
        // If we cannot register the thread then it has probably become disconnected.
        // The only way to inform the app from this thread is with an error callback.
        maybeCallErrorCallback(AAUDIO_ERROR_DISCONNECTED);
    }
    return procResult;
}
+3 −0
Original line number Diff line number Diff line
@@ -10423,8 +10423,11 @@ void MmapThread::disconnect()
            activeTracks.add(t);
        }
        localPortId = mPortId;
        ALOGD("%s: localPortId = %d", __func__, localPortId);
        mPortId = AUDIO_PORT_HANDLE_NONE;
    }
    for (const sp<IAfMmapTrack>& t : activeTracks) {
        ALOGD("%s: t->portId() = %d", __func__, t->portId());
        stop(t->portId());
    }
    // This will decrement references and may cause the destruction of this thread.