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

Commit fd01094f authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add a conditional wait for file switching in MPEG4Writer." into main am: 2e9ef55e

parents f9b7e9ec 2e9ef55e
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -72,6 +72,9 @@ static const int64_t kInitialDelayTimeUs = 700000LL;
static const int64_t kMaxMetadataSize = 0x4000000LL;   // 64MB max per-frame metadata size
static const int64_t kMaxCttsOffsetTimeUs = 30 * 60 * 1000000LL;  // 30 minutes
static const size_t kESDSScratchBufferSize = 10;  // kMaxAtomSize in Mpeg4Extractor 64MB
// Allow up to 100 milli second, which is safely above the maximum delay observed in manual testing
// between posting from setNextFd and handling it
static const int64_t kFdCondWaitTimeoutNs = 100000000;

static const char kMetaKey_Version[]    = "com.android.version";
static const char kMetaKey_Manufacturer[]      = "com.android.manufacturer";
@@ -1262,10 +1265,14 @@ status_t MPEG4Writer::switchFd() {
        return OK;
    }

    // Wait for the signal only if the new file is not available.
    if (mNextFd == -1) {
        status_t res = mFdCond.waitRelative(mLock, kFdCondWaitTimeoutNs);
        if (res != OK) {
            ALOGW("No FileDescriptor for next recording");
            return INVALID_OPERATION;
        }
    }

    mSwitchPending = true;
    sp<AMessage> msg = new AMessage(kWhatSwitch, mReflector);
@@ -2433,6 +2440,7 @@ status_t MPEG4Writer::setNextFd(int fd) {
        return INVALID_OPERATION;
    }
    mNextFd = dup(fd);
    mFdCond.signal();
    return OK;
}

+1 −0
Original line number Diff line number Diff line
@@ -144,6 +144,7 @@ private:
    std::mutex mFallocMutex;
    bool mPreAllocFirstTime; // Pre-allocate space for file and track headers only once per file.
    uint64_t mPrevAllTracksTotalMetaDataSizeEstimate;
    Condition mFdCond;

    List<Track *> mTracks;