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

Commit 59fe010b authored by Eric Laurent's avatar Eric Laurent
Browse files

fix volume and effect enable delay on offloaded tracks

Volume: add a method to wake up the mediaserver playback
thread when a volume command is received on an offloaded track.

Effects: call effect chain process on offloaded playback threads
asynchronously from writes to allow effect state updates while
waiting for async write callback.

Bug: 10796540.

Change-Id: Id2747ae88783575d1d7ffd6fc86fbd054ab2c739
parent 5d6d86a4
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -90,6 +90,9 @@ public:

    /* Return NO_ERROR if timestamp is valid */
    virtual status_t    getTimestamp(AudioTimestamp& timestamp) = 0;

    /* Signal the playback thread for a change in control block */
    virtual void        signal() = 0;
};

// ----------------------------------------------------------------------------
+3 −0
Original line number Diff line number Diff line
@@ -534,6 +534,9 @@ status_t AudioTrack::setVolume(float left, float right)

    mProxy->setVolumeLR((uint32_t(uint16_t(right * 0x1000)) << 16) | uint16_t(left * 0x1000));

    if (isOffloaded()) {
        mAudioTrack->signal();
    }
    return NO_ERROR;
}

+12 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ enum {
    SET_MEDIA_TIME_TRANSFORM,
    SET_PARAMETERS,
    GET_TIMESTAMP,
    SIGNAL,
};

class BpAudioTrack : public BpInterface<IAudioTrack>
@@ -182,6 +183,12 @@ public:
        }
        return status;
    }

    virtual void signal() {
        Parcel data, reply;
        data.writeInterfaceToken(IAudioTrack::getInterfaceDescriptor());
        remote()->transact(SIGNAL, data, &reply);
    }
};

IMPLEMENT_META_INTERFACE(AudioTrack, "android.media.IAudioTrack");
@@ -269,6 +276,11 @@ status_t BnAudioTrack::onTransact(
            }
            return NO_ERROR;
        } break;
        case SIGNAL: {
            CHECK_INTERFACE(IAudioTrack, data, reply);
            signal();
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
+1 −0
Original line number Diff line number Diff line
@@ -412,6 +412,7 @@ private:
                                                  int target);
        virtual status_t    setParameters(const String8& keyValuePairs);
        virtual status_t    getTimestamp(AudioTimestamp& timestamp);
        virtual void        signal(); // signal playback thread for a change in control block

        virtual status_t onTransact(
            uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags);
+17 −5
Original line number Diff line number Diff line
@@ -972,8 +972,14 @@ status_t AudioFlinger::EffectHandle::enable()
        }
        mEnabled = false;
    } else {
        if (thread != 0 && !mEffect->isOffloadable()) {
            if ((thread->type() == ThreadBase::OFFLOAD)) {
        if (thread != 0) {
            if (thread->type() == ThreadBase::OFFLOAD) {
                PlaybackThread *t = (PlaybackThread *)thread.get();
                Mutex::Autolock _l(t->mLock);
                t->broadcast_l();
            }
            if (!mEffect->isOffloadable()) {
                if (thread->type() == ThreadBase::OFFLOAD) {
                    PlaybackThread *t = (PlaybackThread *)thread.get();
                    t->invalidateTracks(AUDIO_STREAM_MUSIC);
                }
@@ -982,6 +988,7 @@ status_t AudioFlinger::EffectHandle::enable()
                }
            }
        }
    }
    return status;
}

@@ -1009,6 +1016,11 @@ status_t AudioFlinger::EffectHandle::disable()
    sp<ThreadBase> thread = mEffect->thread().promote();
    if (thread != 0) {
        thread->checkSuspendOnEffectEnabled(mEffect, false, mEffect->sessionId());
        if (thread->type() == ThreadBase::OFFLOAD) {
            PlaybackThread *t = (PlaybackThread *)thread.get();
            Mutex::Autolock _l(t->mLock);
            t->broadcast_l();
        }
    }

    return status;
Loading