Loading include/private/media/AudioTrackShared.h +6 −2 Original line number Diff line number Diff line Loading @@ -555,6 +555,9 @@ public: // Total count of the number of flushed frames since creation (never reset). virtual int64_t framesFlushed() const { return mFlushed; } // Safe frames ready query with no side effects. virtual size_t framesReadySafe() const = 0; // Get dynamic buffer size from the shared control block. uint32_t getBufferSizeInFrames() const { return android_atomic_acquire_load((int32_t *)&mCblk->mBufferSizeInFrames); Loading Loading @@ -592,8 +595,7 @@ public: // which may include non-contiguous frames virtual size_t framesReady(); // Safe frames ready query used by dump() - this has no side effects. virtual size_t framesReadySafe() const; size_t framesReadySafe() const override; // frames available to read by server. // Currently AudioFlinger will call framesReady() for a fast track from two threads: // FastMixer thread, and normal mixer thread. This is dangerous, as the proxy is intended Loading Loading @@ -697,6 +699,8 @@ public: return mCblk->u.mStreaming.mRear; // For completeness only; mRear written by server. } size_t framesReadySafe() const override; // frames available to read by client. protected: virtual ~AudioRecordServerProxy() { } }; Loading media/libaudioclient/AudioTrackShared.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -1231,6 +1231,21 @@ int32_t StaticAudioTrackServerProxy::getRear() const return 0; } __attribute__((no_sanitize("integer"))) size_t AudioRecordServerProxy::framesReadySafe() const { if (mIsShutdown) { return 0; } const int32_t front = android_atomic_acquire_load(&mCblk->u.mStreaming.mFront); const int32_t rear = mCblk->u.mStreaming.mRear; const ssize_t filled = rear - front; if (!(0 <= filled && (size_t) filled <= mFrameCount)) { return 0; // error condition, silently return 0. } return filled; } // --------------------------------------------------------------------------- } // namespace android Loading
include/private/media/AudioTrackShared.h +6 −2 Original line number Diff line number Diff line Loading @@ -555,6 +555,9 @@ public: // Total count of the number of flushed frames since creation (never reset). virtual int64_t framesFlushed() const { return mFlushed; } // Safe frames ready query with no side effects. virtual size_t framesReadySafe() const = 0; // Get dynamic buffer size from the shared control block. uint32_t getBufferSizeInFrames() const { return android_atomic_acquire_load((int32_t *)&mCblk->mBufferSizeInFrames); Loading Loading @@ -592,8 +595,7 @@ public: // which may include non-contiguous frames virtual size_t framesReady(); // Safe frames ready query used by dump() - this has no side effects. virtual size_t framesReadySafe() const; size_t framesReadySafe() const override; // frames available to read by server. // Currently AudioFlinger will call framesReady() for a fast track from two threads: // FastMixer thread, and normal mixer thread. This is dangerous, as the proxy is intended Loading Loading @@ -697,6 +699,8 @@ public: return mCblk->u.mStreaming.mRear; // For completeness only; mRear written by server. } size_t framesReadySafe() const override; // frames available to read by client. protected: virtual ~AudioRecordServerProxy() { } }; Loading
media/libaudioclient/AudioTrackShared.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -1231,6 +1231,21 @@ int32_t StaticAudioTrackServerProxy::getRear() const return 0; } __attribute__((no_sanitize("integer"))) size_t AudioRecordServerProxy::framesReadySafe() const { if (mIsShutdown) { return 0; } const int32_t front = android_atomic_acquire_load(&mCblk->u.mStreaming.mFront); const int32_t rear = mCblk->u.mStreaming.mRear; const ssize_t filled = rear - front; if (!(0 <= filled && (size_t) filled <= mFrameCount)) { return 0; // error condition, silently return 0. } return filled; } // --------------------------------------------------------------------------- } // namespace android