Loading include/media/nbaio/MonoPipe.h +13 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,17 @@ public: void setAvgFrames(size_t setpoint); size_t maxFrames() const { return mMaxFrames; } // Set the shutdown state for the write side of a pipe. // This may be called by an unrelated thread. When shutdown state is 'true', // a write that would otherwise block instead returns a short transfer count. // There is no guarantee how long it will take for the shutdown to be recognized, // but it will not be an unbounded amount of time. // The state can be restored to normal by calling shutdown(false). void shutdown(bool newState = true); // Return true if the write side of a pipe is currently shutdown. bool isShutdown(); private: // A pair of methods and a helper variable which allows the reader and the // writer to update and observe the values of mFront and mNextRdPTS in an Loading Loading @@ -114,6 +125,8 @@ private: int64_t offsetTimestampByAudioFrames(int64_t ts, size_t audFrames); LinearTransform mSamplesToLocalTime; bool mIsShutdown; // whether shutdown(true) was called, no barriers are needed }; } // namespace android Loading media/libnbaio/MonoPipe.cpp +13 −2 Original line number Diff line number Diff line Loading @@ -41,7 +41,8 @@ MonoPipe::MonoPipe(size_t reqFrames, NBAIO_Format format, bool writeCanBlock) : mWriteTsValid(false), // mWriteTs mSetpoint((reqFrames * 11) / 16), mWriteCanBlock(writeCanBlock) mWriteCanBlock(writeCanBlock), mIsShutdown(false) { CCHelper tmpHelper; status_t res; Loading Loading @@ -121,7 +122,7 @@ ssize_t MonoPipe::write(const void *buffer, size_t count) android_atomic_release_store(written + mRear, &mRear); totalFramesWritten += written; } if (!mWriteCanBlock) { if (!mWriteCanBlock || mIsShutdown) { break; } count -= written; Loading Loading @@ -299,4 +300,14 @@ int64_t MonoPipe::offsetTimestampByAudioFrames(int64_t ts, size_t audFrames) return ts + frame_lt_duration; } void MonoPipe::shutdown(bool newState) { mIsShutdown = newState; } bool MonoPipe::isShutdown() { return mIsShutdown; } } // namespace android Loading
include/media/nbaio/MonoPipe.h +13 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,17 @@ public: void setAvgFrames(size_t setpoint); size_t maxFrames() const { return mMaxFrames; } // Set the shutdown state for the write side of a pipe. // This may be called by an unrelated thread. When shutdown state is 'true', // a write that would otherwise block instead returns a short transfer count. // There is no guarantee how long it will take for the shutdown to be recognized, // but it will not be an unbounded amount of time. // The state can be restored to normal by calling shutdown(false). void shutdown(bool newState = true); // Return true if the write side of a pipe is currently shutdown. bool isShutdown(); private: // A pair of methods and a helper variable which allows the reader and the // writer to update and observe the values of mFront and mNextRdPTS in an Loading Loading @@ -114,6 +125,8 @@ private: int64_t offsetTimestampByAudioFrames(int64_t ts, size_t audFrames); LinearTransform mSamplesToLocalTime; bool mIsShutdown; // whether shutdown(true) was called, no barriers are needed }; } // namespace android Loading
media/libnbaio/MonoPipe.cpp +13 −2 Original line number Diff line number Diff line Loading @@ -41,7 +41,8 @@ MonoPipe::MonoPipe(size_t reqFrames, NBAIO_Format format, bool writeCanBlock) : mWriteTsValid(false), // mWriteTs mSetpoint((reqFrames * 11) / 16), mWriteCanBlock(writeCanBlock) mWriteCanBlock(writeCanBlock), mIsShutdown(false) { CCHelper tmpHelper; status_t res; Loading Loading @@ -121,7 +122,7 @@ ssize_t MonoPipe::write(const void *buffer, size_t count) android_atomic_release_store(written + mRear, &mRear); totalFramesWritten += written; } if (!mWriteCanBlock) { if (!mWriteCanBlock || mIsShutdown) { break; } count -= written; Loading Loading @@ -299,4 +300,14 @@ int64_t MonoPipe::offsetTimestampByAudioFrames(int64_t ts, size_t audFrames) return ts + frame_lt_duration; } void MonoPipe::shutdown(bool newState) { mIsShutdown = newState; } bool MonoPipe::isShutdown() { return mIsShutdown; } } // namespace android