mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-02 09:01:48 -05:00
pcm: introduce defaults.pcm.compat to change the params choose behaviour
Having getenv directly in the function is not a good idea. Allow configuration of the behaviour change in snd_pcm_param_choose() function using alsa.conf. Use the environment variable LIBASOUND_COMPAT only as fallback. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
09879a4bb5
commit
de606e9c25
4 changed files with 16 additions and 3 deletions
|
|
@ -63,6 +63,7 @@ defaults.pcm.card 0
|
|||
defaults.pcm.device 0
|
||||
defaults.pcm.subdevice -1
|
||||
defaults.pcm.nonblock 1
|
||||
defaults.pcm.compat 0
|
||||
defaults.pcm.minperiodtime 5000 # in us
|
||||
defaults.pcm.ipc_key 5678293
|
||||
defaults.pcm.ipc_gid audio
|
||||
|
|
|
|||
|
|
@ -2192,6 +2192,18 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
|
|||
}
|
||||
}
|
||||
if (err >= 0) {
|
||||
err = snd_config_search(pcm_root, "defaults.pcm.compat", &tmp);
|
||||
if (err >= 0) {
|
||||
long i;
|
||||
if (snd_config_get_integer(tmp, &i) >= 0) {
|
||||
if (i > 0)
|
||||
(*pcmp)->compat = 1;
|
||||
}
|
||||
} else {
|
||||
char *str = getenv("LIBASOUND_COMPAT");
|
||||
if (str && *str)
|
||||
(*pcmp)->compat = 1;
|
||||
}
|
||||
err = snd_config_search(pcm_root, "defaults.pcm.minperiodtime", &tmp);
|
||||
if (err >= 0)
|
||||
snd_config_get_integer(tmp, &(*pcmp)->minperiodtime);
|
||||
|
|
|
|||
|
|
@ -184,7 +184,8 @@ struct _snd_pcm {
|
|||
int poll_fd;
|
||||
unsigned short poll_events;
|
||||
int setup: 1,
|
||||
monotonic: 1;
|
||||
monotonic: 1,
|
||||
compat: 1;
|
||||
snd_pcm_access_t access; /* access mode */
|
||||
snd_pcm_format_t format; /* SND_PCM_FORMAT_* */
|
||||
snd_pcm_subformat_t subformat; /* subformat */
|
||||
|
|
|
|||
|
|
@ -1081,7 +1081,6 @@ int snd_pcm_hw_param_never_eq(const snd_pcm_hw_params_t *params,
|
|||
static int snd_pcm_hw_params_choose(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||
{
|
||||
int err;
|
||||
const char *compat = getenv("LIBASOUND_COMPAT");
|
||||
#ifdef CHOOSE_DEBUG
|
||||
snd_output_t *log;
|
||||
snd_output_stdio_attach(&log, stderr, 0);
|
||||
|
|
@ -1115,7 +1114,7 @@ static int snd_pcm_hw_params_choose(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
|||
snd_pcm_hw_param_set_min(pcm, params, SND_CHANGE, SND_PCM_HW_PARAM_PERIOD_TIME, &min, &dir);
|
||||
}
|
||||
}
|
||||
if (compat && *compat) {
|
||||
if (pcm->compat) {
|
||||
/* old mode */
|
||||
err = snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_PERIOD_TIME, NULL, 0);
|
||||
if (err < 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue