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

Commit 827388ba authored by Wei Jia's avatar Wei Jia Committed by android-build-merger
Browse files

Merge "NuPlayerRenderer: ignore fractional audio frame." into nyc-dev

am: aaa28deb

* commit 'aaa28deb':
  NuPlayerRenderer: ignore fractional audio frame.

Change-Id: I847f44e0d16512eb78ab5d1ff0af314f7fd9c1c5
parents 4fd0eb7f aaa28deb
Loading
Loading
Loading
Loading
+11 −2
Original line number Original line Diff line number Diff line
@@ -962,7 +962,15 @@ bool NuPlayer::Renderer::onDrainAudioQueue() {
        }
        }


        entry->mOffset += written;
        entry->mOffset += written;
        if (entry->mOffset == entry->mBuffer->size()) {
        size_t remainder = entry->mBuffer->size() - entry->mOffset;
        if ((ssize_t)remainder < mAudioSink->frameSize()) {
            if (remainder > 0) {
                ALOGW("Corrupted audio buffer has fractional frames, discarding %zu bytes.",
                        remainder);
                entry->mOffset += remainder;
                copy -= remainder;
            }

            entry->mNotifyConsumed->post();
            entry->mNotifyConsumed->post();
            mAudioQueue.erase(mAudioQueue.begin());
            mAudioQueue.erase(mAudioQueue.begin());


@@ -990,7 +998,8 @@ bool NuPlayer::Renderer::onDrainAudioQueue() {
            // AudioSink write is called in non-blocking mode.
            // AudioSink write is called in non-blocking mode.
            // It may return with a short count when:
            // It may return with a short count when:
            //
            //
            // 1) Size to be copied is not a multiple of the frame size. We consider this fatal.
            // 1) Size to be copied is not a multiple of the frame size. Fractional frames are
            //    discarded.
            // 2) The data to be copied exceeds the available buffer in AudioSink.
            // 2) The data to be copied exceeds the available buffer in AudioSink.
            // 3) An error occurs and data has been partially copied to the buffer in AudioSink.
            // 3) An error occurs and data has been partially copied to the buffer in AudioSink.
            // 4) AudioSink is an AudioCache for data retrieval, and the AudioCache is exceeded.
            // 4) AudioSink is an AudioCache for data retrieval, and the AudioCache is exceeded.