From 91186aa81ee4dbb313029d27e40d3d261704d916 Mon Sep 17 00:00:00 2001 From: qidi.huang Date: Wed, 03 Jan 2018 06:43:20 +0000 Subject: Audio: fix Android 8.1 CTS AAudio failure. [1/1] PD# 158018 Let A = sourceFramesNeededWithTimestrech() Let B = mFrameCount = mBufferSize / mFrameSize frameCount = minBufCount * A = (PERIOD_SIZE * PERIOD_COUNT) * A / ((1000 * multiplier * B) / afSampleRate) The value of frameCount is too large so CTS fails, to decrease frameCount, we can decrease (PERIOD_SIZE * PERIOD_COUNT), or increase mBufferSize. Through this way we can pass AAudio CTS test. Change-Id: Iefc2bd682c22e417f3c453d664f9b2a5e3d5aff4 --- diff --git a/audio_hw.c b/audio_hw.c index c1a0a5f..a1485ef 100644 --- a/audio_hw.c +++ b/audio_hw.c @@ -69,15 +69,9 @@ #define PORT_I2S 0 #define PORT_SPDIF 1 #define PORT_PCM 2 -/* number of frames per period */ -#define DEFAULT_PERIOD_SIZE 1024 + #define DEFAULT_CAPTURE_PERIOD_SIZE 1024 -//static unsigned PERIOD_SIZE = DEFAULT_PERIOD_SIZE; static unsigned CAPTURE_PERIOD_SIZE = DEFAULT_CAPTURE_PERIOD_SIZE; -/* number of periods for low power playback */ -#define PLAYBACK_PERIOD_COUNT 4 -/* number of periods for capture */ -#define CAPTURE_PERIOD_COUNT 4 /* minimum sleep time in out_write() when write threshold is not reached */ #define MIN_WRITE_SLEEP_US 5000 @@ -735,7 +729,8 @@ static size_t out_get_buffer_size(const struct audio_stream *stream) if (out->config.rate == 96000) size = PERIOD_SIZE * 2; else - size = PERIOD_SIZE; + // bug_id - 158018, modify size value from PERIOD_SIZE to (PERIOD_SIZE * PLAYBACK_PERIOD_COUNT) + size = PERIOD_SIZE * PLAYBACK_PERIOD_COUNT; } size = ((size + 15) / 16) * 16; return size * audio_stream_out_frame_size((struct audio_stream_out *)stream); -- cgit