mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-12-23 02:56:30 +01:00
Cleaned all hw_info. Removed snd_pcm_hw_{info,params}_rules* and changed strategy to allow the same functionality. Cleaned names tables. Added informative failure
This commit is contained in:
parent
fc9fc225f3
commit
c3348ac9dd
1 changed files with 33 additions and 12 deletions
|
@ -647,21 +647,42 @@ static int test_au(int fd, void *buffer)
|
||||||
|
|
||||||
static void set_params(void)
|
static void set_params(void)
|
||||||
{
|
{
|
||||||
|
snd_pcm_hw_info_t info;
|
||||||
|
snd_pcm_strategy_t *strategy;
|
||||||
|
int err;
|
||||||
|
snd_pcm_hw_info_any(&info);
|
||||||
if (mmap_flag)
|
if (mmap_flag)
|
||||||
hwparams.access = SND_PCM_ACCBIT_MMAP;
|
info.access_mask = SND_PCM_ACCBIT_MMAP;
|
||||||
else if (interleaved)
|
else if (interleaved)
|
||||||
hwparams.access = SND_PCM_ACCBIT_RW_INTERLEAVED;
|
info.access_mask = SND_PCM_ACCBIT_RW_INTERLEAVED;
|
||||||
else
|
else
|
||||||
hwparams.access = SND_PCM_ACCBIT_RW_NONINTERLEAVED;
|
info.access_mask = SND_PCM_ACCBIT_RW_NONINTERLEAVED;
|
||||||
hwparams.subformat = 0;
|
info.format_mask = 1 << hwparams.format;
|
||||||
hwparams.fragment_size = hwparams.rate * frag_length / 1000;
|
info.channels_min = info.channels_max = hwparams.channels;
|
||||||
hwparams.fragments = hwparams.rate * buffer_length / 1000;
|
info.fragments_min = 2;
|
||||||
hwparams.fragments /= hwparams.fragment_size;
|
err = snd_pcm_strategy_simple(&strategy, 0, 1000000);
|
||||||
if (snd_pcm_hw_params_rulesv(handle, &hwparams,
|
assert(err >= 0);
|
||||||
SND_PCM_RULE_REL_BITS | SND_PCM_HW_PARAM_ACCESS,
|
err = snd_pcm_strategy_simple_near(strategy, 0, SND_PCM_HW_PARAM_RATE,
|
||||||
SND_PCM_RULE_REL_NEAR | SND_PCM_HW_PARAM_FRAGMENT_SIZE,
|
hwparams.rate, 10);
|
||||||
SND_PCM_RULE_REL_NEAR | SND_PCM_HW_PARAM_FRAGMENTS,
|
assert(err >= 0);
|
||||||
-1) < 0) {
|
err = snd_pcm_strategy_simple_near(strategy, 0, SND_PCM_HW_PARAM_FRAGMENT_SIZE,
|
||||||
|
hwparams.rate * frag_length / 1000, 1);
|
||||||
|
assert(err >= 0);
|
||||||
|
err = snd_pcm_strategy_simple_near(strategy, 0, SND_PCM_HW_PARAM_BUFFER_SIZE,
|
||||||
|
hwparams.rate * buffer_length / 1000, 1);
|
||||||
|
assert(err >= 0);
|
||||||
|
err = snd_pcm_hw_info_strategy(handle, &info, strategy);
|
||||||
|
snd_pcm_strategy_free(strategy);
|
||||||
|
if (err < 0) {
|
||||||
|
fprintf(stderr, "Unable to find params combination:\n");
|
||||||
|
err = snd_pcm_hw_info_try_explain_failure(handle, &info, NULL, 2, stderr);
|
||||||
|
if (err < 0) {
|
||||||
|
fprintf(stderr, "No explaination found for this failure\n");
|
||||||
|
}
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
err = snd_pcm_hw_params_info(handle, &hwparams, &info);
|
||||||
|
if (err < 0) {
|
||||||
snd_pcm_dump_hw_params_fail(&hwparams, stderr);
|
snd_pcm_dump_hw_params_fail(&hwparams, stderr);
|
||||||
error("unable to set hw params");
|
error("unable to set hw params");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
Loading…
Reference in a new issue