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

Commit 584c14c3 authored by Rachad's avatar Rachad Committed by Android (Google) Code Review
Browse files

Merge "stagefright: do not allocate output buffers for tunneled playback" into lmp-dev

parents e48b90d6 ab76066c
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -217,6 +217,8 @@ private:


    bool mCreateInputBuffersSuspended;
    bool mCreateInputBuffersSuspended;


    bool mTunneled;

    status_t setCyclicIntraMacroblockRefresh(const sp<AMessage> &msg, int32_t mode);
    status_t setCyclicIntraMacroblockRefresh(const sp<AMessage> &msg, int32_t mode);
    status_t allocateBuffersOnPort(OMX_U32 portIndex);
    status_t allocateBuffersOnPort(OMX_U32 portIndex);
    status_t freeBuffersOnPort(OMX_U32 portIndex);
    status_t freeBuffersOnPort(OMX_U32 portIndex);
+28 −1
Original line number Original line Diff line number Diff line
@@ -421,7 +421,8 @@ ACodec::ACodec()
      mMaxPtsGapUs(-1ll),
      mMaxPtsGapUs(-1ll),
      mTimePerFrameUs(-1ll),
      mTimePerFrameUs(-1ll),
      mTimePerCaptureUs(-1ll),
      mTimePerCaptureUs(-1ll),
      mCreateInputBuffersSuspended(false) {
      mCreateInputBuffersSuspended(false),
      mTunneled(false) {
    mUninitializedState = new UninitializedState(this);
    mUninitializedState = new UninitializedState(this);
    mLoadedState = new LoadedState(this);
    mLoadedState = new LoadedState(this);
    mLoadedToIdleState = new LoadedToIdleState(this);
    mLoadedToIdleState = new LoadedToIdleState(this);
@@ -697,6 +698,21 @@ status_t ACodec::configureOutputBuffersFromNativeWindow(
        return err;
        return err;
    }
    }


    // Exits here for tunneled video playback codecs -- i.e. skips native window
    // buffer allocation step as this is managed by the tunneled OMX omponent
    // itself and explicitly sets def.nBufferCountActual to 0.
    if (mTunneled) {
        ALOGV("Tunneled Playback: skipping native window buffer allocation.");
        def.nBufferCountActual = 0;
        err = mOMX->setParameter(
                mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));

        *minUndequeuedBuffers = 0;
        *bufferCount = 0;
        *bufferSize = 0;
        return err;
    }

    *minUndequeuedBuffers = 0;
    *minUndequeuedBuffers = 0;
    err = mNativeWindow->query(
    err = mNativeWindow->query(
            mNativeWindow.get(), NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
            mNativeWindow.get(), NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
@@ -904,6 +920,13 @@ ACodec::BufferInfo *ACodec::dequeueBufferFromNativeWindow() {
    ANativeWindowBuffer *buf;
    ANativeWindowBuffer *buf;
    int fenceFd = -1;
    int fenceFd = -1;
    CHECK(mNativeWindow.get() != NULL);
    CHECK(mNativeWindow.get() != NULL);

    if (mTunneled) {
        ALOGW("dequeueBufferFromNativeWindow() should not be called in tunnel"
              " video playback mode mode!");
        return NULL;
    }

    if (native_window_dequeue_buffer_and_wait(mNativeWindow.get(), &buf) != 0) {
    if (native_window_dequeue_buffer_and_wait(mNativeWindow.get(), &buf) != 0) {
        ALOGE("dequeueBuffer failed.");
        ALOGE("dequeueBuffer failed.");
        return NULL;
        return NULL;
@@ -1245,6 +1268,7 @@ status_t ACodec::configureCodec(
        if (msg->findInt32("feature-tunneled-playback", &tunneled) &&
        if (msg->findInt32("feature-tunneled-playback", &tunneled) &&
            tunneled != 0) {
            tunneled != 0) {
            ALOGI("Configuring TUNNELED video playback.");
            ALOGI("Configuring TUNNELED video playback.");
            mTunneled = true;


            int32_t audioHwSync = 0;
            int32_t audioHwSync = 0;
            if (!msg->findInt32("audio-hw-sync", &audioHwSync)) {
            if (!msg->findInt32("audio-hw-sync", &audioHwSync)) {
@@ -1259,6 +1283,9 @@ status_t ACodec::configureCodec(


            inputFormat->setInt32("adaptive-playback", true);
            inputFormat->setInt32("adaptive-playback", true);
        } else {
        } else {
            ALOGV("Configuring CPU controlled video playback.");
            mTunneled = false;

            // Always try to enable dynamic output buffers on native surface
            // Always try to enable dynamic output buffers on native surface
            err = mOMX->storeMetaDataInBuffers(
            err = mOMX->storeMetaDataInBuffers(
                    mNode, kPortIndexOutput, OMX_TRUE);
                    mNode, kPortIndexOutput, OMX_TRUE);