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

Commit 2553099e authored by Satya Krishna Pindiproli's avatar Satya Krishna Pindiproli Committed by Linux Build Service Account
Browse files

nuplayer: set maxBuffers to 1 in byte stream mode

For MP3 and AAC clips, byte stream mode is enabled
by default in which the parser gives a huge chunk of
data per read. In this case, reading 64 buffers is
unnecessary as it leads to delay in data being written
to HAL which causes a gap during gapless transition.

Set maxBuffers to 1 when byte stream mode is enabled.

Change-Id: I4f51bbc4c53d17f62cab571b83ca015cea430fa4
parent 9693a15c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ struct AVNuUtils {
    virtual bool pcmOffloadException(const sp<AMessage> &);
    virtual audio_format_t getPCMFormat(const sp<AMessage> &);
    virtual void setCodecOutputFormat(const sp<AMessage> &);
    virtual bool isByteStreamModeEnabled(const sp<MetaData> &);

    // ----- NO TRESSPASSING BEYOND THIS LINE ------
    DECLARE_LOADABLE_SINGLETON(AVNuUtils);
+4 −0
Original line number Diff line number Diff line
@@ -76,6 +76,10 @@ void AVNuUtils::checkFormatChange(bool * /*formatChange*/,
        const sp<ABuffer> & /*accessUnit*/) {
}

bool AVNuUtils::isByteStreamModeEnabled(const sp<MetaData> &) {
    return false;
}

// ----- NO TRESSPASSING BEYOND THIS LINE ------
AVNuUtils::AVNuUtils() {}

+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ LOCAL_C_INCLUDES := \
	$(TOP)/frameworks/av/media/libstagefright/timedtext           \
	$(TOP)/frameworks/av/media/libmediaplayerservice              \
	$(TOP)/frameworks/native/include/media/openmax                \
        $(TOP)/frameworks/av/media/libavextensions                    \
	$(TOP)/frameworks/av/media/libavextensions

LOCAL_CFLAGS += -Werror -Wall

+11 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
#include "../../libstagefright/include/NuCachedSource2.h"
#include "../../libstagefright/include/WVMExtractor.h"
#include "../../libstagefright/include/HTTPBase.h"
#include "mediaplayerservice/AVNuExtensions.h"

namespace android {

@@ -59,6 +60,7 @@ NuPlayer::GenericSource::GenericSource(
      mFetchTimedTextDataGeneration(0),
      mDurationUs(-1ll),
      mAudioIsVorbis(false),
      mIsByteMode(false),
      mIsWidevine(false),
      mIsSecure(false),
      mIsStreaming(false),
@@ -245,6 +247,10 @@ status_t NuPlayer::GenericSource::initFromDataSource() {
                } else {
                    mAudioIsVorbis = false;
                }

                if (AVNuUtils::get()->isByteStreamModeEnabled(meta)) {
                    mIsByteMode = true;
                }
                mAudioTrack.mReadMultiple = track->canReadMultiple();
            }
        } else if (!strncasecmp(mime, "video/", 6)) {
@@ -1387,6 +1393,11 @@ void NuPlayer::GenericSource::readBuffer(
            track = &mAudioTrack;
            if (mIsWidevine) {
                maxBuffers = 8;
            } else if (mIsByteMode) {
                // byte stream mode is enabled only for mp3 & aac
                // and the parser gives a huge chunk of data per read,
                // so reading one buffer is sufficient.
                maxBuffers = 1;
            } else {
                maxBuffers = 64;
            }
+1 −0
Original line number Diff line number Diff line
@@ -205,6 +205,7 @@ private:
    int32_t mFetchTimedTextDataGeneration;
    int64_t mDurationUs;
    bool mAudioIsVorbis;
    bool mIsByteMode;
    bool mIsWidevine;
    bool mIsSecure;
    bool mIsStreaming;