From 0094c53eba6ae36486136417def4335fe7903c71 Mon Sep 17 00:00:00 2001 From: Maneet Singh Date: Thu, 11 Jun 2015 17:43:01 -0700 Subject: audio: handle audio underruns using silence playback Audio underruns can be handled either by stopping pcm device and preparing it again or by playing silence frames till application fills the buffer again. On average, stopping and preparing pcm device takes 2-4 times more time than just playing silence frames and let the application catch-up. So switching to that approach now. Bug: 20226809 Bug: 20300203 Change-Id: I53a1d32879e594d15fa2b0142852649edb2b5835 --- audio/hal/audio_hw.c | 1 + audio/hal/audio_hw.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/audio/hal/audio_hw.c b/audio/hal/audio_hw.c index 2d70a13..07fe9bb 100644 --- a/audio/hal/audio_hw.c +++ b/audio/hal/audio_hw.c @@ -61,6 +61,7 @@ static struct pcm_device_profile pcm_device_playback = { .start_threshold = PLAYBACK_START_THRESHOLD, .stop_threshold = PLAYBACK_STOP_THRESHOLD, .silence_threshold = 0, + .silence_size = UINT_MAX, .avail_min = PLAYBACK_AVAILABLE_MIN, }, .card = SOUND_CARD, diff --git a/audio/hal/audio_hw.h b/audio/hal/audio_hw.h index 68040ec..96e84c8 100644 --- a/audio/hal/audio_hw.h +++ b/audio/hal/audio_hw.h @@ -137,7 +137,7 @@ enum { #define PLAYBACK_DEFAULT_CHANNEL_COUNT 2 #define PLAYBACK_DEFAULT_SAMPLING_RATE 48000 #define PLAYBACK_START_THRESHOLD ((PLAYBACK_PERIOD_SIZE * PLAYBACK_PERIOD_COUNT) - 1) -#define PLAYBACK_STOP_THRESHOLD (PLAYBACK_PERIOD_SIZE * PLAYBACK_PERIOD_COUNT) +#define PLAYBACK_STOP_THRESHOLD (PLAYBACK_PERIOD_SIZE * (PLAYBACK_PERIOD_COUNT + 2)) #define PLAYBACK_AVAILABLE_MIN 1 -- cgit v1.2.3