Merge "hal: add audio specific config files for kona"
diff --git a/hal/audio_extn/battery_listener.cpp b/hal/audio_extn/battery_listener.cpp
index 582e9e6..5f19443 100644
--- a/hal/audio_extn/battery_listener.cpp
+++ b/hal/audio_extn/battery_listener.cpp
@@ -140,6 +140,7 @@
if (mStatusnot_ncharging()) // i.e event changed
break;
}
+ [[fallthrough]];
default:
bool c = statusToBool(local_status);
ALOGI("healthInfo cb thread: cb %s", c ? "CHARGING" : "NOT CHARGING");
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 5c7fc9c..99c291c 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -2565,6 +2565,14 @@
in->pcm = pcm_open(adev->snd_card, in->pcm_device_id,
flags, &config);
ATRACE_END();
+ if (errno == ENETRESET && !pcm_is_ready(in->pcm)) {
+ ALOGE("%s: pcm_open failed errno:%d\n", __func__, errno);
+ adev->card_status = CARD_STATUS_OFFLINE;
+ in->card_status = CARD_STATUS_OFFLINE;
+ ret = -EIO;
+ goto error_open;
+ }
+
if (in->pcm == NULL || !pcm_is_ready(in->pcm)) {
ALOGE("%s: %s", __func__, pcm_get_error(in->pcm));
if (in->pcm != NULL) {
@@ -3195,6 +3203,14 @@
out->pcm = pcm_open(adev->snd_card, out->pcm_device_id,
flags, &out->config);
ATRACE_END();
+ if (errno == ENETRESET && !pcm_is_ready(out->pcm)) {
+ ALOGE("%s: pcm_open failed errno:%d\n", __func__, errno);
+ out->card_status = CARD_STATUS_OFFLINE;
+ adev->card_status = CARD_STATUS_OFFLINE;
+ ret = -EIO;
+ goto error_open;
+ }
+
if (out->pcm == NULL || !pcm_is_ready(out->pcm)) {
ALOGE("%s: %s", __func__, pcm_get_error(out->pcm));
if (out->pcm != NULL) {
@@ -3240,6 +3256,14 @@
out->pcm_device_id,
COMPRESS_IN, &out->compr_config);
ATRACE_END();
+ if (errno == ENETRESET && !is_compress_ready(out->compr)) {
+ ALOGE("%s: compress_open failed errno:%d\n", __func__, errno);
+ adev->card_status = CARD_STATUS_OFFLINE;
+ out->card_status = CARD_STATUS_OFFLINE;
+ ret = -EIO;
+ goto error_open;
+ }
+
if (out->compr && !is_compress_ready(out->compr)) {
ALOGE("%s: failed /w error %s", __func__, compress_get_error(out->compr));
compress_close(out->compr);
@@ -5191,8 +5215,15 @@
uint32_t buffer_size;
ALOGD("%s", __func__);
+ lock_output_stream(out);
pthread_mutex_lock(&adev->lock);
+ if (CARD_STATUS_OFFLINE == out->card_status ||
+ CARD_STATUS_OFFLINE == adev->card_status) {
+ ALOGW("out->card_status or adev->card_status offline, try again");
+ ret = -EIO;
+ goto exit;
+ }
if (info == NULL || min_size_frames == 0) {
ALOGE("%s: info = %p, min_size_frames = %d", __func__, info, min_size_frames);
ret = -EINVAL;
@@ -5217,6 +5248,14 @@
__func__, adev->snd_card, out->pcm_device_id, out->config.channels);
out->pcm = pcm_open(adev->snd_card, out->pcm_device_id,
(PCM_OUT | PCM_MMAP | PCM_NOIRQ | PCM_MONOTONIC), &out->config);
+ if (errno == ENETRESET && !pcm_is_ready(out->pcm)) {
+ ALOGE("%s: pcm_open failed errno:%d\n", __func__, errno);
+ out->card_status = CARD_STATUS_OFFLINE;
+ adev->card_status = CARD_STATUS_OFFLINE;
+ ret = -EIO;
+ goto exit;
+ }
+
if (out->pcm == NULL || !pcm_is_ready(out->pcm)) {
step = "open";
ret = -ENODEV;
@@ -5270,6 +5309,7 @@
}
}
pthread_mutex_unlock(&adev->lock);
+ pthread_mutex_unlock(&out->lock);
return ret;
}
@@ -5807,6 +5847,13 @@
pthread_mutex_lock(&adev->lock);
ALOGV("%s in %p", __func__, in);
+ if (CARD_STATUS_OFFLINE == in->card_status||
+ CARD_STATUS_OFFLINE == adev->card_status) {
+ ALOGW("in->card_status or adev->card_status offline, try again");
+ ret = -EIO;
+ goto exit;
+ }
+
if (info == NULL || min_size_frames == 0) {
ALOGE("%s invalid argument info %p min_size_frames %d", __func__, info, min_size_frames);
ret = -EINVAL;
@@ -5832,6 +5879,14 @@
__func__, adev->snd_card, in->pcm_device_id, in->config.channels);
in->pcm = pcm_open(adev->snd_card, in->pcm_device_id,
(PCM_IN | PCM_MMAP | PCM_NOIRQ | PCM_MONOTONIC), &in->config);
+ if (errno == ENETRESET && !pcm_is_ready(in->pcm)) {
+ ALOGE("%s: pcm_open failed errno:%d\n", __func__, errno);
+ in->card_status = CARD_STATUS_OFFLINE;
+ adev->card_status = CARD_STATUS_OFFLINE;
+ ret = -EIO;
+ goto exit;
+ }
+
if (in->pcm == NULL || !pcm_is_ready(in->pcm)) {
step = "open";
ret = -ENODEV;
diff --git a/hal/voice_extn/compress_voip.c b/hal/voice_extn/compress_voip.c
index 2736d68..890f508 100644
--- a/hal/voice_extn/compress_voip.c
+++ b/hal/voice_extn/compress_voip.c
@@ -255,6 +255,7 @@
int ret = 0;
struct audio_usecase *uc_info;
struct listnode *node;
+ struct stream_out *out = NULL;
ALOGD("%s: enter, out_stream_count=%d, in_stream_count=%d",
__func__, voip_data.out_stream_count, voip_data.in_stream_count);
@@ -292,6 +293,15 @@
// restore device for other active usecases
list_for_each(node, &adev->usecase_list) {
uc_info = node_to_item(node, struct audio_usecase, list);
+ out = uc_info->stream.out;
+ if (out && adev->adm_register_output_stream
+ && adev->adm_on_routing_change) {
+ adev->adm_register_output_stream(adev->adm_data,
+ out->handle,
+ out->flags);
+ adev->adm_on_routing_change(adev->adm_data,
+ out->handle);
+ }
select_devices(adev, uc_info->id);
}
} else {