summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2009-09-09 14:16:06 +0200
committerTakashi Iwai <tiwai@suse.de>2009-09-09 14:16:06 +0200
commitcd7070bf4b7afcdcd9dbde9d7363781aa3e1b581 (patch)
tree19abc376cef9b618655d54ba37d918b0e06a33f0
parent1f126fd7c6ef37b04ad745609bbebf0dbbf2e1fd (diff)
PCM - Change the hw_params determination order
In snd_pcm_hw_params_choose(), set the buffer size before the period size and time as default. This will give more useful configuration for most of apps, i.e. larger buffer size. For apps that require the old behavior, now the function checks the environment variable $LIBASOUND_COMPAT. If this variable is set to non-empty, the hw_params is determined in the old way, first period then buffer sizes. Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--src/pcm/pcm_params.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/pcm/pcm_params.c b/src/pcm/pcm_params.c
index 80b3fd21..0e1c3fc5 100644
--- a/src/pcm/pcm_params.c
+++ b/src/pcm/pcm_params.c
@@ -1081,6 +1081,7 @@ 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);
@@ -1103,15 +1104,29 @@ static int snd_pcm_hw_params_choose(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
err = snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_RATE, NULL, 0);
if (err < 0)
return err;
- err = snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_PERIOD_TIME, NULL, 0);
- if (err < 0)
- return err;
- err = snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_PERIOD_SIZE, NULL, 0);
- if (err < 0)
- return err;
- err = snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_BUFFER_SIZE, NULL, 0);
- if (err < 0)
- return err;
+ if (compat && *compat) {
+ /* old mode */
+ err = snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_PERIOD_TIME, NULL, 0);
+ if (err < 0)
+ return err;
+ err = snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_PERIOD_SIZE, NULL, 0);
+ if (err < 0)
+ return err;
+ err = snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_BUFFER_SIZE, NULL, 0);
+ if (err < 0)
+ return err;
+ } else {
+ /* determine buffer size first */
+ err = snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_BUFFER_SIZE, NULL, 0);
+ if (err < 0)
+ return err;
+ err = snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_PERIOD_SIZE, NULL, 0);
+ if (err < 0)
+ return err;
+ err = snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_PERIOD_TIME, NULL, 0);
+ if (err < 0)
+ return err;
+ }
err = snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_TICK_TIME, NULL, 0);
if (err < 0)
return err;