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

Commit 4decccae authored by Amit Shekhar's avatar Amit Shekhar Committed by Linux Build Service Account
Browse files

frameworks/av: fix format for 24 bit offload playback

-Set format for 24 bit offload playback
-Add flac codec specific params in offload metadata

Conflicts:
	media/libstagefright/AudioPlayer.cpp

Change-Id: I3ec2bc0d410ef58ab5e9a929cd25ab7966ed165d
parent 892cdbbc
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -1168,9 +1168,6 @@ void NuPlayer::Renderer::onPause() {
        mAudioSink->pause();
        startAudioOffloadPauseTimeout();
    }
    //for video only stream, reset mAnchorTimeMediaUs on stream's pause scenario
    if (mHasVideo && !mHasAudio)
        mAnchorTimeMediaUs = -1;

    ALOGV("now paused audio queue has %d entries, video has %d entries",
          mAudioQueue.size(), mVideoQueue.size());
+14 −0
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ ifeq ($(call is-vendor-board-platform,QCOM),true)
ifeq ($(strip $(AUDIO_FEATURE_ENABLED_EXTN_FLAC_DECODER)),true)
LOCAL_SRC_FILES += FLACDecoder.cpp
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audio-flac
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio
LOCAL_CFLAGS := -DQTI_FLAC_DECODER
endif
endif
@@ -139,6 +140,19 @@ ifeq ($(TARGET_ENABLE_QC_AV_ENHANCEMENTS),true)
       LOCAL_SRC_FILES  += FMA2DPWriter.cpp
endif #TARGET_ENABLE_AV_ENHANCEMENTS

ifeq ($(call is-vendor-board-platform,QCOM),true)
ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PCM_OFFLOAD_24)),true)
       LOCAL_CFLAGS     += -DPCM_OFFLOAD_ENABLED_24
       LOCAL_C_INCLUDES += $(TOP)/hardware/qcom/media/mm-core/inc
endif
endif

ifeq ($(call is-vendor-board-platform,QCOM),true)
ifeq ($(strip $(AUDIO_FEATURE_ENABLED_FLAC_OFFLOAD)),true)
       LOCAL_CFLAGS     += -DFLAC_OFFLOAD_ENABLED
endif
endif

LOCAL_SHARED_LIBRARIES += \
        libstagefright_enc_common \
        libstagefright_avc_common \
+20 −3
Original line number Diff line number Diff line
@@ -38,6 +38,11 @@

#include "include/AwesomePlayer.h"

#ifdef ENABLE_AV_ENHANCEMENTS
#include "QCMetaData.h"
#include "QCMediaDefs.h"
#endif

namespace android {

AudioPlayer::AudioPlayer(
@@ -150,18 +155,29 @@ status_t AudioPlayer::start(bool sourceAlreadyStarted) {
    }

    audio_format_t audioFormat = AUDIO_FORMAT_PCM_16_BIT;
    int32_t bitWidth = 16;
#ifdef ENABLE_AV_ENHANCEMENTS
#if defined(FLAC_OFFLOAD_ENABLED) || defined(PCM_OFFLOAD_ENABLED_24)
    format->findInt32(kKeySampleBits, &bitWidth);
#endif
#endif

    if (useOffload()) {
        if (mapMimeToAudioFormat(audioFormat, mime) != OK) {
            ALOGE("Couldn't map mime type \"%s\" to a valid AudioSystem::audio_format", mime);
            ALOGE("%s Couldn't map mime type \"%s\" to a valid AudioSystem::audio_format",
                  __func__, mime);
            audioFormat = AUDIO_FORMAT_INVALID;
        } else {
            // Override audio format for PCM offload
            if (audioFormat == AUDIO_FORMAT_PCM_16_BIT) {
                if (16 == bitWidth)
                    audioFormat = AUDIO_FORMAT_PCM_16_BIT_OFFLOAD;
                else if (24 == bitWidth)
                    audioFormat = AUDIO_FORMAT_PCM_24_BIT_OFFLOAD;
            }

            ALOGV("Mime type \"%s\" mapped to audio_format 0x%x", mime, audioFormat);
            ALOGV("%s Mime type \"%s\" mapped to audio_format 0x%x",
                  __func__, mime, audioFormat);
        }

        int32_t aacaot = -1;
@@ -192,6 +208,7 @@ status_t AudioPlayer::start(bool sourceAlreadyStarted) {
                offloadInfo.duration_us = -1;
            }

            offloadInfo.bit_width = bitWidth;
            offloadInfo.sample_rate = mSampleRate;
            offloadInfo.channel_mask = channelMask;
            offloadInfo.format = audioFormat;
+35 −2
Original line number Diff line number Diff line
@@ -39,6 +39,10 @@
#include "include/ExtendedUtils.h"
#ifdef ENABLE_AV_ENHANCEMENTS
#include "QCMediaDefs.h"
#include "QCMetaData.h"
#if defined(FLAC_OFFLOAD_ENABLED) || defined(PCM_OFFLOAD_ENABLED_24)
#include "audio_defs.h"
#endif
#endif

namespace android {
@@ -650,6 +654,23 @@ status_t sendMetaDataToHal(sp<MediaPlayerBase::AudioSink>& sink,
    if (meta->findInt32(kKeyEncoderPadding, &paddingSamples)) {
        param.addInt(String8(AUDIO_OFFLOAD_CODEC_PADDING_SAMPLES), paddingSamples);
    }
#ifdef ENABLE_AV_ENHANCEMENTS
#ifdef FLAC_OFFLOAD_ENABLED
    int32_t minBlkSize, maxBlkSize, minFrmSize, maxFrmSize; //FLAC params
    if (meta->findInt32(kKeyMinBlkSize, &minBlkSize)) {
        param.addInt(String8(AUDIO_OFFLOAD_CODEC_FLAC_MIN_BLK_SIZE), minBlkSize);
    }
    if (meta->findInt32(kKeyMaxBlkSize, &maxBlkSize)) {
        param.addInt(String8(AUDIO_OFFLOAD_CODEC_FLAC_MAX_BLK_SIZE), maxBlkSize);
    }
    if (meta->findInt32(kKeyMinFrmSize, &minFrmSize)) {
        param.addInt(String8(AUDIO_OFFLOAD_CODEC_FLAC_MIN_FRAME_SIZE), minFrmSize);
    }
    if (meta->findInt32(kKeyMaxFrmSize, &maxFrmSize)) {
        param.addInt(String8(AUDIO_OFFLOAD_CODEC_FLAC_MAX_FRAME_SIZE), maxFrmSize);
    }
#endif
#endif

    ALOGV("sendMetaDataToHal: bitRate %d, sampleRate %d, chanMask %d,"
          "delaySample %d, paddingSample %d", bitRate, sampleRate,
@@ -756,13 +777,25 @@ bool canOffloadStream(const sp<MetaData>& meta, bool hasVideo, const sp<MetaData
    audio_offload_info_t info = AUDIO_INFO_INITIALIZER;

    info.format = AUDIO_FORMAT_INVALID;
    int32_t bitWidth = 16;
#ifdef ENABLE_AV_ENHANCEMENTS
#ifdef PCM_OFFLOAD_ENABLED_24
    if(meta->findInt32(kKeySampleBits, &bitWidth) && 24 == bitWidth)
        ALOGV("%s Bits per sample is 24", __func__);
    else
        ALOGW("%s No Sample Bit info in meta data", __func__);
#endif
#endif
    if (mapMimeToAudioFormat(info.format, mime) != OK) {
        ALOGE(" Couldn't map mime type \"%s\" to a valid AudioSystem::audio_format !", mime);
        return false;
    } else {
        // Override audio format for PCM offload
        if (info.format == AUDIO_FORMAT_PCM_16_BIT) {
            if (16 == bitWidth)
                info.format = AUDIO_FORMAT_PCM_16_BIT_OFFLOAD;
            else if (24 == bitWidth)
                info.format = AUDIO_FORMAT_PCM_24_BIT_OFFLOAD;
        }
        ALOGV("Mime type \"%s\" mapped to audio_format %d", mime, info.format);
    }
@@ -812,7 +845,7 @@ bool canOffloadStream(const sp<MetaData>& meta, bool hasVideo, const sp<MetaData
     }
    info.bit_rate = brate;


    info.bit_width = bitWidth;
    info.stream_type = streamType;
    info.has_video = hasVideo;
    info.is_streaming = isStreaming;