Decode DTS/DD audio to 7.1 USB analog sound card?

hi,

i’m trying to output audio to a 7.1 USB sound card (ASIO supported). when i watch a movie with DTS 7.1 or DD 5.1 there is no sound output. GUI sounds and DD 2.0 movie works fine.

is it possible to get analog 7.1 output?

aplay -L output:

> default:CARD=AMLM8AUDIO
>     AML-M8AUDIO,
>     Default Audio Device
> sysdefault:CARD=AMLM8AUDIO
>     AML-M8AUDIO,
>     Default Audio Device
> hdmi:CARD=AMLM8AUDIO,DEV=0
>     AML-M8AUDIO,
>     HDMI Audio Output
> default:CARD=USBStreamer
>     USBStreamer, USB Audio
>     Default Audio Device
> sysdefault:CARD=USBStreamer
>     USBStreamer, USB Audio
>     Default Audio Device
> front:CARD=USBStreamer,DEV=0
>     USBStreamer, USB Audio
>     Front speakers
> surround21:CARD=USBStreamer,DEV=0
>     USBStreamer, USB Audio
>     2.1 Surround output to Front and Subwoofer speakers
> surround40:CARD=USBStreamer,DEV=0
>     USBStreamer, USB Audio
>     4.0 Surround output to Front and Rear speakers
> surround41:CARD=USBStreamer,DEV=0
>     USBStreamer, USB Audio
>     4.1 Surround output to Front, Rear and Subwoofer speakers
> surround50:CARD=USBStreamer,DEV=0
>     USBStreamer, USB Audio
>     5.0 Surround output to Front, Center and Rear speakers
> surround51:CARD=USBStreamer,DEV=0
>     USBStreamer, USB Audio
>     5.1 Surround output to Front, Center, Rear and Subwoofer speakers
> surround71:CARD=USBStreamer,DEV=0
>     USBStreamer, USB Audio
>     7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
> iec958:CARD=USBStreamer,DEV=0
>     USBStreamer, USB Audio
>     IEC958 (S/PDIF) Digital Audio Output

surroundXX are not listed in coreelec audio settings. maybe i have to add them to ~/.asoundrc? i don’t know if that would help.

can you help me?

additional information from log (when playing DTS 7.1 movie):

> 2021-12-28 12:19:44.116 T:4051694400    INFO: CActiveAESink::OpenSink - initialize sink
> 2021-12-28 12:19:44.168 T:4051694400   DEBUG: CActiveAESink::OpenSink - trying to open device ALSA:@:CARD=USBStreamer,DEV=0
> 2021-12-28 12:19:44.175 T:4051694400    INFO: CAESinkALSA::Initialize - Requested layout: FL, FR, FC, LFE, BL, BR, SL, SR
> 2021-12-28 12:19:44.175 T:4051694400    INFO: CAESinkALSA::Initialize - Attempting to open device "@:CARD=USBStreamer,DEV=0"
> 2021-12-28 12:19:44.194 T:4051694400    INFO: CAESinkALSA::Initialize - Opened device "surround71:CARD=USBStreamer,DEV=0"
> 2021-12-28 12:19:44.196 T:4051694400    INFO: CAESinkALSA::InitializeHW - Your hardware does not support AE_FMT_FLOAT, trying other formats
> 2021-12-28 12:19:44.196 T:4051694400   ERROR: CAESinkALSA::InitializeHW - Unable to find a suitable output format
> 2021-12-28 12:19:44.197 T:4051694400   DEBUG: CActiveAESink::OpenSink - trying to open device ALSA:default
> 2021-12-28 12:19:44.197 T:4051694400    INFO: CAESinkALSA::Initialize - Requested layout: FL, FR, FC, LFE, BL, BR, SL, SR
> 2021-12-28 12:19:44.197 T:4051694400    INFO: CAESinkALSA::Initialize - Attempting to open device "default"
> 2021-12-28 12:19:44.215 T:4051694400    INFO: CAESinkALSA::Initialize - Opened device "default"
> 2021-12-28 12:19:44.225 T:4051694400    INFO: CAESinkALSA::InitializeHW - Your hardware does not support AE_FMT_FLOAT, trying other formats
> 2021-12-28 12:19:44.226 T:4051694400    INFO: CAESinkALSA::InitializeHW - Using data format AE_FMT_S32NE
> 2021-12-28 12:19:44.226 T:4051694400   DEBUG: CAESinkALSA::InitializeHW - Request: periodSize 2048, bufferSize 16384
> 2021-12-28 12:19:44.246 T:3902796608   DEBUG: CVideoPlayer::ProcessVideoData size:482 dts:0.250 pts:0.667 dur:41.000ms, clock:-0.333 level:0
> 2021-12-28 12:19:44.246 T:3902796608   DEBUG: CVideoPlayer::ProcessVideoData size:479 dts:0.292 pts:0.501 dur:41.000ms, clock:-0.333 level:0
> 2021-12-28 12:19:44.246 T:3902796608   DEBUG: CVideoPlayer::ProcessVideoData size:478 dts:0.334 pts:0.417 dur:41.000ms, clock:-0.333 level:0
> 2021-12-28 12:19:44.246 T:3902796608   DEBUG: CVideoPlayer::ProcessVideoData size:479 dts:0.375 pts:0.375 dur:41.000ms, clock:-0.333 level:0
> 2021-12-28 12:19:44.246 T:3902796608   DEBUG: CVideoPlayer::ProcessVideoData size:478 dts:0.417 pts:0.459 dur:41.000ms, clock:-0.333 level:1
> 2021-12-28 12:19:44.256 T:3902796608   DEBUG: CVideoPlayer::ProcessVideoData size:478 dts:0.459 pts:0.584 dur:41.000ms, clock:-0.333 level:2
> 2021-12-28 12:19:44.256 T:4051694400   DEBUG: CAESinkALSA::InitializeHW - Got: periodSize 2048, bufferSize 16384
> 2021-12-28 12:19:44.256 T:4051694400   DEBUG: CAESinkALSA::InitializeHW - Setting timeout to 342 ms
> 2021-12-28 12:19:44.257 T:4051694400   DEBUG: CAESinkALSA::GetChannelLayout - Input Channel Count: 8 Output Channel Count: 8
> 2021-12-28 12:19:44.257 T:4051694400   DEBUG: CAESinkALSA::GetChannelLayout - Requested Layout: FL, FR, FC, LFE, BL, BR, SL, SR
> 2021-12-28 12:19:44.257 T:4051694400   DEBUG: CAESinkALSA::GetChannelLayout - Got Layout: FL, FR, LFE, FC, SL, SR, BL, BR (ALSA: FL FR LFE FC RL RR RLC RRC) (CEA: 7)
> 2021-12-28 12:19:44.258 T:4051694400   DEBUG: CActiveAESink::OpenSink - ALSA Initialized:
> 2021-12-28 12:19:44.258 T:4051694400   DEBUG:   Output Device : Default (AML-M8AUDIO Analog)
> 2021-12-28 12:19:44.258 T:4051694400   DEBUG:   Sample Rate   : 48000
> 2021-12-28 12:19:44.258 T:4051694400   DEBUG:   Sample Format : AE_FMT_S32NE
> 2021-12-28 12:19:44.258 T:4051694400   DEBUG:   Channel Count : 8
> 2021-12-28 12:19:44.258 T:4051694400   DEBUG:   Channel Layout: FL, FR, LFE, FC, SL, SR, BL, BR
> 2021-12-28 12:19:44.258 T:4051694400   DEBUG:   Frames        : 2048
> 2021-12-28 12:19:44.258 T:4051694400   DEBUG:   Frame Size    : 32

the USB device is not supporting the requested format and KODI is switching to onboard sound card.

a second log (when playing a DD 2.0 movie, sound works):

> 2021-12-28 12:29:55.363 T:4051694400   DEBUG: CActiveAESink::OpenSink - trying to open device ALSA:@:CARD=USBStreamer,DEV=0
> 2021-12-28 12:29:55.363 T:4051694400    INFO: CAESinkALSA::Initialize - Requested layout: FL, FR
> 2021-12-28 12:29:55.363 T:4051694400    INFO: CAESinkALSA::Initialize - Attempting to open device "@:CARD=USBStreamer,DEV=0"
> 2021-12-28 12:29:55.397 T:4051694400    INFO: CAESinkALSA::Initialize - Opened device "sysdefault:CARD=USBStreamer"
> 2021-12-28 12:29:55.399 T:4051694400    INFO: CAESinkALSA::InitializeHW - Your hardware does not support AE_FMT_FLOAT, trying other formats
> 2021-12-28 12:29:55.399 T:4051694400    INFO: CAESinkALSA::InitializeHW - Using data format AE_FMT_S32NE
> 2021-12-28 12:29:55.399 T:4051694400   DEBUG: CAESinkALSA::InitializeHW - Request: periodSize 1024, bufferSize 16384
> 2021-12-28 12:29:55.399 T:4051694400   DEBUG: CAESinkALSA::InitializeHW - Got: periodSize 1024, bufferSize 16384
> 2021-12-28 12:29:55.399 T:4051694400   DEBUG: CAESinkALSA::InitializeHW - Setting timeout to 342 ms
> 2021-12-28 12:29:55.400 T:4051694400    INFO: CAESinkALSA::Initialize - setting default aud_ch to 19
> 2021-12-28 12:29:55.400 T:4051694400   DEBUG: CAESinkALSA::GetChannelLayout - Input Channel Count: 2 Output Channel Count: 10
> 2021-12-28 12:29:55.400 T:4051694400   DEBUG: CAESinkALSA::GetChannelLayout - Requested Layout: FL, FR
> 2021-12-28 12:29:55.400 T:4051694400   DEBUG: CAESinkALSA::GetChannelLayout - Got Layout: FL, FR, FC, LFE, BL, BR, FLOC, FROC, BC, SL (ALSA: FL FR FC LFE RL RR FLC FRC RC SL) (CEA: 7)
> 2021-12-28 12:29:55.400 T:4051694400   DEBUG: CActiveAESink::OpenSink - ALSA Initialized:
> 2021-12-28 12:29:55.400 T:4051694400   DEBUG:   Output Device : USBStreamer
> 2021-12-28 12:29:55.400 T:4051694400   DEBUG:   Sample Rate   : 48000
> 2021-12-28 12:29:55.400 T:4051694400   DEBUG:   Sample Format : AE_FMT_S32NE
> 2021-12-28 12:29:55.400 T:4051694400   DEBUG:   Channel Count : 10
> 2021-12-28 12:29:55.400 T:4051694400   DEBUG:   Channel Layout: FL, FR, FC, LFE, BL, BR, FLOC, FROC, BC, SL
> 2021-12-28 12:29:55.400 T:4051694400   DEBUG:   Frames        : 1024
> 2021-12-28 12:29:55.400 T:4051694400   DEBUG:   Frame Size    : 40

and finally a log from “Enumerated ALSA devices:”

> 2015-01-01 01:00:22.118 T:4061446976  NOTICE:     Device 4
> 2015-01-01 01:00:22.118 T:4061446976  NOTICE:         m_deviceName      : @:CARD=USBStreamer,DEV=0
> 2015-01-01 01:00:22.118 T:4061446976  NOTICE:         m_displayName     : USBStreamer
> 2015-01-01 01:00:22.118 T:4061446976  NOTICE:         m_displayNameExtra: Analog
> 2015-01-01 01:00:22.118 T:4061446976  NOTICE:         m_deviceType      : AE_DEVTYPE_PCM
> 2015-01-01 01:00:22.118 T:4061446976  NOTICE:         m_channels        : FL, FR, FC, LFE, BL, BR, FLOC, FROC, BC, SL
> 2015-01-01 01:00:22.118 T:4061446976  NOTICE:         m_sampleRates     : 48000
> 2015-01-01 01:00:22.118 T:4061446976  NOTICE:         m_dataFormats     : AE_FMT_S32NE
> 2015-01-01 01:00:22.118 T:4061446976  NOTICE:         m_streamTypes     : No passthrough capabilities

The final system you didn’t say anything about - its analog / digital? 2ch?

Maybe start here

it’s an XMOS USB to I2S-Converter connected to an I2S DAC with max. 10 channels of analog output

Man, the final destination? Soundbar? Analog home cinema? Don’t have any crystal ball with me. The sound comes from?

it does not matter where the analog output finally goes to … finally there are some amps i want to feed.

this is the USB I2S device: https://www.minidsp.com/products/usb-audio-interface/usbstreamer
this is the I2S DAC DAC-32384-DSD, 32Bit/384KHz, 1bit/5.6MHz DSD128, 8 Kanäle DAC basierend auf ES9018 | eBay

Please help us to understand what is going on! Your box / SBC is… If you have a proper hw you don’t have to use a soundcard to an amplifier, for me looks overkill, but I am not an audiophile. Can you post a full log so the devs can get a proper image?

Does it work when the output device is directly connected to the source?

Please submit logs the proper way.

Thank you.

Thank you for your fast reply. Yes, it overkill with this audio setup :slight_smile: I can’t connect it any other way, it has to be USB → I2S → Analog Out → AMP. This combination works like an USB sound card.

I will post more logs the proper way. I found something for the devs and it could be the problem: If i setup 2.0 or 4.0 audio i can get sound from any source! 5.1 and 7.1 is not working. Maybe a bug with the channel mapping:

The USB audio device is always giving this channel layout:

CAESinkALSA::GetChannelLayout - Got Layout: FL, FR, FC, LFE, BL, BR, FLOC, FROC, BC, SL (ALSA: FL FR FC LFE RL RR FLC FRC RC SL) (CEA: 5)

When i want to watch a movie in 5.1 this format is requested:

CAESinkALSA::GetChannelLayout - Requested Layout: FL, FR, FC, LFE, SL, SR

Request with 7.1 movie:

CAESinkALSA::GetChannelLayout - Requested Layout: FL, FR, FC, LFE, BL, BR, SL, SR

I don’t know why the USB audio device is giving this layout with BC. There is no mapping for the requested SR. It could be easy to fix with some channel name remapping, maybe SR to BC?

Another problem is that the USB device is always reporting only sample rate 48000, but the device is capable of doing 44100,48000,88200,96000,176400,192000.

Some more info from the log. When i’m selecting more than 4 channels in the coreELEC audio settings:

With 4.0 channels in settings it’s working:

2021-12-29 09:25:33.375 T:4053791552 INFO: CAESinkALSA::Initialize - Opened device “surround40:CARD=USBStreamer,DEV=0”
2021-12-29 09:25:33.376 T:4053791552 INFO: CAESinkALSA::InitializeHW - Your hardware does not support AE_FMT_FLOAT, trying other formats
2021-12-29 09:25:33.377 T:4053791552 INFO: CAESinkALSA::InitializeHW - Using data format AE_FMT_S32NE
2021-12-29 09:25:33.377 T:4053791552 DEBUG: CAESinkALSA::InitializeHW - Request: periodSize 4096, bufferSize 16384
2021-12-29 09:25:33.393 T:4053791552 DEBUG: CAESinkALSA::InitializeHW - Got: periodSize 4096, bufferSize 16384
2021-12-29 09:25:33.394 T:4053791552 DEBUG: CAESinkALSA::GetChannelLayout - Input Channel Count: 4 Output Channel Count: 10
2021-12-29 09:25:33.394 T:4053791552 DEBUG: CAESinkALSA::GetChannelLayout - Requested Layout: FL, FR, BL, BR

Maybe it’s not only a mapping problem. When i setup 4.1 channels in settings the requested layout “FL, FR, LFE, BL, BR” should map to the reported channels “FL, FR, FC, LFE, BL, BR, FLOC, FROC, BC, SL” of the USB audio device, but it fails and output device is switching to onboard “ALSA:default”

2021-12-29 10:04:27.809 T:4053791552 INFO: CAESinkALSA::Initialize - Opened device “surround51:CARD=USBStreamer,DEV=0”
2021-12-29 10:04:27.810 T:4053791552 INFO: CAESinkALSA::InitializeHW - Your hardware does not support AE_FMT_FLOAT, trying other formats
2021-12-29 10:04:27.811 T:4053791552 ERROR: CAESinkALSA::InitializeHW - Unable to find a suitable output format
2021-12-29 10:04:27.812 T:4053791552 DEBUG: CActiveAESink::OpenSink - trying to open device ALSA:default
2021-12-29 10:04:27.812 T:4053791552 INFO: CAESinkALSA::Initialize - Requested layout: FL, FR, LFE, BL, BR

With more than 4 channels data format AE_FMT_S32NE can’t be set on the USB audio device and it falls back to default onboard sound. I don’t know what the “Request: periodSize” is when i select more than 4 channels, there is no information in the log. Maybe that’s a problem too?

system/ kodi log: ZeroBin.net

I see that some XMOS USB DACs are directly supported linux-amlogic/quirks.c at amlogic-4.9-19 · CoreELEC/linux-amlogic · GitHub …Maybe i have to ask an associated developer to support my XMOS USB adapter.

update: i tried a simple sound test on the console (stopped KODI with “systemctl stop kodi”):
speaker-test -t sine -c 8 -r 96000 -F S24_3LE -b 200000 -p 50000 -D default:CARD=USBStreamer

speaker-test 1.1.9

Playback device is default:CARD=USBStreamer
Stream parameters are 96000Hz, S24_3LE, 8 channels
Sine wave rate is 440.0000Hz
Rate set to 96000Hz (requested 96000Hz)
Buffer size range from 4096 to 32768
Period size range from 2047 to 2049
Requested period time 50000 us
Requested buffer time 200000 us
was set period_size = 2048
was set buffer_size = 18432
0 - Front Left
6 - Front Left Center
2 - Front Center
7 - Front Right Center
1 - Front Right
5 - Rear Right
4 - Rear Left
3 - LFE
Time per period = 23.742841

I can hear every channel! GREAT!!! It works with 2,3,4,5,6 and 7 channels too. So it’s not really a driver problem. The sound in general works!

KODI is always trying to access surroundXX:CARD=USBStreamer,DEV=0 to play multichannel audio. maybe DEV=0 is not correct? where is this defined? maybe i can just remove this parameter?

i tried to add a new 7.1 device to /storage/.config/asound.conf to reroute it to “default:CARD=USBStreamer” but everything i tried i can’t see the devices in KODI audio setup. asound.conf is ignored.

i hope to find a solution and maybe it helps some other people with USB audio problems.

@Garcea: Sorry for this wording. It was not meant in a bad way :slight_smile: :slight_smile:

The main magic happen here:

All Audio stuff is very complicated.

No offense taken, you weren’t too clear about your audio setup from player to the end.

Yes. I checked this yesterday, thank you. The solution is to find out why snd_pcm_hw_params_set_format fails. Maybe ALSA is not giving the correct available sound formats from the USB device.

You can see that some channel name remapping in AESinkALSA.cpp is also happening because some USB audio devices are not reporting the correct channel names.

@Portisch: Do you think i can solve this problem by some asound.conf workarounds?

If nothing helps i will try to set up a build environment in the next month and add some more debug logs.

About | FAQ | Terms of Service | Privacy Policy | Legal Notice