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

Commit 704e7265 authored by Wei Jia's avatar Wei Jia
Browse files

Added paused state to NuPlayerDecoder

This prevents decoder from requesting new buffer until the decoder
is resumed, and prevents processing a potential DISCONTINUITY while
the player is still flushing.

Bug: 13133027

Change-Id: I2f9fa9f00c8583aa6908809cb7c31ddde07cfaf0
parent ee777157
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ NuPlayer::Decoder::Decoder(
    : mNotify(notify),
      mNativeWindow(nativeWindow),
      mBufferGeneration(0),
      mPaused(true),
      mComponentName("decoder") {
    // Every decoder has its own looper because MediaCodec operations
    // are blocking, but NuPlayer needs asynchronous operations.
@@ -112,6 +113,7 @@ void NuPlayer::Decoder::onConfigure(const sp<AMessage> &format) {
            mOutputBuffers.size());

    requestCodecNotification();
    mPaused = false;
}

void NuPlayer::Decoder::requestCodecNotification() {
@@ -352,6 +354,11 @@ void NuPlayer::Decoder::onFlush() {
    sp<AMessage> notify = mNotify->dup();
    notify->setInt32("what", kWhatFlushCompleted);
    notify->post();
    mPaused = true;
}

void NuPlayer::Decoder::onResume() {
    mPaused = false;
}

void NuPlayer::Decoder::onShutdown() {
@@ -380,6 +387,7 @@ void NuPlayer::Decoder::onShutdown() {
    sp<AMessage> notify = mNotify->dup();
    notify->setInt32("what", kWhatShutdownCompleted);
    notify->post();
    mPaused = true;
}

void NuPlayer::Decoder::onMessageReceived(const sp<AMessage> &msg) {
@@ -397,8 +405,10 @@ void NuPlayer::Decoder::onMessageReceived(const sp<AMessage> &msg) {
        case kWhatCodecNotify:
        {
            if (!isStaleReply(msg)) {
                if (!mPaused) {
                    while (handleAnInputBuffer()) {
                    }
                }

                while (handleAnOutputBuffer()) {
                }
@@ -430,6 +440,12 @@ void NuPlayer::Decoder::onMessageReceived(const sp<AMessage> &msg) {
            break;
        }

        case kWhatResume:
        {
            onResume();
            break;
        }

        case kWhatShutdown:
        {
            onShutdown();
@@ -447,7 +463,7 @@ void NuPlayer::Decoder::signalFlush() {
}

void NuPlayer::Decoder::signalResume() {
    // nothing to do
    (new AMessage(kWhatResume, id()))->post();
}

void NuPlayer::Decoder::initiateShutdown() {
+2 −0
Original line number Diff line number Diff line
@@ -87,11 +87,13 @@ private:

    void onConfigure(const sp<AMessage> &format);
    void onFlush();
    void onResume();
    void onInputBufferFilled(const sp<AMessage> &msg);
    void onRenderBuffer(const sp<AMessage> &msg);
    void onShutdown();

    int32_t mBufferGeneration;
    bool mPaused;
    AString mComponentName;

    bool supportsSeamlessAudioFormatChange(const sp<AMessage> &targetFormat) const;