Loading include/private/media/AudioTrackShared.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -256,6 +256,8 @@ public: return mEpoch; return mEpoch; } } size_t getFramesFilled(); private: private: size_t mEpoch; size_t mEpoch; }; }; Loading media/libmedia/AudioTrack.cpp +3 −1 Original line number Original line Diff line number Diff line Loading @@ -1662,7 +1662,9 @@ status_t AudioTrack::restoreTrack_l(const char *from) // if the new IAudioTrack is created, createTrack_l() will modify the // if the new IAudioTrack is created, createTrack_l() will modify the // following member variables: mAudioTrack, mCblkMemory and mCblk. // following member variables: mAudioTrack, mCblkMemory and mCblk. // It will also delete the strong references on previous IAudioTrack and IMemory // It will also delete the strong references on previous IAudioTrack and IMemory size_t position = mProxy->getPosition(); // take the frames that will be lost by track recreation into account in saved position size_t position = mProxy->getPosition() + mProxy->getFramesFilled(); mNewPosition = position + mUpdatePeriod; mNewPosition = position + mUpdatePeriod; size_t bufferPosition = mStaticProxy != NULL ? mStaticProxy->getBufferPosition() : 0; size_t bufferPosition = mStaticProxy != NULL ? mStaticProxy->getBufferPosition() : 0; result = createTrack_l(mStreamType, result = createTrack_l(mStreamType, Loading media/libmedia/AudioTrackShared.cpp +21 −0 Original line number Original line Diff line number Diff line Loading @@ -316,6 +316,27 @@ size_t ClientProxy::getMisalignment() (mFrameCountP2 - 1); (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() void AudioTrackClientProxy::flush() Loading Loading
include/private/media/AudioTrackShared.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -256,6 +256,8 @@ public: return mEpoch; return mEpoch; } } size_t getFramesFilled(); private: private: size_t mEpoch; size_t mEpoch; }; }; Loading
media/libmedia/AudioTrack.cpp +3 −1 Original line number Original line Diff line number Diff line Loading @@ -1662,7 +1662,9 @@ status_t AudioTrack::restoreTrack_l(const char *from) // if the new IAudioTrack is created, createTrack_l() will modify the // if the new IAudioTrack is created, createTrack_l() will modify the // following member variables: mAudioTrack, mCblkMemory and mCblk. // following member variables: mAudioTrack, mCblkMemory and mCblk. // It will also delete the strong references on previous IAudioTrack and IMemory // It will also delete the strong references on previous IAudioTrack and IMemory size_t position = mProxy->getPosition(); // take the frames that will be lost by track recreation into account in saved position size_t position = mProxy->getPosition() + mProxy->getFramesFilled(); mNewPosition = position + mUpdatePeriod; mNewPosition = position + mUpdatePeriod; size_t bufferPosition = mStaticProxy != NULL ? mStaticProxy->getBufferPosition() : 0; size_t bufferPosition = mStaticProxy != NULL ? mStaticProxy->getBufferPosition() : 0; result = createTrack_l(mStreamType, result = createTrack_l(mStreamType, Loading
media/libmedia/AudioTrackShared.cpp +21 −0 Original line number Original line Diff line number Diff line Loading @@ -316,6 +316,27 @@ size_t ClientProxy::getMisalignment() (mFrameCountP2 - 1); (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() void AudioTrackClientProxy::flush() Loading