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

Commit fe346c70 authored by Glenn Kasten's avatar Glenn Kasten
Browse files

Fix miscellanous AudioTrack::getTimestamp() bugs

Check that get_presentation_position is non-NULL before calling.

AudioTrack::getTimestamp not implemented for fast tracks.

Fix typo in Track::getTimestamp().

Fix bugs in AudioTrack::getTimestamp after stop:
 - getTimestamp while stopped is not allowed.
 - stop, start, getTimestamp now returns the correct value.

Change-Id: Ie8d9dc1f28d8927634e04175a68b147ffc2ea8eb
parent 4d0815d6
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -1714,7 +1714,18 @@ status_t AudioTrack::setParameters(const String8& keyValuePairs)
status_t AudioTrack::getTimestamp(AudioTimestamp& timestamp)
{
    AutoMutex lock(mLock);
    return mAudioTrack->getTimestamp(timestamp);
    // FIXME not implemented for fast tracks; should use proxy and SSQ
    if (mFlags & AUDIO_OUTPUT_FLAG_FAST) {
        return INVALID_OPERATION;
    }
    if (mState != STATE_ACTIVE && mState != STATE_PAUSED) {
        return INVALID_OPERATION;
    }
    status_t status = mAudioTrack->getTimestamp(timestamp);
    if (status == NO_ERROR) {
        timestamp.mPosition += mProxy->getEpoch();
    }
    return status;
}

String8 AudioTrack::getParameters(const String8& keys)
+3 −0
Original line number Diff line number Diff line
@@ -81,6 +81,9 @@ status_t AudioStreamOutSink::getNextWriteTimestamp(int64_t *timestamp) {

status_t AudioStreamOutSink::getTimestamp(AudioTimestamp& timestamp)
{
    if (mStream->get_presentation_position == NULL) {
        return INVALID_OPERATION;
    }
    // FIXME position64 won't be needed after AudioTimestamp.mPosition is changed to uint64_t
    uint64_t position64;
    int ok = mStream->get_presentation_position(mStream, &position64, &timestamp.mTime);
+5 −1
Original line number Diff line number Diff line
@@ -727,9 +727,13 @@ status_t AudioFlinger::PlaybackThread::Track::setParameters(const String8& keyVa

status_t AudioFlinger::PlaybackThread::Track::getTimestamp(AudioTimestamp& timestamp)
{
    // Client should implement this using SSQ; the unpresented frame count in latch is irrelevant
    if (isFastTrack()) {
        return INVALID_OPERATION;
    }
    sp<ThreadBase> thread = mThread.promote();
    if (thread == 0) {
        return false;
        return INVALID_OPERATION;
    }
    Mutex::Autolock _l(thread->mLock);
    PlaybackThread *playbackThread = (PlaybackThread *)thread.get();