Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7edbacf2 authored by James Dong's avatar James Dong Committed by Android (Google) Code Review
Browse files

Merge "Handle malformed raw AAC/AMR writer better" into jb-mr1-dev

parents 603b12ef fa514f00
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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);
+6 −3
Original line number Diff line number Diff line
@@ -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);