Loading include/media/nbaio/Pipe.h +6 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,11 @@ class Pipe : public NBAIO_Sink { public: // maxFrames will be rounded up to a power of 2, and all slots are available. Must be >= 2. Pipe(size_t maxFrames, const NBAIO_Format& format); // buffer is an optional parameter specifying the virtual address of the pipe buffer, // which must be of size roundup(maxFrames) * Format_frameSize(format) bytes. Pipe(size_t maxFrames, const NBAIO_Format& format, void *buffer = NULL); // If a buffer was specified in the constructor, it is not automatically freed by destructor. virtual ~Pipe(); // NBAIO_Port interface Loading @@ -57,6 +61,7 @@ private: void * const mBuffer; volatile int32_t mRear; // written by android_atomic_release_store volatile int32_t mReaders; // number of PipeReader clients currently attached to this Pipe const bool mFreeBufferInDestructor; }; } // namespace android Loading media/libnbaio/Pipe.cpp +7 −4 Original line number Diff line number Diff line Loading @@ -25,20 +25,23 @@ namespace android { Pipe::Pipe(size_t maxFrames, const NBAIO_Format& format) : Pipe::Pipe(size_t maxFrames, const NBAIO_Format& format, void *buffer) : NBAIO_Sink(format), mMaxFrames(roundup(maxFrames)), mBuffer(malloc(mMaxFrames * Format_frameSize(format))), mBuffer(buffer == NULL ? malloc(mMaxFrames * Format_frameSize(format)) : buffer), mRear(0), mReaders(0) mReaders(0), mFreeBufferInDestructor(buffer == NULL) { } Pipe::~Pipe() { ALOG_ASSERT(android_atomic_acquire_load(&mReaders) == 0); if (mFreeBufferInDestructor) { free(mBuffer); } } ssize_t Pipe::write(const void *buffer, size_t count) { Loading Loading
include/media/nbaio/Pipe.h +6 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,11 @@ class Pipe : public NBAIO_Sink { public: // maxFrames will be rounded up to a power of 2, and all slots are available. Must be >= 2. Pipe(size_t maxFrames, const NBAIO_Format& format); // buffer is an optional parameter specifying the virtual address of the pipe buffer, // which must be of size roundup(maxFrames) * Format_frameSize(format) bytes. Pipe(size_t maxFrames, const NBAIO_Format& format, void *buffer = NULL); // If a buffer was specified in the constructor, it is not automatically freed by destructor. virtual ~Pipe(); // NBAIO_Port interface Loading @@ -57,6 +61,7 @@ private: void * const mBuffer; volatile int32_t mRear; // written by android_atomic_release_store volatile int32_t mReaders; // number of PipeReader clients currently attached to this Pipe const bool mFreeBufferInDestructor; }; } // namespace android Loading
media/libnbaio/Pipe.cpp +7 −4 Original line number Diff line number Diff line Loading @@ -25,20 +25,23 @@ namespace android { Pipe::Pipe(size_t maxFrames, const NBAIO_Format& format) : Pipe::Pipe(size_t maxFrames, const NBAIO_Format& format, void *buffer) : NBAIO_Sink(format), mMaxFrames(roundup(maxFrames)), mBuffer(malloc(mMaxFrames * Format_frameSize(format))), mBuffer(buffer == NULL ? malloc(mMaxFrames * Format_frameSize(format)) : buffer), mRear(0), mReaders(0) mReaders(0), mFreeBufferInDestructor(buffer == NULL) { } Pipe::~Pipe() { ALOG_ASSERT(android_atomic_acquire_load(&mReaders) == 0); if (mFreeBufferInDestructor) { free(mBuffer); } } ssize_t Pipe::write(const void *buffer, size_t count) { Loading