From 96eb2b8a7b496fa7e3b68e68e2186354e6210d44 Mon Sep 17 00:00:00 2001 From: Paras Nagda Date: Wed, 24 Sep 2014 15:43:48 +0530 Subject: libstagefright: Fix MPEG4Writer crash when internal memory is almost full. - Camcoder recording crashes when internal memory is almost full. - crash happens if there is no space to write even first video frame. as soon as first video frame comes file limit exceeded information is given back to recorder and timestamp of video is not updated. since video timestamp is not proper crash is seen when comparing it with audio timestamp. - check is added while doing comparision of timestamps and reporting error in track stop() so recorded file is not saved to memory. Change-Id: I69e8bad62ab03ce01de5cbdb13f8ea841b787fcb --- media/libstagefright/MPEG4Writer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'media/libstagefright/MPEG4Writer.cpp') diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp index 47f114a..d4ac2e8 100644 --- a/media/libstagefright/MPEG4Writer.cpp +++ b/media/libstagefright/MPEG4Writer.cpp @@ -1881,6 +1881,10 @@ status_t MPEG4Writer::Track::stop() { status_t err = static_cast(reinterpret_cast(dummy)); ALOGD("%s track stopped", mIsAudio? "Audio": "Video"); + if (mOwner->exceedsFileSizeLimit() && mStszTableEntries->count() == 0) { + ALOGE(" Filesize limit exceeded and zero samples written "); + return ERROR_END_OF_STREAM; + } return err; } @@ -3086,7 +3090,7 @@ void MPEG4Writer::Track::writePaspBox() { int32_t MPEG4Writer::Track::getStartTimeOffsetScaledTime() const { int64_t trackStartTimeOffsetUs = 0; int64_t moovStartTimeUs = mOwner->getStartTimestampUs(); - if (mStartTimestampUs != moovStartTimeUs) { + if (mStartTimestampUs != moovStartTimeUs && mStszTableEntries->count() != 0) { CHECK_GT(mStartTimestampUs, moovStartTimeUs); trackStartTimeOffsetUs = mStartTimestampUs - moovStartTimeUs; } -- cgit v1.1