alsa-project / alsa-lib

The Advanced Linux Sound Architecture (ALSA) - library
GNU Lesser General Public License v2.1
370 stars 178 forks source link

ALSA error: snd_pcm_hw_params_set_format failed: Invalid argument. #413

Closed linuxandos2 closed 1 day ago

linuxandos2 commented 3 weeks ago

Playing a flac with a samplerate higer than 96000 with audacious gives:

_ALSA error: snd_pcm_hw_params_setformat failed: Invalid argument.

Output device for audacious is hw:1.0 - USB Audio the device is a soudbaster blasterx G6.

output of cat /proc/asound/card1/stream0

Creative Technology Ltd Sound BlasterX G6 at usb-0000:00:14.0-4.1, high speed : USB Audio

Playback: Status: Stop Interface 1 Altset 1 Format: S24_3LE Channels: 2 Endpoint: 0x01 (1 OUT) (ASYNC) Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000 Data packet interval: 125 us Bits: 24 Channel map: FL FR Sync Endpoint: 0x81 (1 IN) Sync EP Interface: 1 Sync EP Altset: 1 Implicit Feedback Mode: No Interface 1 Altset 2 Format: S32_LE Channels: 2 Endpoint: 0x01 (1 OUT) (ASYNC) Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000 Data packet interval: 125 us Bits: 32 Channel map: FL FR Sync Endpoint: 0x81 (1 IN) Sync EP Interface: 1 Sync EP Altset: 2 Implicit Feedback Mode: No

Capture: Status: Stop Interface 2 Altset 1 Format: S24_3LE Channels: 2 Endpoint: 0x82 (2 IN) (ASYNC) Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000 Data packet interval: 125 us Bits: 24 Channel map: FL FR Interface 2 Altset 2 Format: S32_LE Channels: 2 Endpoint: 0x82 (2 IN) (ASYNC) Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000 Data packet interval: 125 us Bits: 32 Channel map: FL FR

linux: gentoo kernel: 6.9.9-gentoo-x86_64 alsa-lib-1.2.12 alsa-topology-conf-1.2.5.1 alsa-ucm-conf-1.2.12 alsa-plugins-1.2.12 alsa-utils-1.2.12

selecting

pulse - PulseAudio Sound Server

in audacious results in no sound and audacious hangs. Pipewire and wireplumber are used.

On an old gentoo- system on another partition all samplerates play successfully.

kernel: linux-6.8.1-gentoo the versions of alsa are: alsa-lib-1.2.10-r2 alsa-topology-conf-1.2.5.1 alsa-ucm-conf-1.2.10-r1 alsa-plugins-1.2.7.1-r1 alsa-utils-1.2.10-r1

On the new system the 'old' kernel linux-6.8.1-gentoo is also available. Rolled back alsa-lib from alsa-lib-1.2.12 to alsa-lib-1.2.10 and booted kernel kernel linux-6.8.1-gentoo Still same problem.

perexg commented 3 weeks ago

It looks like a kernel driver issue (but maybe not even the sound driver). Try to connect your USB audio device to another USB port (like 2.0 only) on your system. Some USB host drivers have issues with the bandwidth calculation. Also try to reproduce your issue with the aplay or some basic ALSA utility. Like aplay -D hw:0 -f S24_3LE -r 96000 -c 2 /dev/zero . Replace zero in hw:0 with your card number.

linuxandos2 commented 3 weeks ago

The usb port use is no a powered usb3 hub. Tryed on a usb3 port derectly on the system an also on a usb2 port: same results. Now new system is running with the same kernel same .config as the old one where flac's above 192000 samples per second play. Tests with aplay:

96000

marco@localhost ~ $ aplay -D hw:1,0 -c 1 -f S24_3LE -r 96000 -c 2 /dev/zero Playing raw data '/dev/zero' : Signed 24 bit Little Endian in 3bytes, Rate 96000 Hz, Stereo

192000

marco@localhost ~ $ aplay -D hw:1,0 -c 1 -f S24_3LE -r 192000 -c 2 /dev/zero Playing raw data '/dev/zero' : Signed 24 bit Little Endian in 3bytes, Rate 192000 Hz, Stereo aplay: set_params:1456: Unable to install hw params: ACCESS: RW_INTERLEAVED FORMAT: S24_3LE SUBFORMAT: STD SAMPLE_BITS: 24 FRAME_BITS: 48 CHANNELS: 2 RATE: 192000 PERIOD_TIME: 125000 PERIOD_SIZE: 24000 PERIOD_BYTES: 144000 PERIODS: 4 BUFFER_TIME: 500000 BUFFER_SIZE: 96000 BUFFER_BYTES: 576000 TICK_TIME: 0

tiwai commented 3 weeks ago

Make sure that no input stream is running on the same device while you test different parameters for the output. Since the device runs in the implicit feedback mode, the parameters are tied for both input and output.

linuxandos2 commented 3 weeks ago

Yes there is no input stream running, dureing both tests. cat /proc/asound/card1/stream0:

Capture: Status: Stop Interface 2 Altset 1 Format: S24_3LE Channels: 2 Endpoint: 0x82 (2 IN) (ASYNC) Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000 Data packet interval: 125 us Bits: 24 Channel map: FL FR Interface 2 Altset 2 Format: S32_LE Channels: 2 Endpoint: 0x82 (2 IN) (ASYNC) Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000 Data packet interval: 125 us Bits: 32 Channel map: FL FR

tiwai commented 3 weeks ago

Hm, what if you run with plughw instead of hw? Also, try to adjust the buffer and period size, too.

linuxandos2 commented 3 weeks ago

Test with plughw, rate 96000, buffer-size=1000000 ==>OK aplay -D plughw:1,0 -c 1 -f S24_3LE -r 96000 -c 2 --buffer-size=1000000 /dev/zero

Playing raw data '/dev/zero' : Signed 24 bit Little Endian in 3bytes, Rate 96000 Hz, Stereo

Test with plughw, rate 192000, buffer-size=1000000 ==>NOK aplay -D plughw:1,0 -c 1 -f S24_3LE -r 192000 -c 2 --buffer-size=1000000 /dev/zero

Playing raw data '/dev/zero' : Signed 24 bit Little Endian in 3bytes, Rate 192000 Hz, Stereo aplay: set_params:1456: Unable to install hw params: ACCESS: RW_INTERLEAVED FORMAT: S24_3LE SUBFORMAT: STD SAMPLE_BITS: 24 FRAME_BITS: 48 CHANNELS: 2 RATE: 192000 PERIOD_TIME: 1000000 PERIOD_SIZE: 192000 PERIOD_BYTES: 1152000 PERIODS: 2 BUFFER_TIME: 2000000 BUFFER_SIZE: 384000 BUFFER_BYTES: 2304000 TICK_TIME: 0

linuxandos2 commented 3 weeks ago

Also tryed different period sizes.

linuxandos2 commented 2 weeks ago

Finally installed a fresh gentoo system on a different partition: Problem does not occur any more. If you want to further investigate let my know. Up to you to close. And thanks alot.