diff options
author | Eric Laurent <elaurent@google.com> | 2013-10-16 15:12:32 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2013-10-16 15:12:32 -0700 |
commit | cc21e4f1e41dfa17e7e2bef995fcd22c45f6bcd0 (patch) | |
tree | a446f08a1adaf31ef5dddc491c620209176b67aa /media/libmedia/AudioTrackShared.cpp | |
parent | 014e7fa2e90827d911c37bb0ce4d2e10e14d0bb3 (diff) | |
download | frameworks_av-cc21e4f1e41dfa17e7e2bef995fcd22c45f6bcd0.zip frameworks_av-cc21e4f1e41dfa17e7e2bef995fcd22c45f6bcd0.tar.gz frameworks_av-cc21e4f1e41dfa17e7e2bef995fcd22c45f6bcd0.tar.bz2 |
AudioTrack: fix head position after restore
The head position transfered to the new track
by restoreTrack_l() must take into account the frames that
are dropped from the old track to avoid a non recoverable
offset in the playback head position returned to applications.
Bug: 11230062.
Change-Id: I51143a08b95e8f264ed709ae2054360315f2b8b1
Diffstat (limited to 'media/libmedia/AudioTrackShared.cpp')
-rw-r--r-- | media/libmedia/AudioTrackShared.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/media/libmedia/AudioTrackShared.cpp b/media/libmedia/AudioTrackShared.cpp index 4fd92b2..da73d65 100644 --- a/media/libmedia/AudioTrackShared.cpp +++ b/media/libmedia/AudioTrackShared.cpp @@ -316,6 +316,27 @@ size_t ClientProxy::getMisalignment() (mFrameCountP2 - 1); } +size_t ClientProxy::getFramesFilled() { + audio_track_cblk_t* cblk = mCblk; + int32_t front; + int32_t rear; + + if (mIsOut) { + front = android_atomic_acquire_load(&cblk->u.mStreaming.mFront); + rear = cblk->u.mStreaming.mRear; + } else { + rear = android_atomic_acquire_load(&cblk->u.mStreaming.mRear); + front = cblk->u.mStreaming.mFront; + } + ssize_t filled = rear - front; + // pipe should not be overfull + if (!(0 <= filled && (size_t) filled <= mFrameCount)) { + ALOGE("Shared memory control block is corrupt (filled=%d); shutting down", filled); + return 0; + } + return (size_t)filled; +} + // --------------------------------------------------------------------------- void AudioTrackClientProxy::flush() |