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

Commit 052efa49 authored by Chong Zhang's avatar Chong Zhang Committed by Android (Google) Code Review
Browse files

Merge "wait for flush to finish before returning setSurface" into lmp-dev

parents 43febe72 13d6faa0
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1732,6 +1732,13 @@ void NuPlayer::performSetSurface(const sp<NativeWindowWrapper> &wrapper) {

    // XXX - ignore error from setVideoScalingMode for now
    setVideoScalingMode(mVideoScalingMode);

    if (mDriver != NULL) {
        sp<NuPlayerDriver> driver = mDriver.promote();
        if (driver != NULL) {
            driver->notifySetSurfaceComplete();
        }
    }
}

void NuPlayer::onSourceNotify(const sp<AMessage> &msg) {
+20 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ NuPlayerDriver::NuPlayerDriver()
    : mState(STATE_IDLE),
      mIsAsyncPrepare(false),
      mAsyncResult(UNKNOWN_ERROR),
      mSetSurfaceInProgress(false),
      mDurationUs(-1),
      mPositionUs(-1),
      mNotifyTimeRealUs(-1),
@@ -136,6 +137,10 @@ status_t NuPlayerDriver::setVideoSurfaceTexture(
        const sp<IGraphicBufferProducer> &bufferProducer) {
    Mutex::Autolock autoLock(mLock);

    if (mSetSurfaceInProgress) {
        return INVALID_OPERATION;
    }

    switch (mState) {
        case STATE_SET_DATASOURCE_PENDING:
        case STATE_RESET_IN_PROGRESS:
@@ -145,8 +150,14 @@ status_t NuPlayerDriver::setVideoSurfaceTexture(
            break;
    }

    mSetSurfaceInProgress = true;

    mPlayer->setVideoSurfaceTextureAsync(bufferProducer);

    while (mSetSurfaceInProgress) {
        mCondition.wait(mLock);
    }

    return OK;
}

@@ -533,6 +544,15 @@ void NuPlayerDriver::notifyResetComplete() {
    mCondition.broadcast();
}

void NuPlayerDriver::notifySetSurfaceComplete() {
    Mutex::Autolock autoLock(mLock);

    CHECK(mSetSurfaceInProgress);
    mSetSurfaceInProgress = false;

    mCondition.broadcast();
}

void NuPlayerDriver::notifyDuration(int64_t durationUs) {
    Mutex::Autolock autoLock(mLock);
    mDurationUs = durationUs;
+2 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ struct NuPlayerDriver : public MediaPlayerInterface {
    void notifySetDataSourceCompleted(status_t err);
    void notifyPrepareCompleted(status_t err);
    void notifyResetComplete();
    void notifySetSurfaceComplete();
    void notifyDuration(int64_t durationUs);
    void notifyPosition(int64_t positionUs);
    void notifySeekComplete();
@@ -102,6 +103,7 @@ private:

    // The following are protected through "mLock"
    // >>>
    bool mSetSurfaceInProgress;
    int64_t mDurationUs;
    int64_t mPositionUs;
    int64_t mNotifyTimeRealUs;