• 1
  • 3
  • 4
  • 5(current)
  • 6
  • 7
  • 15
Linux Almost solved: PROPER Dual Audio on Linux
#61
If I compare my xbmc logging with the logs of Vuebe, the logging of the detection of the audio outputs defined in the asound.conf file is missing in my log file. Because my logging file doesn't contain any error message, I assume it is missing in the code. As a result no default is present in the enumeration of the ALSA outputs,

In more detail, this part is missing:

Code:
09:28:36 T:3007354688    INFO: CAESinkALSA - Enumerating device "default"
09:28:36 T:3007354688    INFO: CAESinkALSA - Adding device "default"
09:28:36 T:3007354688    INFO: CAESinkALSA - Enumerating device "pulse"
09:28:36 T:3007354688    INFO: CAESinkALSA - ALSA: pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
09:28:36 T:3007354688    INFO: CAESinkALSA - Unable to open device "pulse" for playback
09:28:36 T:3007354688    INFO: CAESinkALSA - Unable to open device "pulse"
09:28:36 T:3007354688    INFO: CAESinkALSA - Enumerating device "xbmcaudio"
09:28:36 T:3007354688    INFO: CAESinkALSA - Adding device "xbmcaudio"
09:28:36 T:3007354688    INFO: CAESinkALSA - Enumerating device "both"
09:28:36 T:3007354688    INFO: CAESinkALSA - Adding device "both"
09:28:36 T:3007354688    INFO: CAESinkALSA - Enumerating device "multi2"
09:28:36 T:3007354688    INFO: CAESinkALSA - Adding device "multi2"
09:28:36 T:3007354688    INFO: CAESinkALSA - Enumerating device "@:CARD=NVidia,DEV=0"
09:28:36 T:3007354688    INFO: CAESinkALSA - Adding device "@:CARD=NVidia,DEV=0"
09:28:36 T:3007354688    INFO: CAESinkALSA - Enumerating device "iec958:CARD=NVidia,DEV=0"
09:28:36 T:3007354688    INFO: CAESinkALSA - Adding device "iec958:CARD=NVidia,DEV=0"
09:28:36 T:3007354688    INFO: CAESinkALSA - Enumerating device "hdmi:CARD=NVidia_1,DEV=0"
09:28:36 T:3007354688    INFO: CAESinkALSA - Adding device "hdmi:CARD=NVidia_1,DEV=0"
09:28:36 T:3007354688    INFO: CAESinkALSA - Enumerating device "hdmi:CARD=NVidia_1,DEV=1"
09:28:36 T:3007354688   DEBUG: CAESinkALSA - HDMI device "hdmi:CARD=NVidia_1,DEV=1" may be unconnected (no ELD data)
09:28:36 T:3007354688    INFO: CAESinkALSA - Adding device "hdmi:CARD=NVidia_1,DEV=1"
09:28:36 T:3007354688    INFO: CAESinkALSA - Enumerating device "hdmi:CARD=NVidia_1,DEV=2"
09:28:36 T:3007354688   DEBUG: CAESinkALSA - HDMI device "hdmi:CARD=NVidia_1,DEV=2" may be unconnected (no ELD data)
09:28:36 T:3007354688    INFO: CAESinkALSA - Adding device "hdmi:CARD=NVidia_1,DEV=2"
09:28:36 T:3007354688    INFO: CAESinkALSA - Enumerating device "hdmi:CARD=NVidia_1,DEV=3"
09:28:36 T:3007354688   DEBUG: CAESinkALSA - HDMI device "hdmi:CARD=NVidia_1,DEV=3" may be unconnected (no ELD data)
09:28:36 T:3007354688    INFO: CAESinkALSA - Adding device "hdmi:CARD=NVidia_1,DEV=3"

I decided to raise an issue: https://github.com/OpenELEC/OpenELEC.tv/issues/2176.

I received a response from the team saying that Dual Audio is not supported. So I think I just wait a year to update to OE 4 or OE 5 and hope it will be supported at that time. I won't bother you guys again.
Reply
#62
Hello XBMC-follower
Okay here are my complete settings for a Zotac Ionitx -d (should work with all Ionitx a-f versions, due to same layout, ION gen1)

Soundhardware layout:
Analog 5.1 surround system from Creative, directly plugged into the 3 jacks directly in the back
Sound to the TV via HDMI (2 ch)

Used version:
Ubuntu 12.04 with xorg-edgers ppa (so Linux-Kernel is 3.5) Xorg-edgers PPA
nightly Builds of XBMC, currently XBMC 13.0 Alpha 3 git from April 11th from XMBC Nightly PPA

First set up your Audio Card to use both outputs in the BIOS
BIOS -> Chipset -> SouthBridge Configuration -> AZALIA AUDIO : Internal codec + External codec

Then configure your ubuntu for 5.1 audio.
write with root-rights in the file /etc/modprobe.d/alsa-base.conf as last line
Code:
options snd-hda-intel model=3stack-6ch index=0
This lets the soundcard know that it should give out 6 ch sound from the 3 jacks in the back.

The I checked my ALSA-Settings with the alsamixer. Important is the switch from 2ch to 6 ch mode. (Yeah BUUUUHHHH windows, but for ssh-work its enough Big Grin )
Image
Image

Then I adapted the great file given by puntloos to my needs. Location of the file on Ubuntu-based system is /etc/asound.conf.
Code:
# asound.conf for Dual Audio - HDMI (stereo) + Stereo out (analog 5.1)
# by puntloos, adapted by Matthias T.
# This should allow you to send audio to two devices, one HDMI (for surround) and one other device, which can be digital or even analog outputs
# 1- Location of asound.conf in OpenELEC is ./storage/.config/asound.conf - create or modify that file. location on Ubuntu based system is /etc/asound.conf.
# 2- Modify the bottom part of the file to match your hardware

pcm.!default {
        type plug
        slave {
                pcm "both_digital"
        }
}

# First we create a 'both' route, that has 12 channels
pcm.both_digital {
        type route
        slave {
                pcm multi
                channels 12
        }
        # And we route the channels 1:1
        # 6 inputs (0-5) get mapped into 12 outputs (0-11)
        # (this is how we copy channels)
        ttable.0.0 1.0
        ttable.1.1 1.0
        ttable.2.2 1.0
        ttable.3.3 1.0
        ttable.4.4 1.0
        ttable.5.5 1.0
        ttable.0.6 1.0
        ttable.1.7 1.0
        ttable.2.8 1.0
        ttable.3.9 1.0
        ttable.4.10 1.0
        ttable.5.11 1.0
}

# Then define a multi device that splits the 12-channel input
# Into 2x 6 output

pcm.multi {
        type multi
        slaves.a {
                pcm "analog_hw"
                channels 6
        }
        slaves.b {
                # virtual dac still has 6 channels
                # although I suppose I could try making it 2
                pcm "hdmi_virtual"
                channels 6
        }

    # Bind stuff to the HDMI outputs
        bindings.0.slave a
        bindings.0.channel 0
        bindings.1.slave a
        bindings.1.channel 1
        bindings.2.slave a
        bindings.2.channel 2
        bindings.3.slave a
        bindings.3.channel 3
        bindings.4.slave a
        bindings.4.channel 4
        bindings.5.slave a
        bindings.5.channel 5

        # And to the DAC outputs
        bindings.6.slave b
        bindings.6.channel 0
        bindings.7.slave b
        bindings.7.channel 1
        bindings.8.slave b
        bindings.8.channel 2
        bindings.9.slave b
        bindings.9.channel 3
        bindings.10.slave b
        bindings.10.channel 4
        bindings.11.slave b
        bindings.11.channel 5
}

# Since the DAC is 2 channels, we downmix.
pcm.hdmi_virtual
{
  type route
  slave.pcm hdmi_hw
  slave.channels 2

  # Different routing setting taken from http://wiki.ubuntuusers.de/.asoundrc
  ttable.0.0 1
  ttable.1.1 1
  ttable.2.0 0.707
  ttable.3.1 0.707
  ttable.4.0 0.5
  ttable.4.1 0.5
  ttable.5.0 0.5
  ttable.5.1 0.5
}

# And here is my actual hardware
# Note that this is linked to the output of 'aplay -l'
# HDMI output
pcm.analog_hw {
        type hw
        card 0
        device 0
        channels 6
}

# Stereo output
pcm.hdmi_hw {
        type hw
        card 0
        device 3
        channels 2
}

For working standby I created a file
/etc/pm/config.d/00sleep_module
with following content
Code:
SUSPEND_MODULES="alsa"
This unloads and reloads the sound system after standby. For this to work you have to make the file excutable.
Code:
sudo chmod +x /etc/pm/config.d/00sleep_module

To be assured that this works I altered the line in /etc/default/acpi-support
Code:
STOP_SERVICES="alsa"

For XBMC Settings (language is german, but should be self-explaining):
Image

Image

As you can see, as hardware i use HDA NVIDIA (both-digital) with is the hardware we defined with the file from puntloos.
I dont use upmix, cause of the analog surround system and I like my music STEREO
The advancedsettings.xml is directly copied from this thread without any changes.

so that's it, I hope I could help.

grettings
Matthias T.
Reply
#63
Got it working on my Zotac ZBOX AD02, XBMC shows a 'Default'-entry in the list of audio devices in XBMC (Openelec 3.0.1). My config for dual audio on headphone jack and HDMI (stereo only, but 5.1 should work too):

Code:
# asound.conf for Dual Audio - HDMI (2.0) + Stereo out
# by puntloos
# This should allow you to send audio to two devices, one HDMI (for surround) and one other device, which can be digital or even analog outputs
# 1- Location of asound.conf in OpenELEC is ./storage/.config/asound.conf - create or modify that file.  
# 2- Modify the bottom part of the file to match your hardware

pcm.!default {
        type plug
        slave {
                pcm "both_digital"
        }
}

# First we create a 'both' route, that has 4 channels
pcm.both_digital {
        type route
        slave {
                pcm multi
                channels 4
        }
        # And we route the channels 1:1
        # 2 inputs (0-1) get mapped into 4 outputs (0-3)
        # (this is how we copy channels)
        ttable.0.0 1.0
        ttable.1.1 1.0
        ttable.0.2 1.0
        ttable.1.3 1.0
}

# Then define a multi device that splits the 4-channel input
# Into 2x 2 output

pcm.multi {
        type multi
        slaves.a {
                pcm "hdmi_hw"
                channels 2
        }
        slaves.b {
                pcm "dac_hw"
                channels 2
        }

    # Bind stuff to the HDMI outputs
        bindings.0.slave a
        bindings.0.channel 0
        bindings.1.slave a
        bindings.1.channel 1

        # And to the DAC outputs
        bindings.2.slave b
        bindings.2.channel 0
        bindings.3.slave b
        bindings.3.channel 1
}

# And here is my actual hardware
# Note that this is linked to the output of 'aplay -l'
# HDMI output
pcm.hdmi_hw {
        type hw
        card 0
        device 3
        channels 2
}

# Stereo output
pcm.dac_hw {
        type hw
        card 1
        device 0
        channels 2
}

I finally can switch off my TV when listening to web radio Smile.
Reply
#64
Thank you hannesb. It just works!

I was also experimenting with limiting the (HDMI) channels but I didn't figure out how to do this correctly. You did! Many thanks.
Reply
#65
(2013-04-21, 21:10)hannesb Wrote: Got it working on my Zotac ZBOX AD02, XBMC shows a 'Default'-entry in the list of audio devices in XBMC (Openelec 3.0.1). My config for dual audio on headphone jack and HDMI (stereo only, but 5.1 should work too):

I finally can switch off my TV when listening to web radio Smile.

Thanks this works!! the asound.conf on the first page wasn't working.. couldn't see Default as an option.

I'm using Openelec 3.0.1 with a Zbox AD12

Is this killing my 5.1 audio though over HDMI?
Reply
#66
Being an audio enthousiastic I tested the configuration of hannesb with my new DAC using an 176 kHz 24 bit audio file. It seems that this configuration resamples the audio to 48 kHz in case the sample frequency of the original file is > 48 kHz. This is probably caused by the limiations of the AMD drivers for HDMI (maximum sample rate 48 kHz). In case I switch over SPDIF DAC only, no resampling is applied, and the signal is bitperfect again. I wonder what is happening in case of an nvidia or Intel graphical chip(set).
Reply
#67
Interesting stuff guys. Hopefully I can find some time to convert hannes's work back into 5.1.

Hannes: what did you change? Did you only remove channels or also other things modified?

ps.. I have no idea why there would be resampling. No reason I can see that that would be due to my asound.conf.
System: Kodi on NVidia Shield 2015
Video: Panasonic AE3000 Projector / Samsung 46" LCD
Audio: Quad 2912 on Nord DM500Up with Marantz 7010 receiver.
Reply
#68
Ha, so it seems I didn't read back far enough, in fact Matthias managed to get it to work in surround, so I think I'll go give this a try too, see if anything needs tweaking or I can change this to "FIXED! Wink "

Oh and thanks for the reputation boost =)
System: Kodi on NVidia Shield 2015
Video: Panasonic AE3000 Projector / Samsung 46" LCD
Audio: Quad 2912 on Nord DM500Up with Marantz 7010 receiver.
Reply
#69
Hello and many thanks for your work. I have been testing your files in my Artic M001 but after 45 seconds the sound dissapear from both sources (Analog and HDMI). If stop and play every thing is fine but again after 45 seconds sound dissapear.... And I don't know what to do...

My file asound.conf

# asound.conf for Dual Audio - HDMI (2.0) + Stereo out
# by puntloos
# This should allow you to send audio to two devices, one HDMI (for surround) and one other device, which can be digital or even analog outputs
# 1- Location of asound.conf in OpenELEC is ./storage/.config/asound.conf - create or modify that file.
# 2- Modify the bottom part of the file to match your hardware

pcm.!default {
type plug
slave {
pcm "both_digital"
}
}

# First we create a 'both' route, that has 4 channels
pcm.both_digital {
type route
slave {
pcm multi
channels 4
}
# And we route the channels 1:1
# 2 inputs (0-1) get mapped into 4 outputs (0-3)
# (this is how we copy channels)
ttable.0.0 1.0
ttable.1.1 1.0
ttable.0.2 1.0
ttable.1.3 1.0
}

# Then define a multi device that splits the 4-channel input
# Into 2x 2 output

pcm.multi {
type multi
slaves.a {
pcm "hdmi_hw"
channels 2
}
slaves.b {
pcm "dac_hw"
channels 2
}

# Bind stuff to the HDMI outputs
bindings.0.slave a
bindings.0.channel 0
bindings.1.slave a
bindings.1.channel 1

# And to the DAC outputs
bindings.2.slave b
bindings.2.channel 0
bindings.3.slave b
bindings.3.channel 1
}

# And here is my actual hardware
# Note that this is linked to the output of 'aplay -l'
# HDMI output
pcm.hdmi_hw {
type hw
card 1
device 3
channels 2
}

# Stereo output
pcm.dac_hw {
type hw
card 0
device 0
channels 2
}

aplay -l

openelec:~/.config # aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC892 Analog [ALC892 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: ALC892 Digital [ALC892 Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Generic [HD-Audio Generic], device 3: HDMI 0 [HDMI 0]
Subdevices: 0/1
Subdevice #0: subdevice #0
Reply
#70
I managed to get this working with a simple asoundrc. This gives me 5.1 surround over HDMI and stereo output to zone 2. This is tested and working on Ubuntu 13.04.

Code:
pcm.analog-hw {
        type hw
        card 0
        device 0
}

ctl.analog-hw {
        type hw
        card 0
}

pcm.digital-hw {
        type hw
        card 0
        device 3
}

ctl.digital-hw {
        type hw
        card 0
}

pcm.!default {
        type plug
        slave {
                pcm multi
                rate 48000
        }
        ttable.0.0 1.0
        ttable.1.1 1.0
        ttable.0.2 1.0
        ttable.1.3 1.0
        ttable.2.4 1.0
        ttable.3.5 1.0
        ttable.4.6 1.0
        ttable.5.7 1.0
}

ctl.!default {
        type hw
        card 0
}

pcm.mixed {
        type plug
        slave {
                pcm multi
                rate 48000
                channels 8
        }
        ttable.0.0 1.0
        ttable.1.1 1.0
        ttable.0.2 1.0
        ttable.1.3 1.0
        ttable.2.4 1.0
        ttable.3.5 1.0
        ttable.4.6 1.0
        ttable.5.7 1.0
}

ctl.mixed {
        type hw
        card 0
}

pcm.multi {
        type multi
        slaves.a.pcm "analog-hw"
        slaves.a.channels 2
        slaves.b.pcm "digital-hw"
        slaves.b.channels 6
        bindings.0.slave a
        bindings.0.channel 0
        bindings.1.slave a
        bindings.1.channel 1
        bindings.2.slave b
        bindings.2.channel 0
        bindings.3.slave b
        bindings.3.channel 1
        bindings.4.slave b
        bindings.4.channel 2
        bindings.5.slave b
        bindings.5.channel 3
        bindings.6.slave b
        bindings.6.channel 4
        bindings.7.slave b
        bindings.7.channel 5
}

ctl.multi {
        type hw
        card 0
}

More info here
Reply
#71
This is great, we now have a couple of variants to try.

I should have some time this week to create some final versions and see if they work. It would be perfect if I can create an universal one that:

1/ Works for everyone (can we hope?)
2/ Supports 7.1 - this is not for me personally - ha I have a 4.0 setup myself - but if it supports 7.1 then there is no reason for openelec not to include it into the official build

I am a bit concerned that the 'works for everyone' thing is a bit fickle. It seems that the main reason things do not work are sensitivities with audio hardware having to wait for very short buffers. Just a theory at this moment. Let me come back to this thread tonight perhaps.

(2013-05-07, 03:56)omobeanz Wrote: I managed to get this working with a simple asoundrc. This gives me 5.1 surround over HDMI and stereo output to zone 2. This is tested and working on Ubuntu 13.04.

Hi omobeanz,

thanks for your work. A few questions:

1/ I've noticed you have "ctl" entries. Why have you added these?
2/ Your version indeed seems to prove that I can cut down the source channels earlier (I work with 12, you work with 8). Cool, I think I'll give that a try

Anything else that's different that you did, and why?
System: Kodi on NVidia Shield 2015
Video: Panasonic AE3000 Projector / Samsung 46" LCD
Audio: Quad 2912 on Nord DM500Up with Marantz 7010 receiver.
Reply
#72
Hello again,

I have been testing every file you have added and always the same problem for 45 seconds HDMI and Analog sound perfectly but suddenly sound stops on both devices. Now I am thinking that hardware is failing...

Pleased could you help me, I am absolutely rookie.

Many thanks
Reply
#73
(2013-05-07, 12:57)puntloos Wrote: A few questions:

1/ I've noticed you have "ctl" entries. Why have you added these?
2/ Your version indeed seems to prove that I can cut down the source channels earlier (I work with 12, you work with 8). Cool, I think I'll give that a try

Anything else that's different that you did, and why?

Hey puntloos,

1) The ctl stuff comes from the ALSA wiki directly (http://alsa.opensrc.org/.asoundrc), specifically due to this comment "sometimes apps need matching ctl device".
2) I found while using 'speaker_test' that ALSA intuitively knows what speakers to use based on the number you set so I found there was no need for down-mixing from more channels.
EG:
speaker-test -D mixed -c2 (produces 2 channel stereo)
speaker-test -D mixed -c3 (front left and right and center)
speaker-test -D mixed -c6 (5.1 surround)
Once you know this you use that in the config and it will produce stereo if you define 2 channels and 5.1 if you define 6. This makes the config way easier. For this reason any combination is easy, I will post a 4.0 version and 7.1 version later today.
Reply
#74
Here is an example 7.1 over HDMI and 2 channel stereo. Untested though as my receiver supports only 5.1 when zone 2 is enabled.

Code:
pcm.analog-hw {
        type hw
        card 0
        device 0
}

ctl.analog-hw {
        type hw
        card 0
}

pcm.digital-hw {
        type hw
        card 0
        device 3
}

ctl.digital-hw {
        type hw
        card 0
}

pcm.!default {
        type plug
        slave {
                pcm multi
                rate 48000
        }
        ttable.0.0 1.0
        ttable.1.1 1.0
        ttable.0.2 1.0
        ttable.1.3 1.0
        ttable.2.4 1.0
        ttable.3.5 1.0
        ttable.4.6 1.0
        ttable.5.7 1.0
        ttable.6.8 1.0
        ttable.7.9 1.0
}

ctl.!default {
        type hw
        card 0
}

pcm.mixed {
        type plug
        slave {
                pcm multi
                rate 48000
                channels 10
        }
        ttable.0.0 1.0
        ttable.1.1 1.0
        ttable.0.2 1.0
        ttable.1.3 1.0
        ttable.2.4 1.0
        ttable.3.5 1.0
        ttable.4.6 1.0
        ttable.5.7 1.0
        ttable.6.8 1.0
        ttable.7.9 1.0
}

ctl.mixed {
        type hw
        card 0
}

pcm.multi {
        type multi
        slaves.a.pcm "analog-hw"
        slaves.a.channels 2
        slaves.b.pcm "digital-hw"
        slaves.b.channels 8
        bindings.0.slave a
        bindings.0.channel 0
        bindings.1.slave a
        bindings.1.channel 1
        bindings.2.slave b
        bindings.2.channel 0
        bindings.3.slave b
        bindings.3.channel 1
        bindings.4.slave b
        bindings.4.channel 2
        bindings.5.slave b
        bindings.5.channel 3
        bindings.6.slave b
        bindings.6.channel 4
        bindings.7.slave b
        bindings.7.channel 5
        bindings.8.slave b
        bindings.8.channel 6
        bindings.9.slave b
        bindings.9.channel 7
}

ctl.multi {
        type hw
        card 0
}

Here is what I think would work for 4.0 over HDMI and 2 channel analog stereo (untested). This might not be necessary if you use my original 5.1 config and select 4.0 in your XBMC configuration. In fact, now I think about it, the 7.1 script above *should* work for all configurations and adjust itself based on what you select in your XBMC config (4.0, 5.1, 7.1 etc). Not sure though, I will test that theory when I get home from work...

Code:
pcm.analog-hw {
        type hw
        card 0
        device 0
}

ctl.analog-hw {
        type hw
        card 0
}

pcm.digital-hw {
        type hw
        card 0
        device 3
}

ctl.digital-hw {
        type hw
        card 0
}

pcm.!default {
        type plug
        slave {
                pcm multi
                rate 48000
        }
        ttable.0.0 1.0
        ttable.1.1 1.0
        ttable.0.2 1.0
        ttable.1.3 1.0
        ttable.2.4 1.0
        ttable.3.5 1.0
}

ctl.!default {
        type hw
        card 0
}

pcm.mixed {
        type plug
        slave {
                pcm multi
                rate 48000
                channels 6
        }
        ttable.0.0 1.0
        ttable.1.1 1.0
        ttable.0.2 1.0
        ttable.1.3 1.0
        ttable.2.4 1.0
        ttable.3.5 1.0
}

ctl.mixed {
        type hw
        card 0
}

pcm.multi {
        type multi
        slaves.a.pcm "analog-hw"
        slaves.a.channels 2
        slaves.b.pcm "digital-hw"
        slaves.b.channels 4
        bindings.0.slave a
        bindings.0.channel 0
        bindings.1.slave a
        bindings.1.channel 1
        bindings.2.slave b
        bindings.2.channel 0
        bindings.3.slave b
        bindings.3.channel 1
        bindings.4.slave b
        bindings.4.channel 2
        bindings.5.slave b
        bindings.5.channel 3
}

ctl.multi {
        type hw
        card 0
}
Reply
#75
So after some testing tonight the 7.1 asoundrc above works flawlessly, you just need to set the speaker configuration that is relevant to you in XBMC. I tested the 4.0 for you puntloos and it works just fine.

An oddity that I did find though, if you are using any speaker configuration where the center speaker is active you will not get any voice through the 2 channel analog, just music and other sounds as the voices are directed to the center speaker. This can be avoided if you use say 4.0 or any other configuration that does not send audio to a center speaker. I may try a workaround for that.

Image
Reply
  • 1
  • 3
  • 4
  • 5(current)
  • 6
  • 7
  • 15

Logout Mark Read Team Forum Stats Members Help
Almost solved: PROPER Dual Audio on Linux1