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

Commit efc130c6 authored by Dorin Drimus's avatar Dorin Drimus
Browse files

Propagate setPreferredDevice to ClientDescriptor when AudioTrack is not playing

Bug: 316028989
Change-Id: Ia66bb8f9d3b16dbf94ddc83d92fbb53aca2d0b1f
Test: atest RoutingTest
parent 42e9c451
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -1704,10 +1704,14 @@ status_t AudioTrack::setOutputDevice(audio_port_handle_t deviceId) {
            __func__, mPortId, deviceId, mSelectedDeviceId, mRoutedDeviceId);
    if (mSelectedDeviceId != deviceId) {
        mSelectedDeviceId = deviceId;
        if (mStatus == NO_ERROR && mSelectedDeviceId != mRoutedDeviceId) {
        if (mStatus == NO_ERROR) {
            // allow track invalidation when track is not playing to propagate
            // the updated mSelectedDeviceId
            if (isPlaying_l()) {
                if (mSelectedDeviceId != mRoutedDeviceId) {
                    android_atomic_or(CBLK_INVALID, &mCblk->mFlags);
                    mProxy->interrupt();
                }
            } else {
                // if the track is idle, try to restore now and
                // defer to next start if not possible