diff options
author | Ethan Chen <intervigil@gmail.com> | 2016-03-16 16:58:13 -0700 |
---|---|---|
committer | Ethan Chen <intervigil@gmail.com> | 2016-03-16 16:58:13 -0700 |
commit | d9ae022eab50fe55adc00d352175860e7a1043fa (patch) | |
tree | 7857c6d5e435d5e9f563c8353f0f76fd42322ec1 | |
parent | 7123d2be30344e3550e65b6593ba4bff5b074e85 (diff) | |
parent | 886c2444490dc96c39886bedd78303749d60c7b8 (diff) | |
download | hardware_qcom_audio-stable/cm-13.0-caf-8952-ZNH2KB.tar.gz hardware_qcom_audio-stable/cm-13.0-caf-8952-ZNH2KB.tar.bz2 hardware_qcom_audio-stable/cm-13.0-caf-8952-ZNH2KB.zip |
Merge remote-tracking branch 'caf/LA.BR.1.3.3_rb1.12' into cm-13.0-caf-8952stable/cm-13.0-caf-8952-ZNH2KB
Change-Id: Ia0e5540e1ead7fefdb075b974492417bd6149dbf
-rw-r--r-- | hal/audio_extn/soundtrigger.c | 5 | ||||
-rwxr-xr-x | hal/audio_hw.c | 81 | ||||
-rw-r--r-- | hal/audio_hw.h | 7 | ||||
-rw-r--r-- | hal/msm8916/platform.c | 22 | ||||
-rw-r--r-- | hal/msm8974/platform.c | 18 | ||||
-rw-r--r-- | hal/msm8974/platform.h | 10 | ||||
-rw-r--r-- | hal/platform_info.c | 4 | ||||
-rw-r--r-- | policy_hal/AudioPolicyManager.cpp | 26 |
8 files changed, 109 insertions, 64 deletions
diff --git a/hal/audio_extn/soundtrigger.c b/hal/audio_extn/soundtrigger.c index c13c2f36..2b519c9f 100644 --- a/hal/audio_extn/soundtrigger.c +++ b/hal/audio_extn/soundtrigger.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. +/* Copyright (c) 2013-2014, 2016 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -174,7 +174,7 @@ void audio_extn_sound_trigger_stop_lab(struct stream_in *in) struct sound_trigger_info *st_ses_info = NULL; audio_event_info_t event; - if (!st_dev || !in) + if (!st_dev || !in || !in->is_st_session_active) return; pthread_mutex_lock(&st_dev->lock); @@ -184,6 +184,7 @@ void audio_extn_sound_trigger_stop_lab(struct stream_in *in) event.u.ses_info = st_ses_info->st_ses; ALOGV("%s: AUDIO_EVENT_STOP_LAB pcm %p", __func__, st_ses_info->st_ses.pcm); st_dev->st_callback(AUDIO_EVENT_STOP_LAB, &event); + in->is_st_session_active = false; } } void audio_extn_sound_trigger_check_and_get_session(struct stream_in *in) diff --git a/hal/audio_hw.c b/hal/audio_hw.c index 57151ce1..a674a64f 100755 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. * Not a Contribution. * * Copyright (C) 2013 The Android Open Source Project @@ -168,8 +168,9 @@ const char * const use_case_table[AUDIO_USECASE_MAX] = { [USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = "low-latency-playback", [USECASE_AUDIO_PLAYBACK_MULTI_CH] = "multi-channel-playback", [USECASE_AUDIO_PLAYBACK_OFFLOAD] = "compress-offload-playback", -#ifdef MULTIPLE_OFFLOAD_ENABLED + //Enabled for Direct_PCM [USECASE_AUDIO_PLAYBACK_OFFLOAD2] = "compress-offload-playback2", +#ifdef MULTIPLE_OFFLOAD_ENABLED [USECASE_AUDIO_PLAYBACK_OFFLOAD3] = "compress-offload-playback3", [USECASE_AUDIO_PLAYBACK_OFFLOAD4] = "compress-offload-playback4", [USECASE_AUDIO_PLAYBACK_OFFLOAD5] = "compress-offload-playback5", @@ -179,7 +180,6 @@ const char * const use_case_table[AUDIO_USECASE_MAX] = { [USECASE_AUDIO_PLAYBACK_OFFLOAD9] = "compress-offload-playback9", #endif [USECASE_AUDIO_PLAYBACK_ULL] = "audio-ull-playback", - [USECASE_AUDIO_DIRECT_PCM_OFFLOAD] = "compress-offload-playback2", [USECASE_AUDIO_RECORD] = "audio-record", [USECASE_AUDIO_RECORD_COMPRESS] = "audio-record-compress", @@ -215,8 +215,8 @@ const char * const use_case_table[AUDIO_USECASE_MAX] = { static const audio_usecase_t offload_usecases[] = { USECASE_AUDIO_PLAYBACK_OFFLOAD, -#ifdef MULTIPLE_OFFLOAD_ENABLED USECASE_AUDIO_PLAYBACK_OFFLOAD2, +#ifdef MULTIPLE_OFFLOAD_ENABLED USECASE_AUDIO_PLAYBACK_OFFLOAD3, USECASE_AUDIO_PLAYBACK_OFFLOAD4, USECASE_AUDIO_PLAYBACK_OFFLOAD5, @@ -225,7 +225,6 @@ static const audio_usecase_t offload_usecases[] = { USECASE_AUDIO_PLAYBACK_OFFLOAD8, USECASE_AUDIO_PLAYBACK_OFFLOAD9, #endif - USECASE_AUDIO_DIRECT_PCM_OFFLOAD, }; #define STRING_TO_ENUM(string) { #string, string } @@ -1366,35 +1365,50 @@ bool is_offload_usecase(audio_usecase_t uc_id) return false; } -static audio_usecase_t get_offload_usecase(struct audio_device *adev) +static audio_usecase_t get_offload_usecase(struct audio_device *adev, bool is_direct_pcm) { - audio_usecase_t ret = USECASE_AUDIO_PLAYBACK_OFFLOAD; - unsigned int i, num_usecase = sizeof(offload_usecases)/sizeof(offload_usecases[0]); - char value[PROPERTY_VALUE_MAX] = {0}; + audio_usecase_t ret_uc = USECASE_INVALID; + unsigned int offload_uc_index; + int num_usecase = sizeof(offload_usecases)/sizeof(offload_usecases[0]); + if (!adev->multi_offload_enable) { + if (is_direct_pcm) + ret_uc = USECASE_AUDIO_PLAYBACK_OFFLOAD2; + else + ret_uc = USECASE_AUDIO_PLAYBACK_OFFLOAD; - property_get("audio.offload.multiple.enabled", value, NULL); - if (!(atoi(value) || !strncmp("true", value, 4))) - num_usecase = 1; /* If prop is not set, limit the num of offload usecases to 1 */ + pthread_mutex_lock(&adev->lock); + if (get_usecase_from_list(adev, ret_uc) != NULL) + ret_uc = USECASE_INVALID; + pthread_mutex_unlock(&adev->lock); + + return ret_uc; + } ALOGV("%s: num_usecase: %d", __func__, num_usecase); - for (i = 0; i < num_usecase; i++) { - if (!(adev->offload_usecases_state & (0x1<<i))) { - adev->offload_usecases_state |= 0x1 << i; - ret = offload_usecases[i]; + for (offload_uc_index = 0; offload_uc_index < num_usecase; offload_uc_index++) { + if (!(adev->offload_usecases_state & (0x1 << offload_uc_index))) { + adev->offload_usecases_state |= 0x1 << offload_uc_index; + ret_uc = offload_usecases[offload_uc_index]; break; } } - ALOGV("%s: offload usecase is %d", __func__, ret); - return ret; + + ALOGV("%s: offload usecase is %d", __func__, ret_uc); + return ret_uc; } static void free_offload_usecase(struct audio_device *adev, audio_usecase_t uc_id) { - unsigned int i; - for (i = 0; i < sizeof(offload_usecases)/sizeof(offload_usecases[0]); i++) { - if (offload_usecases[i] == uc_id) { - adev->offload_usecases_state &= ~(0x1<<i); + unsigned int offload_uc_index; + int num_usecase = sizeof(offload_usecases)/sizeof(offload_usecases[0]); + + if (!adev->multi_offload_enable) + return; + + for (offload_uc_index = 0; offload_uc_index < num_usecase; offload_uc_index++) { + if (offload_usecases[offload_uc_index] == uc_id) { + adev->offload_usecases_state &= ~(0x1 << offload_uc_index); break; } } @@ -2349,7 +2363,7 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, out->standby = true; goto exit; } - if (out->usecase != USECASE_AUDIO_PLAYBACK_OFFLOAD && adev->adm_register_output_stream) + if (!is_offload_usecase(out->usecase) && adev->adm_register_output_stream) adev->adm_register_output_stream(adev->adm_data, out->handle, out->flags); } @@ -3122,18 +3136,24 @@ static int adev_open_output_stream(struct audio_hw_device *dev, } if (out->flags & AUDIO_OUTPUT_FLAG_DIRECT_PCM) { - ALOGV("%s:: inserting DIRECT_PCM _USECASE", __func__); - out->usecase = USECASE_AUDIO_DIRECT_PCM_OFFLOAD; + out->usecase = get_offload_usecase(adev, true); + ALOGV("DIRECT_PCM usecase ... usecase selected %d ", out->usecase); } else { - ALOGV("%s:: inserting OFFLOAD_USECASE", __func__); - out->usecase = get_offload_usecase(adev); - out->stream.set_callback = out_set_callback; out->stream.pause = out_pause; out->stream.resume = out_resume; out->stream.drain = out_drain; out->stream.flush = out_flush; + out->usecase = get_offload_usecase(adev, false); + ALOGV("Compress Offload usecase .. usecase selected %d", out->usecase); + } + + if (out->usecase == USECASE_INVALID) { + ALOGE("%s: Max allowed OFFLOAD usecase reached ... "); + ret = -EEXIST; + goto error_open; } + if (config->offload_info.channel_mask) out->channel_mask = config->offload_info.channel_mask; else if (config->channel_mask) { @@ -3844,6 +3864,10 @@ static void adev_close_input_stream(struct audio_hw_device *dev, audio_extn_compr_cap_format_supported(in->config.format)) audio_extn_compr_cap_deinit(); + if (in->is_st_session) { + ALOGV("%s: sound trigger pcm stop lab", __func__); + audio_extn_sound_trigger_stop_lab(in); + } free(stream); return; } @@ -4079,6 +4103,7 @@ static int adev_open(const hw_module_t *module, const char *name, } } + adev->multi_offload_enable = property_get_bool("audio.offload.multiple.enabled", false); pthread_mutex_unlock(&adev_init_lock); if (adev->adm_init) diff --git a/hal/audio_hw.h b/hal/audio_hw.h index 7a165517..67f74510 100644 --- a/hal/audio_hw.h +++ b/hal/audio_hw.h @@ -85,8 +85,8 @@ enum { USECASE_AUDIO_PLAYBACK_LOW_LATENCY, USECASE_AUDIO_PLAYBACK_MULTI_CH, USECASE_AUDIO_PLAYBACK_OFFLOAD, -#ifdef MULTIPLE_OFFLOAD_ENABLED USECASE_AUDIO_PLAYBACK_OFFLOAD2, +#ifdef MULTIPLE_OFFLOAD_ENABLED USECASE_AUDIO_PLAYBACK_OFFLOAD3, USECASE_AUDIO_PLAYBACK_OFFLOAD4, USECASE_AUDIO_PLAYBACK_OFFLOAD5, @@ -97,8 +97,6 @@ enum { #endif USECASE_AUDIO_PLAYBACK_ULL, - USECASE_AUDIO_DIRECT_PCM_OFFLOAD, - /* FM usecase */ USECASE_AUDIO_PLAYBACK_FM, @@ -354,6 +352,9 @@ struct audio_device { adm_deregister_stream_t adm_deregister_stream; adm_request_focus_t adm_request_focus; adm_abandon_focus_t adm_abandon_focus; + + bool multi_offload_enable; + amplifier_device_t *amp; }; diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c index f27648cc..66a73b49 100644 --- a/hal/msm8916/platform.c +++ b/hal/msm8916/platform.c @@ -267,12 +267,12 @@ int pcm_device_table[AUDIO_USECASE_MAX][2] = { MULTIMEDIA2_PCM_DEVICE}, [USECASE_AUDIO_PLAYBACK_OFFLOAD] = {PLAYBACK_OFFLOAD_DEVICE, PLAYBACK_OFFLOAD_DEVICE}, -#ifdef MULTIPLE_OFFLOAD_ENABLED /* Below entries are initialized with invalid values * Valid values should be updated from fnc platform_info_init() * based on pcm ids defined in audio_platform_info.xml. */ - [USECASE_AUDIO_PLAYBACK_OFFLOAD2] = {-1, -1}, + [USECASE_AUDIO_PLAYBACK_OFFLOAD2] = {PLAYBACK_OFFLOAD_DEVICE2, PLAYBACK_OFFLOAD_DEVICE2}, +#ifdef MULTIPLE_OFFLOAD_ENABLED [USECASE_AUDIO_PLAYBACK_OFFLOAD3] = {-1, -1}, [USECASE_AUDIO_PLAYBACK_OFFLOAD4] = {-1, -1}, [USECASE_AUDIO_PLAYBACK_OFFLOAD5] = {-1, -1}, @@ -282,8 +282,6 @@ int pcm_device_table[AUDIO_USECASE_MAX][2] = { [USECASE_AUDIO_PLAYBACK_OFFLOAD9] = {-1, -1}, #endif [USECASE_AUDIO_PLAYBACK_ULL] = {MULTIMEDIA3_PCM_DEVICE, MULTIMEDIA3_PCM_DEVICE}, - [USECASE_AUDIO_DIRECT_PCM_OFFLOAD] = - {PLAYBACK_OFFLOAD_DEVICE2, PLAYBACK_OFFLOAD_DEVICE2}, [USECASE_AUDIO_RECORD] = {AUDIO_RECORD_PCM_DEVICE, AUDIO_RECORD_PCM_DEVICE}, [USECASE_AUDIO_RECORD_COMPRESS] = {COMPRESS_CAPTURE_DEVICE, COMPRESS_CAPTURE_DEVICE}, [USECASE_AUDIO_RECORD_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE, @@ -666,8 +664,8 @@ static struct name_to_index usecase_name_index[AUDIO_USECASE_MAX] = { {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_LOW_LATENCY)}, {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_MULTI_CH)}, {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD)}, -#ifdef MULTIPLE_OFFLOAD_ENABLED {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD2)}, +#ifdef MULTIPLE_OFFLOAD_ENABLED {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD3)}, {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD4)}, {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD5)}, @@ -677,7 +675,6 @@ static struct name_to_index usecase_name_index[AUDIO_USECASE_MAX] = { {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD9)}, #endif {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_ULL)}, - {TO_NAME_INDEX(USECASE_AUDIO_DIRECT_PCM_OFFLOAD)}, {TO_NAME_INDEX(USECASE_AUDIO_RECORD)}, {TO_NAME_INDEX(USECASE_AUDIO_RECORD_LOW_LATENCY)}, {TO_NAME_INDEX(USECASE_VOICE_CALL)}, @@ -2051,11 +2048,12 @@ int platform_get_snd_device_bit_width(snd_device_t snd_device) int platform_set_native_support(bool codec_support) { - na_props.platform_na_prop_enabled = na_props.ui_na_prop_enabled + int ret = -1; + ret = na_props.platform_na_prop_enabled = na_props.ui_na_prop_enabled = codec_support; ALOGV("%s: na_props.platform_na_prop_enabled: %d", __func__, na_props.platform_na_prop_enabled); - return 0; + return ret; } int platform_get_native_support() @@ -3673,7 +3671,6 @@ bool platform_listen_usecase_needs_event(audio_usecase_t uc_id) case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER: case USECASE_AUDIO_PLAYBACK_MULTI_CH: case USECASE_AUDIO_PLAYBACK_OFFLOAD: - case USECASE_AUDIO_DIRECT_PCM_OFFLOAD: needs_event = true; break; /* concurrent playback in low latency allowed */ @@ -3737,7 +3734,6 @@ bool platform_sound_trigger_usecase_needs_event(audio_usecase_t uc_id) case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER: case USECASE_AUDIO_PLAYBACK_MULTI_CH: case USECASE_AUDIO_PLAYBACK_OFFLOAD: - case USECASE_AUDIO_DIRECT_PCM_OFFLOAD: needs_event = true; break; /* concurrent playback in low latency allowed */ @@ -3932,6 +3928,8 @@ int platform_set_codec_backend_cfg(struct audio_device* adev, * 24 bit playback - 48khz for stream sample rate less than 48khz * 24 bit playback - 96khz for sample rate range of 48khz to 96khz * 24 bit playback - 192khz for sample rate range of 96khz to 192 khz + * native support is present: 16/24 bit 44.1Khz clip uses backend at 44.1Khz + * native support is not present: 44.1Khz clips uses backend at 48Khz * Upper limit is inclusive in the sample rate range. */ // TODO: This has to be more dynamic based on policy file @@ -4068,6 +4066,10 @@ bool platform_check_codec_backend_cfg(struct audio_device* adev, bit_width = (uint32_t)platform_get_snd_device_bit_width(SND_DEVICE_OUT_SPEAKER); sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE; } + // 24 bit native clips must be played at 48Khz for non native backend + if ((24 == bit_width) && (OUTPUT_SAMPLING_RATE_44100 == sample_rate)) { + sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE; + } } /* diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c index 66d10f8c..b39586ea 100644 --- a/hal/msm8974/platform.c +++ b/hal/msm8974/platform.c @@ -239,9 +239,9 @@ static int pcm_device_table[AUDIO_USECASE_MAX][2] = { MULTIMEDIA2_PCM_DEVICE}, [USECASE_AUDIO_PLAYBACK_OFFLOAD] = {PLAYBACK_OFFLOAD_DEVICE, PLAYBACK_OFFLOAD_DEVICE}, -#ifdef MULTIPLE_OFFLOAD_ENABLED [USECASE_AUDIO_PLAYBACK_OFFLOAD2] = {PLAYBACK_OFFLOAD_DEVICE2, PLAYBACK_OFFLOAD_DEVICE2}, +#ifdef MULTIPLE_OFFLOAD_ENABLED [USECASE_AUDIO_PLAYBACK_OFFLOAD3] = {PLAYBACK_OFFLOAD_DEVICE3, PLAYBACK_OFFLOAD_DEVICE3}, [USECASE_AUDIO_PLAYBACK_OFFLOAD4] = @@ -260,8 +260,6 @@ static int pcm_device_table[AUDIO_USECASE_MAX][2] = { [USECASE_AUDIO_PLAYBACK_ULL] = {MULTIMEDIA3_PCM_DEVICE, MULTIMEDIA3_PCM_DEVICE}, - [USECASE_AUDIO_DIRECT_PCM_OFFLOAD] = - {PLAYBACK_OFFLOAD_DEVICE2, PLAYBACK_OFFLOAD_DEVICE2}, [USECASE_AUDIO_RECORD] = {AUDIO_RECORD_PCM_DEVICE, AUDIO_RECORD_PCM_DEVICE}, [USECASE_AUDIO_RECORD_COMPRESS] = {COMPRESS_CAPTURE_DEVICE, COMPRESS_CAPTURE_DEVICE}, @@ -604,8 +602,8 @@ static struct name_to_index usecase_name_index[AUDIO_USECASE_MAX] = { {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_LOW_LATENCY)}, {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_MULTI_CH)}, {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD)}, -#ifdef MULTIPLE_OFFLOAD_ENABLED {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD2)}, +#ifdef MULTIPLE_OFFLOAD_ENABLED {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD3)}, {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD4)}, {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD5)}, @@ -615,7 +613,6 @@ static struct name_to_index usecase_name_index[AUDIO_USECASE_MAX] = { {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD9)}, #endif {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_ULL)}, - {TO_NAME_INDEX(USECASE_AUDIO_DIRECT_PCM_OFFLOAD)}, {TO_NAME_INDEX(USECASE_AUDIO_RECORD)}, {TO_NAME_INDEX(USECASE_AUDIO_RECORD_LOW_LATENCY)}, {TO_NAME_INDEX(USECASE_VOICE_CALL)}, @@ -1670,11 +1667,12 @@ int platform_get_snd_device_bit_width(snd_device_t snd_device) int platform_set_native_support(bool codec_support) { - na_props.platform_na_prop_enabled = na_props.ui_na_prop_enabled + int ret = -1; + ret = na_props.platform_na_prop_enabled = na_props.ui_na_prop_enabled = codec_support; ALOGD("%s: na_props.platform_na_prop_enabled: %d", __func__, na_props.platform_na_prop_enabled); - return 0; + return ret; } int platform_get_native_support() @@ -3374,6 +3372,8 @@ int platform_set_codec_backend_cfg(struct audio_device* adev, * 24 bit playback - 48khz for stream sample rate less than 48khz * 24 bit playback - 96khz for sample rate range of 48khz to 96khz * 24 bit playback - 192khz for sample rate range of 96khz to 192 khz + * native support is present: 16/24 bit 44.1Khz clip uses backend at 44.1Khz + * native support is not present: 44.1Khz clips uses backend at 48Khz * Upper limit is inclusive in the sample rate range. */ if (sample_rate != @@ -3519,6 +3519,10 @@ bool platform_check_codec_backend_cfg(struct audio_device* adev, bit_width = (uint32_t)platform_get_snd_device_bit_width(SND_DEVICE_OUT_SPEAKER); sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE; } + // 24 bit native clips must be played at 48Khz for non native backend + if ((24 == bit_width) && (OUTPUT_SAMPLING_RATE_44100 == sample_rate)) { + sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE; + } } ALOGI("%s Codec selected backend: %d updated bit width: %d and sample rate: %d", __func__, backend_idx, bit_width, sample_rate); diff --git a/hal/msm8974/platform.h b/hal/msm8974/platform.h index fdf34003..3e6f5bda 100644 --- a/hal/msm8974/platform.h +++ b/hal/msm8974/platform.h @@ -242,9 +242,13 @@ enum { #endif #define PLAYBACK_OFFLOAD_DEVICE 9 +// Direct_PCM +#if defined (PLATFORM_MSM8994) || defined (PLATFORM_MSM8996) || defined (PLATFORM_APQ8084) +#define PLAYBACK_OFFLOAD_DEVICE2 17 +#endif + #ifdef MULTIPLE_OFFLOAD_ENABLED #ifdef PLATFORM_APQ8084 -#define PLAYBACK_OFFLOAD_DEVICE2 17 #define PLAYBACK_OFFLOAD_DEVICE3 18 #define PLAYBACK_OFFLOAD_DEVICE4 34 #define PLAYBACK_OFFLOAD_DEVICE5 35 @@ -254,7 +258,6 @@ enum { #define PLAYBACK_OFFLOAD_DEVICE9 39 #endif #if defined (PLATFORM_MSM8994) || defined (PLATFORM_MSM8996) -#define PLAYBACK_OFFLOAD_DEVICE2 17 #define PLAYBACK_OFFLOAD_DEVICE3 18 #define PLAYBACK_OFFLOAD_DEVICE4 37 #define PLAYBACK_OFFLOAD_DEVICE5 38 @@ -265,9 +268,6 @@ enum { #endif #endif -// for DIRECT_PCM -#define PLAYBACK_OFFLOAD_DEVICE2 17 - #define COMPRESS_VOIP_CALL_PCM_DEVICE 3 #ifdef PLATFORM_MSM8610 diff --git a/hal/platform_info.c b/hal/platform_info.c index 0ed59e24..577208f2 100644 --- a/hal/platform_info.c +++ b/hal/platform_info.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -315,7 +315,7 @@ static void process_native_support(const XML_Char **attr) } if (platform_set_native_support(atoi((char *)attr[3])) < 0) { - ALOGE("%s: NATIVE_AUDIO_44 was not set!", __func__); + ALOGE("%s: native audio support flag couldn't be set!", __func__); goto done; } diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp index 30c26a22..c8ed64fe 100644 --- a/policy_hal/AudioPolicyManager.cpp +++ b/policy_hal/AudioPolicyManager.cpp @@ -1566,18 +1566,18 @@ audio_io_handle_t AudioPolicyManagerCustom::getOutputForDevice( } else if (/* stream == AUDIO_STREAM_MUSIC && */ flags == AUDIO_OUTPUT_FLAG_NONE && property_get_bool("audio.deep_buffer.media", false /* default_value */)) { - flags = (audio_output_flags_t)(AUDIO_OUTPUT_FLAG_DEEP_BUFFER); - forced_deep = true; + forced_deep = true; } if (stream == AUDIO_STREAM_TTS) { flags = AUDIO_OUTPUT_FLAG_TTS; } // Do offload magic here - if (((flags == AUDIO_OUTPUT_FLAG_NONE) || forced_deep) && - (stream == AUDIO_STREAM_MUSIC) && (offloadInfo != NULL) && + if ((flags == AUDIO_OUTPUT_FLAG_NONE) && + (stream == AUDIO_STREAM_MUSIC) && + (offloadInfo != NULL) && ((offloadInfo->usage == AUDIO_USAGE_MEDIA) || (offloadInfo->usage == AUDIO_USAGE_GAME))) { - flags = (audio_output_flags_t)(flags|AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_DIRECT_PCM); + flags = (audio_output_flags_t)(AUDIO_OUTPUT_FLAG_DIRECT_PCM); ALOGD("AudioCustomHAL --> Force Direct Flag .. flag (0x%x)", flags); } @@ -1585,7 +1585,7 @@ audio_io_handle_t AudioPolicyManagerCustom::getOutputForDevice( // skip direct output selection if the request can obviously be attached to a mixed output // and not explicitly requested - if (((flags & AUDIO_OUTPUT_FLAG_DIRECT) == 0) && + if (((flags & (AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_DIRECT_PCM)) == 0) && audio_is_linear_pcm(format) && samplingRate <= MAX_MIXER_SAMPLING_RATE && audio_channel_count_from_out_mask(channelMask) <= 2) { goto non_direct_output; @@ -1598,7 +1598,7 @@ audio_io_handle_t AudioPolicyManagerCustom::getOutputForDevice( // This may prevent offloading in rare situations where effects are left active by apps // in the background. - if (((flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) == 0) || + if (((flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) == 0) && !mEffects.isNonOffloadableEffectEnabled()) { profile = getProfileForDirectOutput(device, samplingRate, @@ -1608,6 +1608,14 @@ audio_io_handle_t AudioPolicyManagerCustom::getOutputForDevice( } if (profile != 0) { + + if (!(flags & AUDIO_OUTPUT_FLAG_DIRECT_PCM) && + (profile->mFlags & AUDIO_OUTPUT_FLAG_DIRECT_PCM)) { + ALOGI("got Direct_PCM without requesting ... reject "); + profile = NULL; + goto non_direct_output; + } + sp<SwAudioOutputDescriptor> outputDesc = NULL; for (size_t i = 0; i < mOutputs.size(); i++) { @@ -1724,6 +1732,10 @@ non_direct_output: // for non direct outputs, only PCM is supported if (audio_is_linear_pcm(format)) { + if (forced_deep) { + flags = (audio_output_flags_t)(AUDIO_OUTPUT_FLAG_DEEP_BUFFER); + ALOGI("setting force DEEP buffer now "); + } // get which output is suitable for the specified stream. The actual // routing change will happen when startOutput() will be called SortedVector<audio_io_handle_t> outputs = getOutputsForDevice(device, mOutputs); |