From 97b81e321d33009158af481f4807f3970c76aba2 Mon Sep 17 00:00:00 2001 From: Dhananjay Kumar Date: Wed, 15 May 2019 21:00:21 +0530 Subject: [PATCH] hal: fix CTS failures for AudioRecrod test cases Update frames read for inputs streams to report it correctly in get capture position api. Incorrect reporting of frame count was leading to failure for all CTS AudioRecord test cases. Change-Id: I864ed5f1a580fcb65261b5af8a5560392bc8c964 --- hal/audio_hw.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hal/audio_hw.c b/hal/audio_hw.c index 23436035..c2aff9c8 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -6242,7 +6242,7 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer, struct audio_device *adev = in->dev; int ret = -1; - size_t bytes_read = 0; + size_t bytes_read = 0, frame_size = 0; lock_input_stream(in); @@ -6334,6 +6334,10 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer, memset(buffer, 0, bytes); exit: + frame_size = audio_stream_in_frame_size(stream); + if (frame_size > 0) + in->frames_read += bytes_read/frame_size; + if (-ENETRESET == ret) in->card_status = CARD_STATUS_OFFLINE; pthread_mutex_unlock(&in->lock);