Promotion of av-userspace.lnx.1.0-00045.
CRs Change ID Subject
--------------------------------------------------------------------------------------------------------------
968276 Ib0d59b91af053da70a2eb844841d10b39c74bf18 hal: Ensure that stream is not started during Sub system
974913 I43db793dd6d1adede088f7a7c3d86bd39770e2d7 hal: limit AFE and ADM sample rate at 48 for speaker
Change-Id: Ic2b6b3871c32b6afdcad500c38915a2ef038483d
CRs-Fixed: 974913, 968276
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index 6771bf9..8f49b8d 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -622,8 +622,7 @@
__func__, platform_get_default_app_type(adev->platform), acdb_dev_id, sample_rate);
} else if (usecase->type == PCM_PLAYBACK) {
- if ((24 == usecase->stream.out->bit_width) &&
- (usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER)) {
+ if (usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER) {
usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
} else if ((usecase->stream.out->app_type_cfg.sample_rate == OUTPUT_SAMPLING_RATE_44100 &&
!(audio_is_this_native_usecase(usecase))) ||
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index f8b9652..e4b8a37 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1997,7 +1997,7 @@
pthread_mutex_unlock(&adev->lock);
}
pthread_mutex_unlock(&out->lock);
- ALOGV("%s: exit", __func__);
+ ALOGD("%s: exit", __func__);
return 0;
}
@@ -2311,20 +2311,20 @@
lock_output_stream(out);
if (SND_CARD_STATE_OFFLINE == snd_scard_state) {
- // increase written size during SSR to avoid mismatch
- // with the written frames count in AF
- if (!is_offload_usecase(out->usecase))
- out->written += bytes / (out->config.channels * sizeof(short));
- if (out->pcm) {
- ALOGD(" %s: sound card is not active/SSR state", __func__);
- ret= -EIO;
- goto exit;
- } else if (is_offload_usecase(out->usecase)) {
- //during SSR for compress usecase we should return error to flinger
+ if (is_offload_usecase(out->usecase)) {
+ /*during SSR for compress usecase we should return error to flinger*/
ALOGD(" copl %s: sound card is not active/SSR state", __func__);
pthread_mutex_unlock(&out->lock);
return -ENETRESET;
+ } else {
+ /* increase written size during SSR to avoid mismatch
+ * with the written frames count in AF
+ */
+ out->written += bytes / (out->config.channels * sizeof(short));
+ ALOGD(" %s: sound card is not active/SSR state", __func__);
+ ret= -EIO;
+ goto exit;
}
}
@@ -2434,9 +2434,8 @@
out->standby = true;
}
out_standby(&out->stream.common);
- usleep(bytes * 1000000 / audio_stream_out_frame_size(stream) /
+ usleep((uint64_t)bytes * 1000000 / audio_stream_out_frame_size(stream) /
out_get_sample_rate(&out->stream.common));
-
}
return bytes;
}
@@ -2550,11 +2549,13 @@
ret = 0;
}
}
+ } else if (adev->snd_card_status.state == SND_CARD_STATE_OFFLINE) {
+ *frames = out->written;
+ clock_gettime(CLOCK_MONOTONIC, timestamp);
+ ret = 0;
}
}
-
pthread_mutex_unlock(&out->lock);
-
return ret;
}
@@ -2864,7 +2865,7 @@
return bytes;
}
- if (in->pcm && (SND_CARD_STATE_OFFLINE == snd_scard_state)) {
+ if (SND_CARD_STATE_OFFLINE == snd_scard_state) {
ALOGD(" %s: sound card is not active/SSR state", __func__);
ret= -EIO;;
goto exit;
@@ -2930,7 +2931,7 @@
memset(buffer, 0, bytes);
in_standby(&in->stream.common);
ALOGV("%s: read failed status %d- sleeping for buffer duration", __func__, ret);
- usleep(bytes * 1000000 / audio_stream_in_frame_size(stream) /
+ usleep((uint64_t)bytes * 1000000 / audio_stream_in_frame_size(stream) /
in_get_sample_rate(&in->stream.common));
}
return bytes;
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 9cd7928..378ca83 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -4291,16 +4291,15 @@
}
+
/*
- * 24 bit playback on speakers is allowed through 48
- * khz backend only
+ * hifi playback not supported on spkr devices, limit the Sample Rate
+ * to 48 khz.
*/
- if ((24 == bit_width) &&
- (usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER)) {
- bit_width = (uint32_t)platform_get_snd_device_bit_width(SND_DEVICE_OUT_SPEAKER);
+ if (usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER) {
sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
- ALOGD("%s:becf: afe: 24 bit playback on speakers"
- "Configure afe to default Sample Rate(48k)", __func__);
+ ALOGD("%s:becf: afe: playback on speakers Configure afe to \
+ default Sample Rate(48k)", __func__);
}
/*
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index cd53ce4..516179a 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -3893,15 +3893,13 @@
}
/*
- * 24 bit playback on speakers is allowed through 48
- * khz backend only
+ * hifi playback not supported on spkr devices, limit the Sample Rate
+ * to 48 khz.
*/
- if ((24 == bit_width) &&
- (usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER)) {
- bit_width = (uint32_t)platform_get_snd_device_bit_width(SND_DEVICE_OUT_SPEAKER);
+ if (usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER) {
sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
- ALOGD("%s:becf: afe: 24 bit playback on speakers"
- "Configure afe to default Sample Rate(48k)", __func__);
+ ALOGD("%s:becf: afe: playback on speakers Configure afe to \
+ default Sample Rate(48k)", __func__);
}
/*