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


    requestCodecNotification();
    requestCodecNotification();
    mPaused = false;
}
}


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

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


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


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


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


        case kWhatResume:
        {
            onResume();
            break;
        }

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


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


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


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


    int32_t mBufferGeneration;
    int32_t mBufferGeneration;
    bool mPaused;
    AString mComponentName;
    AString mComponentName;


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