From 7de85ac2d9782b7c41fe7c885ced4f19d1e00bdc Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Wed, 29 Jul 2015 15:11:00 +0200 Subject: [PATCH] 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. --- src/audio/capture/alsa.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/audio/capture/alsa.c b/src/audio/capture/alsa.c index 5cfe4201f..5c20ee9b3 100644 --- a/src/audio/capture/alsa.c +++ b/src/audio/capture/alsa.c @@ -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).