mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-04-07 20:06:01 +00:00
ALSA cap: Init num of channels after rate and fmt
With Hammerfall DSP, snd_pcm_hw_params_set_channels_first() and then setting exact rate and format generated incorrect config.
This commit is contained in:
@@ -313,18 +313,6 @@ static void * audio_cap_alsa_init(const char *cfg)
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Channels count */
|
||||
rc = snd_pcm_hw_params_set_channels(s->handle, params, s->frame.ch_count);
|
||||
if (rc < 0) {
|
||||
if (s->frame.ch_count == 1) { // some devices cannot do mono
|
||||
snd_pcm_hw_params_set_channels_first(s->handle, params, &s->min_device_channels);
|
||||
} else {
|
||||
fprintf(stderr, MOD_NAME "unable to set channel count: %s\n",
|
||||
snd_strerror(rc));
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
/* we want to resample if device doesn't support default sample rate */
|
||||
val = 1;
|
||||
rc = snd_pcm_hw_params_set_rate_resample(s->handle,
|
||||
@@ -346,6 +334,18 @@ static void * audio_cap_alsa_init(const char *cfg)
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Channels count */
|
||||
rc = snd_pcm_hw_params_set_channels(s->handle, params, s->frame.ch_count);
|
||||
if (rc < 0) {
|
||||
if (s->frame.ch_count == 1) { // some devices cannot do mono
|
||||
snd_pcm_hw_params_set_channels_first(s->handle, params, &s->min_device_channels);
|
||||
} else {
|
||||
fprintf(stderr, MOD_NAME "unable to set channel count: %s\n",
|
||||
snd_strerror(rc));
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
/* This must be set after setting of sample rate for Chat 150 which increases
|
||||
* value to 1024. But if this setting precedes, setting sample rate of 48000
|
||||
* fails (1024 period) or does not work properly (128).
|
||||
|
||||
Reference in New Issue
Block a user