diff options
author | Glenn Kasten <gkasten@google.com> | 2014-03-07 02:30:11 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-03-07 02:30:11 +0000 |
commit | b8d0b780c9ae160b830cc7a31b22600293e4978b (patch) | |
tree | 9ea56a5014c7ac2a029cb7668319bd837b837f4c /media/libmedia | |
parent | 328ab3c21c185a7541e7ee087a61e18f6888af1c (diff) | |
parent | af191eb4feac513d17dc0362e0cea5bc9e0ffe9d (diff) | |
download | frameworks_av-b8d0b780c9ae160b830cc7a31b22600293e4978b.zip frameworks_av-b8d0b780c9ae160b830cc7a31b22600293e4978b.tar.gz frameworks_av-b8d0b780c9ae160b830cc7a31b22600293e4978b.tar.bz2 |
am af191eb4: Merge "Replace size_t in shared memory by uint32_t"
* commit 'af191eb4feac513d17dc0362e0cea5bc9e0ffe9d':
Replace size_t in shared memory by uint32_t
Diffstat (limited to 'media/libmedia')
-rw-r--r-- | media/libmedia/AudioTrackShared.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/media/libmedia/AudioTrackShared.cpp b/media/libmedia/AudioTrackShared.cpp index caa7900..e898109 100644 --- a/media/libmedia/AudioTrackShared.cpp +++ b/media/libmedia/AudioTrackShared.cpp @@ -475,9 +475,14 @@ void StaticAudioTrackClientProxy::flush() void StaticAudioTrackClientProxy::setLoop(size_t loopStart, size_t loopEnd, int loopCount) { + // This can only happen on a 64-bit client + if (loopStart > UINT32_MAX || loopEnd > UINT32_MAX) { + // FIXME Should return an error status + return; + } StaticAudioTrackState newState; - newState.mLoopStart = loopStart; - newState.mLoopEnd = loopEnd; + newState.mLoopStart = (uint32_t) loopStart; + newState.mLoopEnd = (uint32_t) loopEnd; newState.mLoopCount = loopCount; mBufferPosition = loopStart; (void) mMutator.push(newState); @@ -487,7 +492,7 @@ size_t StaticAudioTrackClientProxy::getBufferPosition() { size_t bufferPosition; if (mMutator.ack()) { - bufferPosition = mCblk->u.mStatic.mBufferPosition; + bufferPosition = (size_t) mCblk->u.mStatic.mBufferPosition; if (bufferPosition > mFrameCount) { bufferPosition = mFrameCount; } @@ -622,7 +627,7 @@ void ServerProxy::releaseBuffer(Buffer* buffer) if (half == 0) { half = 1; } - size_t minimum = cblk->mMinimum; + size_t minimum = (size_t) cblk->mMinimum; if (minimum == 0) { minimum = mIsOut ? half : 1; } else if (minimum > half) { @@ -760,7 +765,8 @@ ssize_t StaticAudioTrackServerProxy::pollPosition() mIsShutdown = true; return (ssize_t) NO_INIT; } - mCblk->u.mStatic.mBufferPosition = position; + // This may overflow, but client is not supposed to rely on it + mCblk->u.mStatic.mBufferPosition = (uint32_t) position; } return (ssize_t) position; } @@ -836,7 +842,8 @@ void StaticAudioTrackServerProxy::releaseBuffer(Buffer* buffer) mPosition = newPosition; cblk->mServer += stepCount; - cblk->u.mStatic.mBufferPosition = newPosition; + // This may overflow, but client is not supposed to rely on it + cblk->u.mStatic.mBufferPosition = (uint32_t) newPosition; if (setFlags != 0) { (void) android_atomic_or(setFlags, &cblk->mFlags); // this would be a good place to wake a futex |