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

Commit 8bcd72bc authored by Steve Kondik's avatar Steve Kondik
Browse files

Merge branch 'LA.BF64.1.2.1_rb2.6' of git://codeaurora.org/platform/frameworks/av into cm-12.1

Change-Id: I8db1bc53d6603b1cb1f3f50c37c6925646b3762a
parents 9db62f87 daebc4eb
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -1468,6 +1468,7 @@ MediaPlayerService::AudioOutput::AudioOutput(int sessionId, int uid, int pid,
    mSendLevel = 0.0;
    setMinBufferCount();
    mAttributes = attr;
    mBitWidth = 16;
}

MediaPlayerService::AudioOutput::~AudioOutput()
@@ -1754,6 +1755,15 @@ status_t MediaPlayerService::AudioOutput::open(
        } else if (mRecycledTrack->format() != format) {
            reuse = false;
        }

        if (bothOffloaded) {
            if (mBitWidth != offloadInfo->bit_width) {
                ALOGV("output bit width differs %d v/s %d",
                      mBitWidth, offloadInfo->bit_width);
                reuse = false;
            }
        }

    } else {
        ALOGV("no track available to recycle");
    }
@@ -1865,6 +1875,13 @@ status_t MediaPlayerService::AudioOutput::open(
    mSampleRateHz = sampleRate;
    mFlags = flags;
    mMsecsPerFrame = mPlaybackRatePermille / (float) sampleRate;

    if (offloadInfo) {
        mBitWidth = offloadInfo->bit_width;
    } else {
        mBitWidth = 16;
    }

    uint32_t pos;
    if (t->getPosition(&pos) == OK) {
        mBytesWritten = uint64_t(pos) * t->frameSize();
@@ -1917,6 +1934,7 @@ void MediaPlayerService::AudioOutput::switchToNextOutput() {
        mNextOutput->mMsecsPerFrame = mMsecsPerFrame;
        mNextOutput->mBytesWritten = mBytesWritten;
        mNextOutput->mFlags = mFlags;
        mNextOutput->mBitWidth = mBitWidth;
    }
}

@@ -2229,6 +2247,7 @@ status_t MediaPlayerService::AudioCache::open(
{
    ALOGV("open(%u, %d, 0x%x, %d, %d)", sampleRate, channelCount, channelMask, format, bufferCount);
    if (mHeap->getHeapID() < 0) {
        ALOGE("Invalid heap Id");
        return NO_INIT;
    }

+1 −0
Original line number Diff line number Diff line
@@ -162,6 +162,7 @@ class MediaPlayerService : public BnMediaPlayerService
        static bool             mIsOnEmulator;
        static int              mMinBufferCount;  // 12 for emulator; otherwise 4
        audio_output_flags_t    mFlags;
        uint16_t                mBitWidth;

        // CallbackData is what is passed to the AudioTrack as the "user" data.
        // We need to be able to target this to a different Output on the fly,
+6 −0
Original line number Diff line number Diff line
@@ -70,6 +70,8 @@

namespace android {

static const int64_t kMax32BitFileSize = 0x00ffffffffLL; // 4GB

// To collect the encoder usage for the battery app
static void addBatteryData(uint32_t params) {
    sp<IBinder> binder =
@@ -478,6 +480,10 @@ status_t StagefrightRecorder::setParamMaxFileSizeBytes(int64_t bytes) {
    }

    mMaxFileSizeBytes = bytes;

    // If requested size is >4GB, force 64-bit offsets
    mUse64BitFileOffset |= (bytes >= kMax32BitFileSize);

    return OK;
}

+24 −3
Original line number Diff line number Diff line
@@ -267,10 +267,31 @@ status_t NuPlayer::GenericSource::initFromDataSource() {
    // Widevine sources might re-initialize crypto when starting, if we delay
    // this to start(), all data buffered during prepare would be wasted.
    // (We don't actually start reading until start().)
    if (mAudioTrack.mSource != NULL && mAudioTrack.mSource->start() != OK) {
    if (mAudioTrack.mSource != NULL) {
        bool overrideSourceStart = false;
        status_t status = false;
        sp<MetaData> audioMeta = NULL;
        audioMeta = mAudioTrack.mSource->getFormat();

        if (ExtendedUtils::is24bitPCMOffloadEnabled()) {
            if(ExtendedUtils::is24bitPCMOffloaded(audioMeta)) {
                overrideSourceStart = true;
            }
        }

        if (overrideSourceStart && audioMeta.get()) {
            ALOGV("Override AudioTrack source with Meta");
            status = mAudioTrack.mSource->start(audioMeta.get());
        } else {
            ALOGV("Do not override AudioTrack source with Meta");
            status = mAudioTrack.mSource->start();
        }

        if (status != OK ) {
            ALOGE("failed to start audio track!");
            return UNKNOWN_ERROR;
        }
    }

    if (mVideoTrack.mSource != NULL && mVideoTrack.mSource->start() != OK) {
        ALOGE("failed to start video track!");
+33 −35
Original line number Diff line number Diff line
@@ -922,7 +922,7 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
                } else {
                    ALOGV("Decoded PCM offload flushing");
                    if (mAudioDecoder != NULL) {
                        flushDecoder(true /* audio */, false/* needShutdown */);
                        flushDecoder(true /* audio */, true/* needShutdown */);
                    }
                }
                mRenderer->flush(
@@ -937,8 +937,7 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
                    if (ExtendedUtils::is24bitPCMOffloadEnabled()) {
                        sp<MetaData> audioMeta = mSource->getFormatMeta(true /* audio */);
                        if (ExtendedUtils::is24bitPCMOffloaded(audioMeta)) {
					        ALOGV("Override pcm format to 16 bits");
					        ExtendedUtils::setKeyPCMFormat(audioMeta, AUDIO_FORMAT_PCM_16_BIT );
                              mSource->stop();
                              mSource->start();
                        }
                    }
@@ -1065,20 +1064,8 @@ void NuPlayer::onStart() {
            instantiateDecoder(true, &mAudioDecoder);
        }
    }
    bool overrideSourceStart = false;
    if (ExtendedUtils::is24bitPCMOffloadEnabled()) {
	//if 24 bit offloading is enabled and if its such a use
	//case do not call start since this will be called
	//after openAudioSink
	     sp<MetaData> audioMeta = mSource->getFormatMeta(true /* audio */);
		 overrideSourceStart = ExtendedUtils::is24bitPCMOffloaded(audioMeta);
	}

    if (overrideSourceStart) {
	    ALOGV("%s: Do not start source, wait till openAudioSink");
	} else {
    mSource->start();
	}

    uint32_t flags = 0;

@@ -1108,7 +1095,7 @@ void NuPlayer::onStart() {
        }
        mOffloadAudio =
                ((mime && !ExtendedUtils::pcmOffloadException(mime)) &&
                canOffloadStream(audioMeta, (videoFormat != NULL), vMeta,
                canOffloadStream(audioPCMMeta, (videoFormat != NULL), vMeta,
                        mIsStreaming /* is_streaming */, streamType));
        mOffloadDecodedPCM = mOffloadAudio;
        ALOGI("Could not offload audio decode, pcm offload decided :%d",
@@ -1247,6 +1234,15 @@ void NuPlayer::tryOpenAudioSinkForOffload(const sp<AMessage> &format, bool hasVi
    // Note: This is called early in NuPlayer to determine whether offloading
    // is possible; otherwise the decoders call the renderer openAudioSink directly.

    //update bit width before opening audio sink
    if (ExtendedUtils::is24bitPCMOffloadEnabled()) {
        sp<MetaData> audioMeta = mSource->getFormatMeta(true /* audio */);
        if (ExtendedUtils::is24bitPCMOffloaded(audioMeta)) {
            ALOGV("overriding format with 24 bits");
            format->setInt32("bits-per-sample", 24);
        }
    }

    status_t err = mRenderer->openAudioSink(
            format, true /* offloadOnly */, hasVideo, AUDIO_OUTPUT_FLAG_NONE, mIsStreaming, &mOffloadAudio);
    if (err != OK) {
@@ -1309,20 +1305,22 @@ status_t NuPlayer::instantiateDecoder(bool audio, sp<DecoderBase> *decoder) {
        sp<MetaData> audioMeta = mSource->getFormatMeta(true /* audio */);

        if (mOffloadAudio && !mOffloadDecodedPCM) {
             if(ExtendedUtils::is24bitPCMOffloadEnabled() &&
			         ExtendedUtils::is24bitPCMOffloaded(audioMeta)) {
                         //if offloaded, configure source for 24 bit
                         ExtendedUtils::setKeyPCMFormat(audioMeta,AUDIO_FORMAT_PCM_8_24_BIT);
            if (ExtendedUtils::is24bitPCMOffloadEnabled()) {
                sp<MetaData> audioMeta = mSource->getFormatMeta(true /* audio */);
                if (ExtendedUtils::is24bitPCMOffloaded(audioMeta)) {
                    mSource->stop();
                    mSource->start();
                }
            }
            *decoder = new DecoderPassThrough(notify, mSource, mRenderer);
        } else {
             if(ExtendedUtils::is24bitPCMOffloadEnabled() &&
			         ExtendedUtils::is24bitPCMOffloaded(audioMeta)) {
                         //if NOT offloaded, configure source for 16 bit
                         ExtendedUtils::setKeyPCMFormat(audioMeta,AUDIO_FORMAT_PCM_16_BIT);
            if (ExtendedUtils::is24bitPCMOffloadEnabled()) {
                sp<MetaData> audioMeta = mSource->getFormatMeta(true /* audio */);
                if (ExtendedUtils::is24bitPCMOffloaded(audioMeta)) {
                    mSource->stop();
                    mSource->start();
                }
            }
            *decoder = new Decoder(notify, mSource, mRenderer);
        }
    } else {
Loading