diff options
| author | James Dong <jdong@google.com> | 2012-08-10 10:25:51 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-08-10 10:25:51 -0700 |
| commit | 7edbacf24e60c01e2d3b10715ec8f9cc2f55c11a (patch) | |
| tree | e8b2d0ecda3008ecb890f8cbb7e4be9e054fff9b | |
| parent | 603b12efa16e7afb4e6c75f6b353216c83e8e135 (diff) | |
| parent | fa514f007bd144eb99cdd68f2fe5302a4508db28 (diff) | |
| download | frameworks_av-7edbacf24e60c01e2d3b10715ec8f9cc2f55c11a.zip frameworks_av-7edbacf24e60c01e2d3b10715ec8f9cc2f55c11a.tar.gz frameworks_av-7edbacf24e60c01e2d3b10715ec8f9cc2f55c11a.tar.bz2 | |
Merge "Handle malformed raw AAC/AMR writer better" into jb-mr1-dev
| -rw-r--r-- | media/libstagefright/AACWriter.cpp | 13 | ||||
| -rw-r--r-- | media/libstagefright/AMRWriter.cpp | 9 |
2 files changed, 19 insertions, 3 deletions
diff --git a/media/libstagefright/AACWriter.cpp b/media/libstagefright/AACWriter.cpp index 33b7bd5..a6f7cfb 100644 --- a/media/libstagefright/AACWriter.cpp +++ b/media/libstagefright/AACWriter.cpp @@ -304,6 +304,7 @@ status_t AACWriter::threadFunc() { int64_t previousPausedDurationUs = 0; int64_t maxTimestampUs = 0; status_t err = OK; + bool stoppedPrematurely = true; prctl(PR_SET_NAME, (unsigned long)"AACWriterThread", 0, 0, 0); @@ -372,6 +373,18 @@ status_t AACWriter::threadFunc() { buffer->release(); buffer = NULL; + + if (err != OK) { + break; + } + + if (stoppedPrematurely) { + stoppedPrematurely = false; + } + } + + if ((err == OK || err == ERROR_END_OF_STREAM) && stoppedPrematurely) { + err = ERROR_MALFORMED; } close(mFd); diff --git a/media/libstagefright/AMRWriter.cpp b/media/libstagefright/AMRWriter.cpp index 15a7143..8d5eec8 100644 --- a/media/libstagefright/AMRWriter.cpp +++ b/media/libstagefright/AMRWriter.cpp @@ -254,11 +254,14 @@ status_t AMRWriter::threadFunc() { if (n < (ssize_t)buffer->range_length()) { buffer->release(); buffer = NULL; + err = ERROR_IO; + break; + } + if (err != OK) { break; } - // XXX: How to tell it is stopped prematurely? if (stoppedPrematurely) { stoppedPrematurely = false; } @@ -267,8 +270,8 @@ status_t AMRWriter::threadFunc() { buffer = NULL; } - if (stoppedPrematurely) { - notify(MEDIA_RECORDER_EVENT_INFO, MEDIA_RECORDER_TRACK_INFO_COMPLETION_STATUS, UNKNOWN_ERROR); + if ((err == OK || err == ERROR_END_OF_STREAM) && stoppedPrematurely) { + err = ERROR_MALFORMED; } close(mFd); |
