Merge "audio: hal: fix power issue if tfa98xx calibration failed am: 32847effc9 am: 7bf8526a38" into nyc-mr2-dev-plus-aosp
am: 79d550b4d4
Change-Id: Idb0264e7cfe94fb77551308fde0d9b83e9295705
diff --git a/hal/Android.mk b/hal/Android.mk
index f3d2798..c2801db 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -152,6 +152,8 @@
LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS += -Werror
+
include $(BUILD_SHARED_LIBRARY)
endif
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 0a5bccb..faa27db 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -2200,39 +2200,18 @@
#ifdef NO_AUDIO_OUT
static ssize_t out_write_for_no_output(struct audio_stream_out *stream,
- const void *buffer, size_t bytes)
+ const void *buffer __unused, size_t bytes)
{
struct stream_out *out = (struct stream_out *)stream;
- struct timespec t = { .tv_sec = 0, .tv_nsec = 0 };
- int64_t now;
- int64_t elapsed_time_since_last_write = 0;
- int64_t sleep_time;
- clock_gettime(CLOCK_MONOTONIC, &t);
- now = (t.tv_sec * 1000000000LL + t.tv_nsec) / 1000;
-
+ /* No Output device supported other than BT for playback.
+ * Sleep for the amount of buffer duration
+ */
lock_output_stream(out);
- if (out->last_write_time_us)
- elapsed_time_since_last_write = now - out->last_write_time_us;
- sleep_time = bytes * 1000000LL / audio_stream_out_frame_size(stream) /
- out_get_sample_rate(&stream->common) - elapsed_time_since_last_write;
- if (sleep_time > 0) {
- usleep(sleep_time);
- } else {
- // we don't sleep when we exit standby (this is typical for a real alsa buffer).
- sleep_time = 0;
- }
- out->last_write_time_us = now + sleep_time;
+ usleep(bytes * 1000000 / audio_stream_out_frame_size(
+ (const struct audio_stream_out *)&out->stream) /
+ out_get_sample_rate(&out->stream.common));
pthread_mutex_unlock(&out->lock);
- // last_write_time_us is an approximation of when the (simulated) alsa
- // buffer is believed completely full. The usleep above waits for more space
- // in the buffer, but by the end of the sleep the buffer is considered
- // topped-off.
- //
- // On the subsequent out_write(), we measure the elapsed time spent in
- // the mixer. This is subtracted from the sleep estimate based on frames,
- // thereby accounting for drain in the alsa buffer during mixing.
- // This is a crude approximation; we don't handle underruns precisely.
return bytes;
}
#endif
@@ -2264,7 +2243,7 @@
}
if (out->usecase == USECASE_AUDIO_PLAYBACK_OFFLOAD) {
- ALOGVV("%s: writing buffer (%d bytes) to compress device", __func__, bytes);
+ ALOGVV("%s: writing buffer (%zu bytes) to compress device", __func__, bytes);
if (out->send_new_metadata) {
ALOGVV("send new gapless metadata");
compress_set_gapless_metadata(out->compr, &out->gapless_mdata);
@@ -2307,7 +2286,7 @@
if (out->muted)
memset((void *)buffer, 0, bytes);
- ALOGVV("%s: writing buffer (%d bytes) to pcm device", __func__, bytes);
+ ALOGVV("%s: writing buffer (%zu bytes) to pcm device", __func__, bytes);
long ns = pcm_bytes_to_frames(out->pcm, bytes)*1000000000LL/
out->config.rate;
@@ -2699,7 +2678,7 @@
lock_input_stream(in);
if (in->is_st_session) {
- ALOGVV(" %s: reading on st session bytes=%d", __func__, bytes);
+ ALOGVV(" %s: reading on st session bytes=%zu", __func__, bytes);
/* Read from sound trigger HAL */
audio_extn_sound_trigger_read(in, buffer, bytes);
pthread_mutex_unlock(&in->lock);
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index 2cf72e1..798d954 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -210,8 +210,6 @@
card_status_t card_status;
struct error_log error_log;
-
- int64_t last_write_time_us;
};
struct stream_in {
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 4995bd8..f7953cc 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -969,7 +969,7 @@
ALOGE("%s: Could not find the symbol acdb_loader_deallocate_ACDB from %s",
__func__, LIB_ACDB_LOADER);
- my_data->acdb_send_audio_cal_v3 = (acdb_send_audio_cal_t)dlsym(my_data->acdb_handle,
+ my_data->acdb_send_audio_cal_v3 = (acdb_send_audio_cal_v3_t)dlsym(my_data->acdb_handle,
"acdb_loader_send_audio_cal_v3");
if (!my_data->acdb_send_audio_cal_v3)
ALOGE("%s: Could not find the symbol acdb_send_audio_cal from %s",
@@ -1073,7 +1073,7 @@
{
struct platform_data *my_data = (struct platform_data *)platform;
- if (platform == NULL || device_name == NULL) {
+ if (platform == NULL) {
ALOGW("%s: something wrong, use legacy get_snd_device name", __func__);
strlcpy(device_name, platform_get_snd_device_name(snd_device),
DEVICE_NAME_MAX_SIZE);
@@ -1095,7 +1095,7 @@
bool platform_check_and_set_capture_backend_cfg(struct audio_device* adev __unused,
struct audio_usecase *usecase __unused,
- snd_device_t snd_device)
+ snd_device_t snd_device __unused)
{
return false;
}
diff --git a/hal/msm8960/platform.c b/hal/msm8960/platform.c
index 7b76df3..eafb64a 100644
--- a/hal/msm8960/platform.c
+++ b/hal/msm8960/platform.c
@@ -1099,7 +1099,8 @@
snd_device_t snd_device,
char *device_name)
{
- device_name = platform_get_snd_device_name(snd_device);
+ strlcpy(device_name, platform_get_snd_device_name(snd_device),
+ DEVICE_NAME_MAX_SIZE);
return 0;
}
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 9d4abec..c5a15cf 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -120,7 +120,7 @@
bool speaker_lr_swap;
void *acdb_handle;
-#if defined (PLATFORM_MSM8994) || (PLATFORM_MSM8996)
+#if defined (PLATFORM_MSM8994) || (PLATFORM_MSM8996) || (PLATFORM_MSM8998)
acdb_init_v2_cvd_t acdb_init;
#elif defined (PLATFORM_MSM8084)
acdb_init_v2_t acdb_init;
@@ -974,7 +974,7 @@
return 0;
}
-#if defined (PLATFORM_MSM8994) || (PLATFORM_MSM8996)
+#if defined (PLATFORM_MSM8994) || (PLATFORM_MSM8996) || (PLATFORM_MSM8998)
char *cvd_version = calloc(1, MAX_CVD_VERSION_STRING_SIZE);
if (!cvd_version)
ALOGE("failed to allocate cvd_version");
@@ -1253,7 +1253,7 @@
ALOGV("%s: Could not find the symbol acdb_loader_send_gain_dep_cal from %s",
__func__, LIB_ACDB_LOADER);
-#if defined (PLATFORM_MSM8994) || (PLATFORM_MSM8996)
+#if defined (PLATFORM_MSM8994) || (PLATFORM_MSM8996) || (PLATFORM_MSM8998)
acdb_init_v2_cvd_t acdb_init;
acdb_init = (acdb_init_v2_cvd_t)dlsym(my_data->acdb_handle,
"acdb_loader_init_v2");
@@ -1366,9 +1366,10 @@
{
struct platform_data *my_data = (struct platform_data *)platform;
- if (platform == NULL || device_name == NULL) {
+ if (platform == NULL) {
ALOGW("%s: something wrong, use legacy get_snd_device name", __func__);
- device_name = platform_get_snd_device_name(snd_device);
+ strlcpy(device_name, platform_get_snd_device_name(snd_device),
+ DEVICE_NAME_MAX_SIZE);
} else if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) {
if (operator_specific_device_table[snd_device] != NULL) {
strlcpy(device_name, get_operator_specific_device_mixer_path(snd_device),
@@ -1527,8 +1528,8 @@
return ret;
}
-int platform_get_default_app_type_v2(void *platform, usecase_type_t type __unused,
- int *app_type)
+int platform_get_default_app_type_v2(void *platform __unused, usecase_type_t type __unused,
+ int *app_type __unused)
{
ALOGE("%s: Not implemented", __func__);
return -ENOSYS;
@@ -2160,10 +2161,10 @@
} else if ((channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK) &&
(my_data->source_mic_type & SOURCE_DUAL_MIC)) {
snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_STEREO;
- } else if (((int)channel_mask == AUDIO_CHANNEL_INDEX_MASK_3) &&
+ } else if ((channel_mask == AUDIO_CHANNEL_INDEX_MASK_3) &&
(my_data->source_mic_type & SOURCE_THREE_MIC)) {
snd_device = SND_DEVICE_IN_THREE_MIC;
- } else if (((int)channel_mask == AUDIO_CHANNEL_INDEX_MASK_4) &&
+ } else if ((channel_mask == AUDIO_CHANNEL_INDEX_MASK_4) &&
(my_data->source_mic_type & SOURCE_QUAD_MIC)) {
snd_device = SND_DEVICE_IN_QUAD_MIC;
}
@@ -2190,10 +2191,10 @@
(channel_mask == AUDIO_CHANNEL_IN_STEREO)) &&
(my_data->source_mic_type & SOURCE_DUAL_MIC)) {
snd_device = SND_DEVICE_IN_UNPROCESSED_STEREO_MIC;
- } else if (((int)channel_mask == AUDIO_CHANNEL_INDEX_MASK_3) &&
+ } else if ((channel_mask == AUDIO_CHANNEL_INDEX_MASK_3) &&
(my_data->source_mic_type & SOURCE_THREE_MIC)) {
snd_device = SND_DEVICE_IN_UNPROCESSED_THREE_MIC;
- } else if (((int)channel_mask == AUDIO_CHANNEL_INDEX_MASK_4) &&
+ } else if ((channel_mask == AUDIO_CHANNEL_INDEX_MASK_4) &&
(my_data->source_mic_type & SOURCE_QUAD_MIC)) {
snd_device = SND_DEVICE_IN_UNPROCESSED_QUAD_MIC;
} else {
@@ -2281,10 +2282,10 @@
!(in_device & AUDIO_DEVICE_IN_COMMUNICATION)) {
if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
if ((my_data->source_mic_type & SOURCE_QUAD_MIC) &&
- (int)channel_mask == AUDIO_CHANNEL_INDEX_MASK_4) {
+ channel_mask == AUDIO_CHANNEL_INDEX_MASK_4) {
snd_device = SND_DEVICE_IN_QUAD_MIC;
} else if ((my_data->source_mic_type & SOURCE_THREE_MIC) &&
- (int)channel_mask == AUDIO_CHANNEL_INDEX_MASK_3) {
+ channel_mask == AUDIO_CHANNEL_INDEX_MASK_3) {
snd_device = SND_DEVICE_IN_THREE_MIC;
} else if ((my_data->source_mic_type & SOURCE_DUAL_MIC) &&
channel_count == 2) {
@@ -2626,7 +2627,8 @@
}
bool platform_check_and_set_capture_backend_cfg(struct audio_device* adev,
- struct audio_usecase *usecase, snd_device_t snd_device)
+ struct audio_usecase *usecase __unused,
+ snd_device_t snd_device __unused)
{
enum pcm_format in_pcm_format = PCM_FORMAT_S16_LE;
diff --git a/hal/platform_api.h b/hal/platform_api.h
index ebbe9d2..83554b0 100644
--- a/hal/platform_api.h
+++ b/hal/platform_api.h
@@ -28,6 +28,7 @@
};
enum card_status_t;
+struct audio_usecase;
enum usecase_type_t;
void *platform_init(struct audio_device *adev);
diff --git a/post_proc/bundle.c b/post_proc/bundle.c
index df327ab..73b9ae5 100644
--- a/post_proc/bundle.c
+++ b/post_proc/bundle.c
@@ -244,7 +244,7 @@
__attribute__ ((visibility ("default")))
int offload_effects_bundle_hal_stop_output(audio_io_handle_t output, int pcm_id)
{
- int ret;
+ int ret = 0;
struct listnode *node;
struct listnode *fx_node;
output_context_t *out_ctxt;
@@ -750,11 +750,11 @@
__attribute__ ((visibility ("default")))
audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = {
- tag : AUDIO_EFFECT_LIBRARY_TAG,
- version : EFFECT_LIBRARY_API_VERSION,
- name : "Offload Effects Bundle Library",
- implementor : "The Android Open Source Project",
- create_effect : effect_lib_create,
- release_effect : effect_lib_release,
- get_descriptor : effect_lib_get_descriptor,
+ .tag = AUDIO_EFFECT_LIBRARY_TAG,
+ .version = EFFECT_LIBRARY_API_VERSION,
+ .name = "Offload Effects Bundle Library",
+ .implementor = "The Android Open Source Project",
+ .create_effect = effect_lib_create,
+ .release_effect = effect_lib_release,
+ .get_descriptor = effect_lib_get_descriptor,
};
diff --git a/post_proc/equalizer.c b/post_proc/equalizer.c
index 1cd40d2..c3a438f 100644
--- a/post_proc/equalizer.c
+++ b/post_proc/equalizer.c
@@ -183,7 +183,7 @@
int equalizer_get_num_presets(equalizer_context_t *context __unused)
{
- ALOGV("%s: presets_num: %d", __func__,
+ ALOGV("%s: presets_num: %zu", __func__,
sizeof(equalizer_preset_names)/sizeof(char *));
return sizeof(equalizer_preset_names)/sizeof(char *);
}
diff --git a/post_proc/volume_listener.c b/post_proc/volume_listener.c
index 1402ae6..2858e04 100644
--- a/post_proc/volume_listener.c
+++ b/post_proc/volume_listener.c
@@ -366,7 +366,9 @@
ALOGE("%s: EFFECT_CMD_INIT: %s, sending -EINVAL", __func__,
(p_reply_data == NULL) ? "p_reply_data is NULL" :
"*reply_size != sizeof(int)");
- return -EINVAL;
+ android_errorWriteLog(0x534e4554, "32669549");
+ status = -EINVAL;
+ goto exit;
}
*(int *)p_reply_data = 0;
break;
@@ -375,7 +377,9 @@
ALOGV("%s :: cmd called EFFECT_CMD_SET_CONFIG", __func__);
if (p_cmd_data == NULL || cmd_size != sizeof(effect_config_t)
|| p_reply_data == NULL || reply_size == NULL || *reply_size != sizeof(int)) {
- return -EINVAL;
+ android_errorWriteLog(0x534e4554, "32669549");
+ status = -EINVAL;
+ goto exit;
}
context->config = *(effect_config_t *)p_cmd_data;
*(int *)p_reply_data = 0;
@@ -399,7 +403,9 @@
ALOGE("%s: EFFECT_CMD_OFFLOAD: %s, sending -EINVAL", __func__,
(p_reply_data == NULL) ? "p_reply_data is NULL" :
"*reply_size != sizeof(int)");
- return -EINVAL;
+ android_errorWriteLog(0x534e4554, "32669549");
+ status = -EINVAL;
+ goto exit;
}
*(int *)p_reply_data = 0;
break;
diff --git a/visualizer/offload_visualizer.c b/visualizer/offload_visualizer.c
index c56ebff..4d1373f 100644
--- a/visualizer/offload_visualizer.c
+++ b/visualizer/offload_visualizer.c
@@ -81,11 +81,11 @@
effect_ops_t ops;
};
-typedef struct output_context_s {
+struct output_context_s {
struct listnode outputs_list_node; /* node in active_outputs_list */
audio_io_handle_t handle; /* io handle */
struct listnode effects_list; /* list of effects attached to this output */
-} output_context_t;
+};
/* maximum time since last capture buffer update before resetting capture buffer. This means
@@ -427,7 +427,7 @@
__attribute__ ((visibility ("default")))
int visualizer_hal_start_output(audio_io_handle_t output, int pcm_id) {
- int ret;
+ int ret = 0;
struct listnode *node;
ALOGV("%s output %d pcm_id %d", __func__, output, pcm_id);
@@ -473,7 +473,7 @@
__attribute__ ((visibility ("default")))
int visualizer_hal_stop_output(audio_io_handle_t output, int pcm_id) {
- int ret;
+ int ret = 0;
struct listnode *node;
struct listnode *fx_node;
output_context_t *out_ctxt;