mirror of
https://github.com/openharmony/third_party_tinyalsa.git
synced 2026-07-19 15:24:22 -04:00
pcm: add control for ASLA thresholds to pcm_open
Add the ability to explicitly set start, stop and silence thresholds during tinyalsa's pcm_open. Setting any of these values to 0 in your pcm_config structure will cause the system to use its old defaults.
This commit is contained in:
committed by
Simon Wilson
parent
ee99f213b2
commit
3bb114a645
@@ -59,6 +59,18 @@ struct pcm_config {
|
||||
unsigned int period_size;
|
||||
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.
|
||||
*
|
||||
* start_threshold : period_count * period_size
|
||||
* stop_threshold : period_count * period_size
|
||||
* silence_threshold : 0
|
||||
*/
|
||||
unsigned int start_threshold;
|
||||
unsigned int stop_threshold;
|
||||
unsigned int silence_threshold;
|
||||
};
|
||||
|
||||
/* Mixer control types */
|
||||
|
||||
@@ -427,11 +427,21 @@ struct pcm *pcm_open(unsigned int card, unsigned int device,
|
||||
sparams.tstamp_mode = SNDRV_PCM_TSTAMP_ENABLE;
|
||||
sparams.period_step = 1;
|
||||
sparams.avail_min = 1;
|
||||
sparams.start_threshold = config->period_count * config->period_size;
|
||||
sparams.stop_threshold = config->period_count * config->period_size;
|
||||
|
||||
if (!config->start_threshold)
|
||||
sparams.start_threshold = config->period_count * config->period_size;
|
||||
else
|
||||
sparams.start_threshold = config->start_threshold;
|
||||
|
||||
if (!config->stop_threshold)
|
||||
sparams.stop_threshold = config->period_count * config->period_size;
|
||||
else
|
||||
sparams.stop_threshold = config->stop_threshold;
|
||||
|
||||
sparams.xfer_align = config->period_size / 2; /* needed for old kernels */
|
||||
sparams.silence_size = 0;
|
||||
sparams.silence_threshold = 0;
|
||||
sparams.silence_threshold = config->silence_threshold;
|
||||
|
||||
|
||||
if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_SW_PARAMS, &sparams)) {
|
||||
oops(pcm, errno, "cannot set sw params");
|
||||
|
||||
Reference in New Issue
Block a user