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

Commit 6623074d authored by Steve Kondik's avatar Steve Kondik
Browse files

audio: Fix PCM offload for NuPlayer

 * PCM offload is wonderfully broken on NuPlayer in the current CAF
   codebase.  Force the format to an offload format to get it
   working again.

Change-Id: I2ebfa4afc2e0a2bd7e7b6df4595449a2705f1eab
parent 38242543
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -27,8 +27,12 @@ ifeq ($(call is-vendor-board-platform,QCOM),true)
ifeq ($(strip $(AUDIO_FEATURE_ENABLED_EXTN_FLAC_DECODER)),true)
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audio-flac
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio
LOCAL_CFLAGS := -DQTI_FLAC_DECODER
LOCAL_CFLAGS += -DQTI_FLAC_DECODER
endif
ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PCM_OFFLOAD)),true)
LOCAL_CFLAGS += -DPCM_OFFLOAD_ENABLED
endif

endif

LOCAL_MODULE:= libstagefright_nuplayer
+5 −0
Original line number Diff line number Diff line
@@ -1366,6 +1366,11 @@ bool NuPlayer::Renderer::onOpenAudioSink(
                    "audio_format", mime.c_str());
            onDisableOffloadAudio();
        } else {
#ifdef PCM_OFFLOAD_ENABLED
            if (audio_is_linear_pcm(audioFormat) || audio_is_offload_pcm(audioFormat)) {
                audioFormat = AUDIO_FORMAT_PCM_16_BIT_OFFLOAD;
            }
#endif
            ALOGV("Mime \"%s\" mapped to audio_format 0x%x",
                    mime.c_str(), audioFormat);

+5 −7
Original line number Diff line number Diff line
@@ -184,14 +184,12 @@ status_t AudioPlayer::start(bool sourceAlreadyStarted) {
            ALOGE("%s Couldn't map mime type \"%s\" to a valid AudioSystem::audio_format",
                  __func__, mime);
            audioFormat = AUDIO_FORMAT_INVALID;
        } else {
        } else if (audio_is_linear_pcm(audioFormat) || audio_is_offload_pcm(audioFormat)) {
            // 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)
            if (bitWidth >= 24)
                audioFormat = AUDIO_FORMAT_PCM_24_BIT_OFFLOAD;
            else
                audioFormat = AUDIO_FORMAT_PCM_24_BIT_OFFLOAD;
            }

            ALOGV("%s Mime type \"%s\" mapped to audio_format 0x%x",
                  __func__, mime, audioFormat);
+61 −55
Original line number Diff line number Diff line
LOCAL_PATH:= $(call my-dir)

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_COMPRESS_VOIP)),true)
common_cflags += -DAUDIO_EXTN_COMPRESS_VOIP_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_EXTN_FORMATS)),true)
common_cflags += -DAUDIO_EXTN_FORMATS_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_FM)),true)
common_cflags += -DAUDIO_EXTN_FM_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HDMI_SPK)),true)
common_cflags += -DAUDIO_EXTN_HDMI_SPK_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_INCALL_MUSIC)),true)
common_cflags += -DAUDIO_EXTN_INCALL_MUSIC_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_MULTIPLE_TUNNEL)), true)
common_cflags += -DMULTIPLE_OFFLOAD_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PCM_OFFLOAD)),true)
common_cflags += -DPCM_OFFLOAD_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PROXY_DEVICE)),true)
common_cflags += -DAUDIO_EXTN_AFE_PROXY_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_SSR)),true)
common_cflags += -DAUDIO_EXTN_SSR_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_VOICE_CONCURRENCY)),true)
common_cflags += -DVOICE_CONCURRENCY
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_RECORD_PLAY_CONCURRENCY)),true)
common_cflags += -DRECORD_PLAY_CONCURRENCY
endif

ifeq ($(strip $(DOLBY_UDC)),true)
common_cflags += -DDOLBY_UDC
endif #DOLBY_UDC
ifeq ($(strip $(DOLBY_DDP)),true)
common_cflags += -DDOLBY_DDP
endif #DOLBY_DDP
ifeq ($(strip $(DOLBY_DAP)),true)
    ifdef DOLBY_DAP_OPENSLES
        common_cflags += -DDOLBY_DAP_OPENSLES
    endif
endif #DOLBY_END

include $(CLEAR_VARS)

LOCAL_SRC_FILES:= \
@@ -41,6 +97,8 @@ LOCAL_STATIC_LIBRARIES := \
    libmedia_helper \
    libserviceutility

LOCAL_CFLAGS += $(common_cflags)

LOCAL_MODULE:= libaudiopolicyservice

LOCAL_CFLAGS += -fvisibility=hidden
@@ -64,61 +122,7 @@ LOCAL_SHARED_LIBRARIES := \
LOCAL_STATIC_LIBRARIES := \
    libmedia_helper

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_COMPRESS_VOIP)),true)
LOCAL_CFLAGS += -DAUDIO_EXTN_COMPRESS_VOIP_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_EXTN_FORMATS)),true)
LOCAL_CFLAGS += -DAUDIO_EXTN_FORMATS_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_FM)),true)
LOCAL_CFLAGS += -DAUDIO_EXTN_FM_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HDMI_SPK)),true)
LOCAL_CFLAGS += -DAUDIO_EXTN_HDMI_SPK_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_INCALL_MUSIC)),true)
LOCAL_CFLAGS += -DAUDIO_EXTN_INCALL_MUSIC_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_MULTIPLE_TUNNEL)), true)
LOCAL_CFLAGS += -DMULTIPLE_OFFLOAD_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PCM_OFFLOAD)),true)
    LOCAL_CFLAGS += -DPCM_OFFLOAD_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PROXY_DEVICE)),true)
LOCAL_CFLAGS += -DAUDIO_EXTN_AFE_PROXY_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_SSR)),true)
LOCAL_CFLAGS += -DAUDIO_EXTN_SSR_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_VOICE_CONCURRENCY)),true)
LOCAL_CFLAGS += -DVOICE_CONCURRENCY
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_RECORD_PLAY_CONCURRENCY)),true)
LOCAL_CFLAGS += -DRECORD_PLAY_CONCURRENCY
endif

ifeq ($(strip $(DOLBY_UDC)),true)
  LOCAL_CFLAGS += -DDOLBY_UDC
endif #DOLBY_UDC
ifeq ($(strip $(DOLBY_DDP)),true)
  LOCAL_CFLAGS += -DDOLBY_DDP
endif #DOLBY_DDP
ifeq ($(strip $(DOLBY_DAP)),true)
    ifdef DOLBY_DAP_OPENSLES
        LOCAL_CFLAGS += -DDOLBY_DAP_OPENSLES
    endif
endif #DOLBY_END
LOCAL_CFLAGS += $(common_cflags)

LOCAL_MODULE:= libaudiopolicymanagerdefault

@@ -136,6 +140,8 @@ LOCAL_SHARED_LIBRARIES := \

LOCAL_MODULE:= libaudiopolicymanager

LOCAL_CFLAGS += $(common_cflags)

include $(BUILD_SHARED_LIBRARY)

endif
+5 −3
Original line number Diff line number Diff line
@@ -2569,6 +2569,7 @@ return false;

    char propValue[PROPERTY_VALUE_MAX];
    bool pcmOffload = false;

#ifdef PCM_OFFLOAD_ENABLED
    if (audio_is_offload_pcm(offloadInfo.format)) {
        if(property_get("audio.offload.pcm.enable", propValue, NULL)) {
@@ -4609,20 +4610,21 @@ AudioPolicyManager::routing_strategy AudioPolicyManager::getStrategy(
        return STRATEGY_SONIFICATION_RESPECTFUL;
    case AUDIO_STREAM_DTMF:
        return STRATEGY_DTMF;
    default:
        ALOGE("unknown stream type");
    case AUDIO_STREAM_SYSTEM:
        // NOTE: SYSTEM stream uses MEDIA strategy because muting music and switching outputs
        // while key clicks are played produces a poor result
    case AUDIO_STREAM_TTS:
    case AUDIO_STREAM_MUSIC:
#ifdef AUDIO_EXTN_INCALL_MUSIC_ENABLED
#ifdef QCOM_HARDWARE
    case AUDIO_STREAM_INCALL_MUSIC:
#endif
        return STRATEGY_MEDIA;
    case AUDIO_STREAM_ENFORCED_AUDIBLE:
        return STRATEGY_ENFORCED_AUDIBLE;
    default:
        ALOGE("unknown stream type %d", stream);
    }
    return STRATEGY_MEDIA;
}

uint32_t AudioPolicyManager::getStrategyForAttr(const audio_attributes_t *attr) {