[alsa-devel] Using snd_pcm_set_params() on a capture handle

Erik de Castro Lopo mle+la at mega-nerd.com
Mon Oct 26 09:47:01 CET 2015


Clemens Ladisch wrote:

> > * 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()

That showed some differences. The params when its working:

    ACCESS:  RW_INTERLEAVED
    FORMAT:  S32_LE
    SUBFORMAT:  STD
    SAMPLE_BITS: 32
    FRAME_BITS: 64
    CHANNELS: 2
    RATE: 44100
    PERIOD_TIME: (5011 5012)
    PERIOD_SIZE: 221
    PERIOD_BYTES: 1768
    PERIODS: (593 594)
    BUFFER_TIME: (2972154 2972155)
    BUFFER_SIZE: 131072
    BUFFER_BYTES: 1048576
    TICK_TIME: 0

and the one that doesn't:

    ACCESS:  MMAP_INTERLEAVED RW_INTERLEAVED
    FORMAT:  S32_LE
    SUBFORMAT:  STD
    SAMPLE_BITS: 32
    FRAME_BITS: 64
    CHANNELS: 2
    RATE: [44100 96000]
    PERIOD_TIME: [125 1486078)
    PERIOD_SIZE: [8 65536]
    PERIOD_BYTES: [64 524288]
    PERIODS: [2 1024]
    BUFFER_TIME: (166 2972155)
    BUFFER_SIZE: [16 131072]
    BUFFER_BYTES: [128 1048576]
    TICK_TIME: ALL

which seems rather odd!

> Which driver? 

snd_usb_audio

> Any messages in the system log?

Just the connect message when the device is plugged in:

    usb 1-1: new high-speed USB device number 43 using xhci_hcd
    usb 1-1: New USB device found, idVendor=1235, idProduct=8016
    usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
    usb 1-1: Product: Scarlett 2i2 USB
    usb 1-1: Manufacturer: Focusrite


> 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.

Its definitely an error message. I changed the code to:


    if ((err = snd_pcm_readi (capture_handle, buffer, buffer_frames)) < 0) {
        printf ("Read from audio interface failed (%d, %s)\n", err, snd_strerror (err));
        break;
    }

and that results in:

    Read from audio interface failed (-5, Input/output error)

Cheers,
Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/


More information about the Alsa-devel mailing list