[alsa-devel] Using snd_pcm_set_params() on a capture handle
Clemens Ladisch
clemens at ladisch.de
Sun Oct 25 21:11:26 CET 2015
Erik de Castro Lopo wrote:
> * Is snd_pcm_set_params() supposed to work on capture handles?
Yes.
> * Is my use of snd_pcm_set_params() missing something and if so what?
No. But it does not set exactly the same parameters as the manual
hw_params calls.
Please check for differences with snd_pcm_hw_params_dump() (or look into
/proc/asound/cardX/pcm0c/sub0/hw_params).
> The program can be compiled and run in two ways:
>
> gcc -Wall -O2 -DUSE_SET_PARAMS=1 alsa_capture.c -lasound -o alsa_capture
> ./alsa_capture
>
> which fails with:
>
> Read from audio interface failed (Input/output error)
Which driver? Any messages in the system log?
> if ((err = snd_pcm_prepare (capture_handle)) < 0) {
This is done automatically by snd_pcm_hw_params().
> if ((err = snd_pcm_readi (capture_handle, buffer, buffer_frames)) != buffer_frames) {
If less than the full number of frames have been read, you get a return
value that is not an error code but a positive number.
Regards,
Clemens
More information about the Alsa-devel
mailing list