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

Commit 0dff606f authored by James Dong's avatar James Dong
Browse files

Allocate buffers before calling start on its source in OMXCodec::start() for encoder case

o This makes it possible to configure the source to use the same number of input buffers
  as requested by the video encoder, before the source starts. As a result, hardcoded
  number of video buffers for camera source, for instance, can be avoided.

o related-to-bug: 6920805

Change-Id: I13d2c308dce34967768cd407f02988e92ef10a89
parent c9729ca1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ enum {
    kKeyTrackTimeStatus   = 'tktm',  // int64_t

    kKeyNotRealTime       = 'ntrt',  // bool (int32_t)
    kKeyNumBuffers        = 'nbbf',  // int32_t

    // Ogg files can be tagged to be automatically looping...
    kKeyAutoLoop          = 'autL',  // bool (int32_t)
+17 −5
Original line number Diff line number Diff line
@@ -3623,11 +3623,6 @@ status_t OMXCodec::start(MetaData *meta) {
        }
        params->setInt64(kKeyTime, startTimeUs);
    }
    status_t err = mSource->start(params.get());

    if (err != OK) {
        return err;
    }

    mCodecSpecificDataIndex = 0;
    mInitialBufferSubmit = true;
@@ -3640,6 +3635,23 @@ status_t OMXCodec::start(MetaData *meta) {
    mFilledBuffers.clear();
    mPaused = false;

    status_t err;
    if (mIsEncoder) {
        // Calling init() before starting its source so that we can configure,
        // if supported, the source to use exactly the same number of input
        // buffers as requested by the encoder.
        if ((err = init()) != OK) {
            return err;
        }

        params->setInt32(kKeyNumBuffers, mPortBuffers[kPortIndexInput].size());
        return mSource->start(params.get());
    }

    // Decoder case
    if ((err = mSource->start(params.get())) != OK) {
        return err;
    }
    return init();
}