• 1(current)
  • 2
  • 3
  • 4
  • 5
  • 15
Linux Almost solved: PROPER Dual Audio on Linux
#1
Music 
[Edit March 3rd] - It would be useful if you chime in if you either:
- Have it working perfectly
- Have it working 'with issues' (most notably the 'occasional hiccup bug')
- Can't get it to work (do post your graphics card and/or audio hardware through aplay -l )
- Would love for this to work

If many people chime in it'll be easier to get this feature officially supported rather than this system that isn't officially tested not to break with updates etc)

Through experimenting with asound.conf I've managed to get dual audio working. But with some caveats.

Stuff that works:
- XBMC is sending audio to both my HDMI out, as well as to my stereo out.
- The HDMI audio is surround. This was the hard part.

Stuff that is iffy:
- If you are using passthrough audio (don't.... there is not good reason to do so!) then dual audio might stop working. Not sure why, maybe passthrough mode bypasses asound completely?
- My receiver sometimes every 3-4 mins drops audio for a second, relays clicking (losing encoding detection.. I think). Some people had better success.

Todo:
- See if I can put the hardware config stuff on top of the file (for readability)
- See if some additional buffering can be inserted to fix occasional dropouts. So far whatever I try basically stops everything working (too much buffering?)

My system is a Zotac ZBOX ID80 (Intel Atom D2700 + Nvidia Geforce 520M) running OpenELEC Frodo

To get this to work: (for non-OpenELEC setups configfile paths should be similar, go find them yourself with locate or find / | grep asound.conf )

0/ ssh into your XBMC and run
Code:
aplay -l
to get a list of recognized devices. Sample output:
Code:
**** 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: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

1/ Modify your system's asound.conf ( ./storage/.config/asound.conf ) - in particular edit the hardware config at the bottom to match your hardware from #0. In my case it turned out that I needed card 1 device 3 for HDMI out, and card 0 device 1 for digital out.

Code:
# asound.conf for Dual Audio - HDMI (5.1) + 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 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 "hdmi_hw"
                channels 6
        }
        slaves.b {
                # virtual dac still has 6 channels
                # although I suppose I could try making it 2
                pcm "dac_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.dac_virtual
{
  type route
  slave.pcm dac_hw
  slave.channels 2

  # Front and rear, at 33% of original signal strength
  ttable.0.0 0.33
  ttable.1.1 0.33
  ttable.2.0 0.33
  ttable.3.1 0.33

  # Center channel routing (routed to front-left and front-right),
  # 6dB gaindrop (gain half of main channels) per channel
  ttable.4.0 0.16
  ttable.4.1 0.16

  # LFE channel routing (routed to front-left and front-right),
  # 6dB gaindrop (gain half of main channels) per channel
  ttable.5.0 0.16
  ttable.5.1 0.16
}

# 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 6
}

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

2/ Go into system settings and make sure audio device used is 'default'
3/ Edit advancedsettings.xml (./storage/.xbmc/userdata/advancedsettings.xml) - or create the file if it doesn't exist, and make sure it has these lines
Code:
<advancedsettings>
    <audio>
        <resample>0</resample>
        <audiophile>1</audiophile>
        <audiosinkbufferdurationmsec>200</audiosinkbufferdurationmsec>
        <allowtranscode44100>0</allowtranscode44100>
        <streamsilence>1</streamsilence>

        <dont_resample>1</dont_resample>
        <audiophile>1</audiophile>
    </audio>
</advancedsettings>

For reference my full advancedsettings.xml is here

4/ (optional) Go to audio settings and tell XBMC your receiver ONLY supports LPCM, and not AC3/DTS/etc, and disable passthrough, no good can come from it =) (opinions on this vary wildly but this is my fairly informed opinion)
System: Kodi on NVidia Shield 2015
Video: Panasonic AE3000 Projector / Samsung 46" LCD
Audio: Quad 2912 on Nord DM500Up with Marantz 7010 receiver.
Reply
#2
Just a FYI, anytime now XBMC v12 Frodo is going be out (its beta1) and this will probably not work anymore, because Frodo has AudioEngine and Eden doesn't. AudioEngine will very likely make this not work.

You say your Using Openelec if your on V2 it has Eden.

Good effort if it works past Eden though, and probably worth a wiki inclusion if it does work.

uNi
Reply
#3
(2012-11-17, 11:18)uNiversal Wrote: Just a FYI, anytime now XBMC v12 Frodo is going be out (its beta1) and this will probably not work anymore, because Frodo has AudioEngine and Eden doesn't. AudioEngine will very likely make this not work.

You say your Using Openelec if your on V2 it has Eden.

Good effort if it works past Eden though, and probably worth a wiki inclusion if it does work.

uNi

Actually this is on Frodo. I'm running OpenELEC Version: devel-20121016142319-r12188
System: Kodi on NVidia Shield 2015
Video: Panasonic AE3000 Projector / Samsung 46" LCD
Audio: Quad 2912 on Nord DM500Up with Marantz 7010 receiver.
Reply
#4
The channel mapping there's two PR's one of them MAY address this, idk, but nothing is going with that atm https://github.com/xbmc/xbmc/pull/1490

The receiver sometimes keeps on clicking its relays (losing AC3 detection.. you should try to add streamsilence to advancedsettings.xml

http://wiki.xbmc.org/index.php?title=AudioEngine

If you manage to get it working and update your post, Ill try to add it to wiki.

Thanks

uNi
Reply
#5
(2012-11-17, 15:49)uNiversal Wrote: The channel mapping there's two PR's one of them MAY address this, idk, but nothing is going with that atm https://github.com/xbmc/xbmc/pull/1490

Looks like a good lead, I'll look into it, thanks.

Quote:The receiver sometimes keeps on clicking its relays (losing AC3 detection.. you should try to add streamsilence to advancedsettings.xml

http://wiki.xbmc.org/index.php?title=AudioEngine

I'll give it a try but actually it also occurs occasionally during playback. It seems more like a buffering problem to me, so I'll try to add a few
period_time 0
period_size 1024
buffer_size 8192
type statements, see if that helps any

Quote:If you manage to get it working and update your post, Ill try to add it to wiki.

System: Kodi on NVidia Shield 2015
Video: Panasonic AE3000 Projector / Samsung 46" LCD
Audio: Quad 2912 on Nord DM500Up with Marantz 7010 receiver.
Reply
#6
AE is buggy, unsurprisingly for its maturity and complexity, streamsilence qualms some of those bugs, though not all. Very likely it will serve yours well.

uNi
Reply
#7
(2012-11-17, 16:35)uNiversal Wrote: AE is buggy, unsurprisingly for its maturity and complexity, streamsilence qualms some of those bugs, though not all. Very likely it will serve yours well.

uNi
You were partially right at least Wink
streamsilence fixed the rapid clicking (once every 4-5 seconds) when nothing was playing
but there are still occasional clicks during actual playback. Once every 4-5 minutes maybe, and this didn't happen without my asound.conf

My theory currently is that my asound.conf introduces some type of latency into the system that screws with my receiver.

System: Kodi on NVidia Shield 2015
Video: Panasonic AE3000 Projector / Samsung 46" LCD
Audio: Quad 2912 on Nord DM500Up with Marantz 7010 receiver.
Reply
#8
Quick update:

- Ha, the surround 'problem' where the rear channels come from the front too is actually present on my system without my custom asound.conf too. I seem to remember seeing this before but might have to hunt for the solution again.
- Like mentioned, I think the popping problem has to do with buffering, but if I add any buffer statements to my asound.conf my receiver basically switches off (silence). Either I'm breaking asound.conf (putting the buffer statements in a wrong spot) or buffers break the already fragile setup. Asound is hard to debug, very little debugging output. Any asound experts in the house?
System: Kodi on NVidia Shield 2015
Video: Panasonic AE3000 Projector / Samsung 46" LCD
Audio: Quad 2912 on Nord DM500Up with Marantz 7010 receiver.
Reply
#9
I have added this to the wiki and pointed to this topic as a discussion on this matter.

see http://wiki.xbmc.org/index.php?title=XBM...udio_setup

If you get any results please update your main post with more detailed information. I'm sure lots of people are interested in this or were interested. Either way this is good information and should be available to all.

thank you in advance.
Reply
#10
I have added the asound.conf to my system (running latest openelec Frodo Release), But i'm not sure what to set in xbmc for it to use the new settings? Any assistance would be appreciated. I'm running ZBOX-ID41 and trying to get audio out HDMI and analog headphone jack.
Reply
#11
In your system settings, if things work OK, there should be a new audio device. It's been a little while (been busy) but I think it's simply called 'default'.

Try a couple while playing music.
System: Kodi on NVidia Shield 2015
Video: Panasonic AE3000 Projector / Samsung 46" LCD
Audio: Quad 2912 on Nord DM500Up with Marantz 7010 receiver.
Reply
#12
I have the same setup as DoubleD and also was unable to get this to work. No matter what I chose, I couldn't get the HDMI audio to output (the analog worked fine). I eventually gave up on it Undecided
Reply
#13
Oh!

Before I forget. You did modify the bottom section right? This part:

Code:
# And here is my actual hardware
# HDMI output
pcm.hdmi_hw {
        type hw
        card 1
        device 3
        channels 6
}

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

In particular you need to set it to the card+device of both your devices.. Either find online somewhere, try manually (there shouldnt be THAT many combinations try device 0-6 and card 0-2) or ssh in and ask your system what devices it has. - run 'aplay -l'
System: Kodi on NVidia Shield 2015
Video: Panasonic AE3000 Projector / Samsung 46" LCD
Audio: Quad 2912 on Nord DM500Up with Marantz 7010 receiver.
Reply
#14
I'll re-run that tonight to double-check I'm doing things right. Thanks for the quick reply!
Reply
#15
aplay -l gives me the following:

Code:
root ~ # aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC888 Analog [ALC888 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: ALC888 Digital [ALC888 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 7: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 8: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 9: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

So, with that in mind, I setup my pcm.hdmi_hw the same as puntloos does and I change to the dac_hw to 0/0/2 (since I want the sound to be from the analog headphone output).

Even after that I can only get one or the other to work. In the "Audio Output" settings I have:

HDMI
5.1
Audio Output Device -- Default (HDA NVidia HDMI 0)
Passthrough -- HDA NVidia, MEI Panasonic-TV on HDMI #1

this setup works to get audio out of the analog output, but the HDMI output does not produce any sound. If I switch so that the "Audio Output Device" is the same as the Passthrough device (HDMI #1), then I can get sound via HDMI, but not out of the headphones.

Perhaps this has to do with the fact that I'm going from HTPC --> Yamaha receiver --> TV?
Reply
  • 1(current)
  • 2
  • 3
  • 4
  • 5
  • 15

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