Project

General

Profile

ALSA error with direct hw

Added by Cristiano De Alti over 8 years ago

I'm trying to play 24/96 tracks with Audacious 3.7.2 compiled from sources on Linux Mint Nadia.
I want to use direct hw access without software conversions.

Deadbeef can play these tracks without problems both to my integrated audio and an external USB DAC (direct hw access without software conversions).

Audacious gives the following error:

ERROR util.cc:160 [audgui_simple_message]: ALSA error: snd_pcm_hw_params_set_format failed: Invalid argument.

Here is the output of aplay -L

default
    Playback/recording through the PulseAudio sound server
sysdefault:CARD=PCH
    HDA Intel PCH, ALC269VB Analog
    Default Audio Device
front:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VB Analog
    Front speakers
surround40:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VB Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VB Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VB Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VB Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VB Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
hdmi:CARD=PCH,DEV=0
    HDA Intel PCH, HDMI 0
    HDMI Audio Output
dmix:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VB Analog
    Direct sample mixing device
dmix:CARD=PCH,DEV=3
    HDA Intel PCH, HDMI 0
    Direct sample mixing device
dsnoop:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VB Analog
    Direct sample snooping device
dsnoop:CARD=PCH,DEV=3
    HDA Intel PCH, HDMI 0
    Direct sample snooping device
hw:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VB Analog
    Direct hardware device without any conversions
hw:CARD=PCH,DEV=3
    HDA Intel PCH, HDMI 0
    Direct hardware device without any conversions
plughw:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VB Analog
    Hardware device with all software conversions
plughw:CARD=PCH,DEV=3
    HDA Intel PCH, HDMI 0
    Hardware device with all software conversions
sysdefault:CARD=Audio
    NAD USB Audio, USB Audio
    Default Audio Device
front:CARD=Audio,DEV=0
    NAD USB Audio, USB Audio
    Front speakers
surround40:CARD=Audio,DEV=0
    NAD USB Audio, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Audio,DEV=0
    NAD USB Audio, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Audio,DEV=0
    NAD USB Audio, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Audio,DEV=0
    NAD USB Audio, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Audio,DEV=0
    NAD USB Audio, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Audio,DEV=0
    NAD USB Audio, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=Audio,DEV=0
    NAD USB Audio, USB Audio
    Direct sample mixing device
dsnoop:CARD=Audio,DEV=0
    NAD USB Audio, USB Audio
    Direct sample snooping device
hw:CARD=Audio,DEV=0
    NAD USB Audio, USB Audio
    Direct hardware device without any conversions
plughw:CARD=Audio,DEV=0
    NAD USB Audio, USB Audio
    Hardware device with all software conversions

I want to use hw:CARD=Audio,DEV=0 but I get the above error no matter the settings in File | Settings | Audio.
My settings are:

Ouput plugin: Alsa Output
PCM Device: hw:CARD=Audio,DEV=0
Mixer device: hw:1
Mixer element: PCM

About the mixer settings, I've tried other combinations resulting in the same errors.
Note: I use the same configuration in Deadbeef and it works. However Deadbeef does not have any mixer options

The problem is not limited to the USB device. I have the same error using my integrated audio hw:CARD=PCH,DEV=0.
Note: I can use the integrated audio in Deadbeef

Following are some info on my USB DAC when playing one of the above tracks with Deadbeef:

$ cat /proc/asound/card1/stream0 
NAD Electronics NAD USB Audio at usb-0000:05:00.0-1, full speed : USB Audio

Playback:
  Status: Running
    Interface = 1
    Altset = 1
    Packet Size = 588
    Momentary freq = 96000 Hz (0x60.0000)
    Feedback Format = 10.14
    Packet Size = 0
    Momentary freq = 96000 Hz (0x60.0000)
  Interface 1
    Altset 1
    Format: S24_3LE
    Channels: 2
    Endpoint: 1 OUT (ASYNC)
    Rates: 44100, 48000, 88200, 96000

$ cat /proc/asound/card1/pcm0p/info 
card: 1
device: 0
subdevice: 0
stream: PLAYBACK
id: USB Audio
name: USB Audio
subname: subdevice #0
class: 0
subclass: 0
subdevices_count: 1
subdevices_avail: 0

$ cat /proc/asound/card1/pcm0p/sub0/hw_params 
access: RW_INTERLEAVED
format: S24_3LE
subformat: STD
channels: 2
rate: 96000 (96000/1)
period_size: 1024
buffer_size: 8192

$ cat /proc/asound/card1/pcm0p/sub0/info
card: 1
device: 0
subdevice: 0
stream: PLAYBACK
id: USB Audio
name: USB Audio
subname: subdevice #0
class: 0
subclass: 0
subdevices_count: 1
subdevices_avail: 0

$ cat /proc/asound/card1/pcm0p/sub0/status 
state: RUNNING
owner_pid   : 17115
trigger_time: 849782.531341515
tstamp      : 850141.280350597
delay       : 7733
avail       : 1036
avail_max   : 2080
-----
hw_ptr      : 34442252
appl_ptr    : 34449408

$ cat /proc/asound/card1/pcm0p/sub0/sw_params 
tstamp_mode: NONE
period_step: 1
avail_min: 1024
start_threshold: 7168
stop_threshold: 8192
silence_threshold: 0
silence_size: 0
boundary: 4611686018427387904

Regards,
Cristiano


Replies (6)

RE: ALSA error with direct hw - Added by John Lindgren over 8 years ago

It looks like deadbeef is using packed 24-bit audio, whereas Audacious uses unpacked (i.e. aligned to 32-bit word). That's the only difference I can think of. You could try using straight 32-bit instead; some chips support that.

RE: ALSA error with direct hw - Added by Cristiano De Alti over 8 years ago

Unfortunately changing the bit depth doesn't make any difference.
The problem is not limited only to 24/96. I get the same error also playing 16/44.1.

To summarize:

USB DAC: Cannot play anything to hw:CARD=Audio,DEV=0
Integrated audio: Cannot play 24/96 to hw:CARD=PCH,DEV=0 but I can play 16/44.1

I confirm that playing 24/96 and 16/44.1 works fine with Deadbeef both on hw:CARD=Audio,DEV=0 and hw:CARD=PCH,DEV=0.

Regards,
Cristiano

RE: ALSA error with direct hw - Added by Cristiano De Alti over 8 years ago

Hello,
Can you please help me understand if the following alternative is still bit perfect (equivalent to the deadbeef one)?

1. 24/96 flac
2. Output plugin: ALSA Output
3. Bit depth: 24
4. PCM Device: plughw:CARD=Audio,DEV=0
NAD USB Audio, USB Audio
Hardware device with all software conversions
5. hw:1 - NAD USB AUdio
6. Mixer element: PCM

The above config results in the following:

$ cat /proc/asound/card1/stream0 
NAD Electronics NAD USB Audio at usb-0000:05:00.0-1, full speed : USB Audio

Playback:
  Status: Running
    Interface = 1
    Altset = 1
    Packet Size = 588
    Momentary freq = 96000 Hz (0x60.0000)
    Feedback Format = 10.14
    Packet Size = 0
    Momentary freq = 96000 Hz (0x60.0000)
  Interface 1
    Altset 1
    Format: S24_3LE
    Channels: 2
    Endpoint: 1 OUT (ASYNC)
    Rates: 44100, 48000, 88200, 96000

$ cat /proc/asound/card1/pcm0p/sub0/hw_params 
access: MMAP_INTERLEAVED
format: S24_3LE
subformat: STD
channels: 2
rate: 96000 (96000/1)
period_size: 1152
buffer_size: 4800

that looks similar to the deadbeef one of the first post.

Other info: both the system and Audacity volume controls do not affect the output level. Same for the alsamixer volume. This should be good.

Changing the bit depth in Audacity (setting 32 bit for example) does not change the output of the command above.

My guess is that the ALSA plug plugin is ONLY converting the bit format output by Audacity (S32_??) to S24_3LE which is the only supported by the NAD USB DAC,
and that this conversion is lossless

Are there other checks I should do to confirm the above guess?

a. If this is correct I'm fine but it requires some knowledge by the user to figure out if playback is bit-perfect.

a.1. Deadbeef works out of the box with hw:CARD=Audio,DEV=0 and has a reputation of being bit-perfect. I would humbly suggest to "copy" Deadbeef in this area. I'm happy to help testing patches and compile from sources in case you like it.

b. I'm also not sure about the usage of the Bit depth control in Audacious. Can you please advise what it is supposed to do and how it affects bit-perfection?

Thanks for your great work.

Regards,
Cristiano

RE: ALSA error with direct hw - Added by Cristiano De Alti over 8 years ago

In the post above where I wrote mistakenly Audacity I actually meant Audacious. Sorry.

RE: ALSA error with direct hw - Added by Cristiano De Alti over 8 years ago

I have a patch that I will submit soon to support the S24_3LE format (the one used by USB DACs).

    (1-6/6)