From e25fe0b50ea717a9f347dcb927d396e8772e6362 Mon Sep 17 00:00:00 2001 From: Maneet Singh Date: Thu, 11 Jun 2015 17:34:40 -0700 Subject: [PATCH] pcm: add support to set silence_size Tinyalsa always set silence_size to zero. Add support to set this pcm software parameter as required. Bug: 20226809 Bug: 20300203 Change-Id: I25de43623dc04bf5a3ad4c6573bc2b8dad1eec5e --- include/tinyalsa/asoundlib.h | 9 ++++++--- pcm.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/tinyalsa/asoundlib.h b/include/tinyalsa/asoundlib.h index 809e02d..1554b52 100644 --- a/include/tinyalsa/asoundlib.h +++ b/include/tinyalsa/asoundlib.h @@ -93,17 +93,20 @@ struct pcm_config { unsigned int period_count; enum pcm_format format; - /* Values to use for the ALSA start, stop and silence thresholds. Setting - * any one of these values to 0 will cause the default tinyalsa values to be - * used instead. Tinyalsa defaults are as follows. + /* Values to use for the ALSA start, stop and silence thresholds, and + * silence size. Setting any one of these values to 0 will cause the + * default tinyalsa values to be used instead. + * Tinyalsa defaults are as follows. * * start_threshold : period_count * period_size * stop_threshold : period_count * period_size * silence_threshold : 0 + * silence_size : 0 */ unsigned int start_threshold; unsigned int stop_threshold; unsigned int silence_threshold; + unsigned int silence_size; /* Minimum number of frames available before pcm_mmap_write() will actually * write into the kernel buffer. Only used if the stream is opened in mmap mode diff --git a/pcm.c b/pcm.c index d8af58a..e3a41b0 100644 --- a/pcm.c +++ b/pcm.c @@ -953,8 +953,8 @@ struct pcm *pcm_open(unsigned int card, unsigned int device, sparams.avail_min = config->avail_min; sparams.xfer_align = config->period_size / 2; /* needed for old kernels */ - sparams.silence_size = 0; sparams.silence_threshold = config->silence_threshold; + sparams.silence_size = config->silence_size; pcm->boundary = sparams.boundary = pcm->buffer_size; while (pcm->boundary * 2 <= INT_MAX - pcm->buffer_size)