diff options
| author | James Dong <jdong@google.com> | 2010-07-30 17:41:22 -0700 |
|---|---|---|
| committer | James Dong <jdong@google.com> | 2010-08-02 18:08:02 -0700 |
| commit | da8073c68e63179e1d4f5fb562e5625af686c984 (patch) | |
| tree | 1698b33512a3246334d2aa7f4eb11cc16768cff0 /include | |
| parent | d3579580df0cea7e37334d83ef7a9aa85ad70368 (diff) | |
| download | frameworks_base-da8073c68e63179e1d4f5fb562e5625af686c984.zip frameworks_base-da8073c68e63179e1d4f5fb562e5625af686c984.tar.gz frameworks_base-da8073c68e63179e1d4f5fb562e5625af686c984.tar.bz2 | |
File writer has a designated writer thread now
+ This reduces the file I/O block time for audio/video track processing
- Since the file writer is buffering some output samples, the memory
usage would go up, depending on how many output samples are buffered.
Change-Id: I780cc5b26f4b53a5efbd643fcf9505dfc19cd4cd
Diffstat (limited to 'include')
| -rw-r--r-- | include/media/stagefright/MPEG4Writer.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/include/media/stagefright/MPEG4Writer.h b/include/media/stagefright/MPEG4Writer.h index d0c2dca..2e1e8d8 100644 --- a/include/media/stagefright/MPEG4Writer.h +++ b/include/media/stagefright/MPEG4Writer.h @@ -75,6 +75,7 @@ private: uint32_t mInterleaveDurationUs; int32_t mTimeScale; int64_t mStartTimestampUs; + Mutex mLock; List<Track *> mTracks; @@ -87,6 +88,46 @@ private: size_t numTracks(); int64_t estimateMoovBoxSize(int32_t bitRate); + struct Chunk { + Track *mTrack; // Owner + int64_t mTimeStampUs; // Timestamp of the 1st sample + List<MediaBuffer *> mSamples; // Sample data + + // Convenient constructor + Chunk(Track *track, int64_t timeUs, List<MediaBuffer *> samples) + : mTrack(track), mTimeStampUs(timeUs), mSamples(samples) { + } + + }; + struct ChunkInfo { + Track *mTrack; // Owner + List<Chunk> mChunks; // Remaining chunks to be written + }; + + bool mIsFirstChunk; + volatile bool mDone; // Writer thread is done? + pthread_t mThread; // Thread id for the writer + List<ChunkInfo> mChunkInfos; // Chunk infos + Condition mChunkReadyCondition; // Signal that chunks are available + + // Writer thread handling + status_t startWriterThread(); + void stopWriterThread(); + static void *ThreadWrapper(void *me); + void threadFunc(); + + // Buffer a single chunk to be written out later. + void bufferChunk(const Chunk& chunk); + + // Write all buffered chunks from all tracks + void writeChunks(); + + // Write a chunk if there is one + status_t writeOneChunk(); + + // Write the first chunk from the given ChunkInfo. + void writeFirstChunk(ChunkInfo* info); + void lock(); void unlock(); |
