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

Commit 5981fc5a authored by Wei Jia's avatar Wei Jia Committed by Android (Google) Code Review
Browse files

Merge "Added paused state to NuPlayerDecoder"

parents 77d28819 704e7265
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;