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

Commit 76da2635 authored by James Dong's avatar James Dong Committed by Android (Google) Code Review
Browse files

Merge "Added a callback in nuplayer via informational event to signal the start of video rendering"

parents c374dae5 f57b4ea3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -500,6 +500,8 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
                CHECK(msg->findInt32("audio", &audio));

                ALOGV("renderer %s flush completed.", audio ? "audio" : "video");
            } else if (what == Renderer::kWhatVideoRenderingStart) {
                notifyListener(MEDIA_INFO, MEDIA_INFO_RENDERING_START, 0);
            }
            break;
        }
+12 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ NuPlayer::Renderer::Renderer(
      mHasVideo(false),
      mSyncQueues(false),
      mPaused(false),
      mVideoRenderingStarted(false),
      mLastPositionUpdateUs(-1ll),
      mVideoLateByUs(0ll) {
}
@@ -387,9 +388,20 @@ void NuPlayer::Renderer::onDrainVideoQueue() {
    mVideoQueue.erase(mVideoQueue.begin());
    entry = NULL;

    if (!mVideoRenderingStarted) {
        mVideoRenderingStarted = true;
        notifyVideoRenderingStart();
    }

    notifyPosition();
}

void NuPlayer::Renderer::notifyVideoRenderingStart() {
    sp<AMessage> notify = mNotify->dup();
    notify->setInt32("what", kWhatVideoRenderingStart);
    notify->post();
}

void NuPlayer::Renderer::notifyEOS(bool audio, status_t finalResult) {
    sp<AMessage> notify = mNotify->dup();
    notify->setInt32("what", kWhatEOS);
+6 −3
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ struct NuPlayer::Renderer : public AHandler {
        kWhatEOS                 = 'eos ',
        kWhatFlushComplete       = 'fluC',
        kWhatPosition            = 'posi',
        kWhatVideoRenderingStart = 'vdrd',
    };

protected:
@@ -99,6 +100,7 @@ private:
    bool mSyncQueues;

    bool mPaused;
    bool mVideoRenderingStarted;

    int64_t mLastPositionUpdateUs;
    int64_t mVideoLateByUs;
@@ -120,6 +122,7 @@ private:
    void notifyFlushComplete(bool audio);
    void notifyPosition();
    void notifyVideoLateBy(int64_t lateByUs);
    void notifyVideoRenderingStart();

    void flushQueue(List<QueueEntry> *queue);
    bool dropBufferWhileFlushing(bool audio, const sp<AMessage> &msg);