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

Commit c3530677 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6539570 from b296f9a6 to mainline-release

Change-Id: I3907ba2c5ad0c4d6b1071c5f5153e5cd2e62c69b
parents 3cc7fe17 b296f9a6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1686,6 +1686,9 @@ bool CCodecBufferChannel::handleWork(

    {
        Mutexed<Output>::Locked output(mOutput);
        if (!output->buffers) {
            return false;
        }
        output->buffers->pushToStash(
                buffer,
                notifyClient,
+9 −7
Original line number Diff line number Diff line
@@ -639,9 +639,17 @@ exit:

status_t AudioTrack::start()
{
    const int64_t beginNs = systemTime();
    AutoMutex lock(mLock);

    if (mState == STATE_ACTIVE) {
        return INVALID_OPERATION;
    }

    ALOGV("%s(%d): prior state:%s", __func__, mPortId, stateToString(mState));

    // Defer logging here due to OpenSL ES repeated start calls.
    // TODO(b/154868033) after fix, restore this logging back to the beginning of start().
    const int64_t beginNs = systemTime();
    status_t status = NO_ERROR; // logged: make sure to set this before returning.
    mediametrics::Defer defer([&] {
        mediametrics::LogItem(mMetricsId)
@@ -655,12 +663,6 @@ status_t AudioTrack::start()
            .set(AMEDIAMETRICS_PROP_STATUS, (int32_t)status)
            .record(); });

    ALOGV("%s(%d): prior state:%s", __func__, mPortId, stateToString(mState));

    if (mState == STATE_ACTIVE) {
        status = INVALID_OPERATION;
        return status;
    }

    mInUnderrun = true;

+3 −2
Original line number Diff line number Diff line
@@ -2401,8 +2401,8 @@ void MPEG4Writer::onMessageReceived(const sp<AMessage> &msg) {
            int32_t err;
            CHECK(msg->findInt32("errno", &err));
            // Stop tracks' threads and main writer thread.
            notify(MEDIA_RECORDER_EVENT_ERROR, MEDIA_RECORDER_ERROR_UNKNOWN, err);
            stop();
            notify(MEDIA_RECORDER_EVENT_ERROR, MEDIA_RECORDER_ERROR_UNKNOWN, err);
            break;
        }
        // fallocate() failed, hence notify app about it and stop().
@@ -2410,9 +2410,10 @@ void MPEG4Writer::onMessageReceived(const sp<AMessage> &msg) {
            ALOGE("kWhatFallocateError");
            int32_t err;
            CHECK(msg->findInt32("errno", &err));
            // Stop tracks' threads and main writer thread.
            stop();
            //TODO: introduce a suitable MEDIA_RECORDER_ERROR_* instead MEDIA_RECORDER_ERROR_UNKNOWN?
            notify(MEDIA_RECORDER_EVENT_ERROR, MEDIA_RECORDER_ERROR_UNKNOWN, err);
            stop();
            break;
        }
        default:
+4 −41
Original line number Diff line number Diff line
@@ -48,8 +48,7 @@ static bool isMp4Format(MediaMuxer::OutputFormat format) {

MediaMuxer::MediaMuxer(int fd, OutputFormat format)
    : mFormat(format),
      mState(UNINITIALIZED),
      mError(OK) {
      mState(UNINITIALIZED) {
    if (isMp4Format(format)) {
        mWriter = new MPEG4Writer(fd);
    } else if (format == OUTPUT_FORMAT_WEBM) {
@@ -59,7 +58,6 @@ MediaMuxer::MediaMuxer(int fd, OutputFormat format)
    }

    if (mWriter != NULL) {
        mWriter->setMuxerListener(this);
        mFileMeta = new MetaData;
        if (format == OUTPUT_FORMAT_HEIF) {
            // Note that the key uses recorder file types.
@@ -157,26 +155,16 @@ status_t MediaMuxer::start() {

status_t MediaMuxer::stop() {
    Mutex::Autolock autoLock(mMuxerLock);
    if (mState == STARTED || mState == ERROR) {
    if (mState == STARTED) {
        mState = STOPPED;
        for (size_t i = 0; i < mTrackList.size(); i++) {
            if (mTrackList[i]->stop() != OK) {
                return INVALID_OPERATION;
            }
        }
        // Unlock this mutex to allow notify to be called during stop process.
        mMuxerLock.unlock();
        status_t err = mWriter->stop();
        mMuxerLock.lock();
        if (err != OK || mError != OK) {
            ALOGE("stop err: %d, mError:%d", err, mError);
        }
        /* Prioritize mError over err as writer would have got stopped on any
         * internal error and notified muxer already.  Clients might issue
         * stop again later, and mWriter->stop() would return success.
         */
        if (mError != OK) {
            err = mError;
        if (err != OK) {
            ALOGE("stop() err: %d", err);
        }
        return err;
    } else {
@@ -232,29 +220,4 @@ status_t MediaMuxer::writeSampleData(const sp<ABuffer> &buffer, size_t trackInde
    return currentTrack->pushBuffer(mediaBuffer);
}

void MediaMuxer::notify(int msg, int ext1, int ext2) {
    switch (msg) {
        case MEDIA_RECORDER_EVENT_ERROR:
        case MEDIA_RECORDER_TRACK_EVENT_ERROR: {
            Mutex::Autolock autoLock(mMuxerLock);
            mState = ERROR;
            mError = ext2;
            ALOGW("message received msg=%d, ext1=%d, ext2=%d", msg, ext1, ext2);
            break;
        }
        case MEDIA_RECORDER_EVENT_INFO: {
            if (ext1 == MEDIA_RECORDER_INFO_UNKNOWN) {
                Mutex::Autolock autoLock(mMuxerLock);
                mState = ERROR;
                mError = ext2;
                ALOGW("message received msg=%d, ext1=%d, ext2=%d", msg, ext1, ext2);
            }
            break;
        }
        default:
            // Ignore INFO and other notifications for now.
            break;
    }
}

}  // namespace android
+1 −5
Original line number Diff line number Diff line
@@ -117,8 +117,6 @@ public:
    status_t writeSampleData(const sp<ABuffer> &buffer, size_t trackIndex,
                             int64_t timeUs, uint32_t flags) ;

    void notify(int msg, int ext1, int ext2);

private:
    const OutputFormat mFormat;
    sp<MediaWriter> mWriter;
@@ -130,11 +128,9 @@ private:
        UNINITIALIZED,
        INITIALIZED,
        STARTED,
        STOPPED,
        ERROR
        STOPPED
    };
    State mState;
    status_t mError;

    DISALLOW_EVIL_CONSTRUCTORS(MediaMuxer);
};
Loading