Kodi Community Forum

Full Version: Analog multichannel and custom alsa-device: DTS problems
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
edit: I think I solved the problem. For some reason, center and subwoofer channel are reversed in xbmc. Channel number 4 used to be the center, channel 5 the subwoofer - at least that's a correct mapping when checking the surround setup with the tool speaker-test provided by alsa-utils. For some reason, xbmc puts the center to channel number 5 and the sub at channel number 4 Sad

Hello,

I'm quite new to xbmc (coming from mythtv/mythvideo), and I'm trying to configure xbmc to suit my needs.
I am using a custom alsa device instead of the default surround51 for analog multichannel, because my current audio setup lacks a center speaker (I have two stereo amps, one for the front speakers, one for the rear speakers, my subwoofer has its own amp).
The custom device does simple channel routing via $HOME/.asoundrc - it routes the center channel to the front speakers:
Code:
pcm.51to41 {
    type route
    slave.pcm surround51
    slave.channels 6
    ttable.0.0 1
    ttable.1.1 1
    ttable.2.2 1
    ttable.3.3 1
    ttable.4.0 0.8
    ttable.4.1 0.8
    ttable.5.5 1
}
I set analogmultichannel to true in advancedconfig. XBMC seems to default to the surround51 device and ignores the device I specified in the audio configuration in the GUI.
I changed cores/dvdplayer/ALSADirectSound.cpp to use my 51to41 device instead of surround51.
This modification works fine when I play a movie with AC3 sound and I thought I found a workaround for my problem.
For some reason though, XBMC does an output to surround51 instead of 51to41 when I play movies with DTS audio. There is no reference to the surround[51|50|40] in ALSADirectSound.cpp anymore - I replaced it with 51to41. I can't find any more references to surround51 anywhere in the XBMC code.
Is there any chance that I can apply a quick fix somewhere in the sourcecode to make DTS audio use my 51to41 device? Can you give me a hint where I could be looking?

xbmc revision: Built on Nov 19 2008 (SVN:16238)
linux distribution: gentoo-2008.0
arch: x86
kernel: 2.6.27-gentoo-r2 #1 SMP PREEMPT
install method: gentoo ebuild (compiled from svn)
svn revision: 16238
xbmc debug log: http://pastebin.ca/1263412
in your XBMC under sound settings what do you have listed for your device default device.

default being :
default
and
iec958


What are you changing them to enable 5.1 analog outputs?
Thanks
jozwikjp Wrote:in your XBMC under sound settings what do you have listed for your device default device.

default being :
default
and
iec958


What are you changing them to enable 5.1 analog outputs?
Thanks

You have to enable analog multichannel in $HOME/.xbmc/userdata/advancedsettings.xml first (at least I think this is still necessary):

Code:
<advancedsettings>
    <audio>
        <analogmultichannel>true</analogmultichannel>        
    </audio>
</advancedsettings>

You can use whatever device you have available for surround. Most common would be surround51. Check "aplay -L" for what's available on your system.

XBMC really does use the device you specify in the config, I was wrong about that. Turns out that - at least for me - center and subwoofer are mixed up when you're watching something with DTS audio. Check this trac ticket:

http://trac.xbmc.org/ticket/5353

If you have anything with DTS that you could test, I'd appreciate if you could confirm the DTS problem.
Under the the audio settings do you set it to analog or digital?

if digital do you set the passthrough to surround51 which is listed under alist
or just the "Audio Output Device" to surround51 or applicable..

thanks
Joe
Since this thread is about analog output: Set it to analog, audio output device surround51.
Quote:
if(deviceuse == "default")
{
if(iChannels == 6)
deviceuse = "surround51";
else if(iChannels == 5)
deviceuse = "surround50";
else if(iChannels == 4)
deviceuse = "surround40";
}

Thus the code only uses surround51/50/40 if you have your analog device set as default.

The best solution you can do is setup default/surround51... devices using alsa overrides so they work correctly. Our own downmixing/channel reorder code is in the asound.conf file inside our system dir, so you can look there abit if you want to.
elupus Wrote:Thus the code only uses surround51/50/40 if you have your analog device set as default.

Thank you for your reply.
I am sorry that this thread turned out to be so confusing. For AC3 audio, everything works fine, I don't need to patch in my custom device into ALSADirectSound.cpp. The problem is only related to DTS.
Here's what happened to clarify all this:

When I first configured xbmc, I set the analog device to my 51to41 pcm in the gui and started a movie.
The dialog came out of the subwoofer channel and my first impression was that xbmc does not use the 51to41 pcm that I configured. My subwoofer is connected to the stereo jack that carries LFE and center channel. That's why I was under the impression that xbmc did not use the 51to41 pcm that routes the center channel to front left and front right.
I created a pcm called xbmc that swaps center and LFE and I thought that resolved the problem.
The next day I watched something with AC3 audio (which would have worked without the xbmc pcm that I configured) and ended up with LFE and center being swapped (because I configured the xbmc pcm to do exactly this). That's when I found out that the problem is only related to DTS audio.

Here's what I found out about the DTS problem so far:
- the center channel in the DTS stream is mapped to the subwoofer channel
- the subwoofer channel in the DTS stream is routed to nowhere
- rear right in the DTS stream is routed to nowhere (rear right is silent)

This has nothing to do with my messy channel-routing but seems to be an error in either libdts, DVDAudioCodecLibDts or somewhere where I didn't look so far.

elupus Wrote:The best solution you can do is setup default/surround51... devices using alsa overrides so they work correctly. Our own downmixing/channel reorder code is in the asound.conf file inside our system dir, so you can look there abit if you want to.

Thanks, as I mentioned above this was just me being confused because of LFE and center being mixed up.
Thanks for hinting at the asound.conf from xbmc though.
I attached a patch to my ticket that adds support for DTS 5.1 channel mapping:
http://trac.xbmc.org/ticket/5353

Thanks again for pointing at the asound.conf shipped with xbmc, I added a pcm for dts51.
Hi

Any chance you could give exact instructions on how to enable analog multichannel? Everytime i try i get no sound from 5.1 movies but stereo movies work fine.

cheers
harryzimm Wrote:Hi

Any chance you could give exact instructions on how to enable analog multichannel? Everytime i try i get no sound from 5.1 movies but stereo movies work fine.

cheers

Disclaimer: If you're using an abomination like pulseaudio, I can't help you. These instructions assume that you're using alsa without a sound-server on top of it.

Okay, here it is:

You need to make sure that you compiled xbmc from a svn revision >=16076, if you're using atlantis you should be all set unless you want to enjoy movies with DTS audio.
If you have movies with DTS audio, channel mapping for dts has been fixed in r16446, so you have to compile at least that revision.

The next thing you need to do is enable analog multichannel in advancedsettings.xml.
If you haven't touched advancedsettings.xml yet, you have to create it first:
Code:
touch $HOME/.xbmc/userdata/advancedsettings.xml
Add the following to $HOME/.xbmc/userdata/advancedsettings.xml with the text editor of your choice:
Code:
<advancedsettings>
    <audio>
        <analogmultichannel>true</analogmultichannel>
    </audio>
</advancedsettings>

You can start xbmc now and configure the audio via the gui.

Go to Settings -> Videos -> Player -> Configure Audio Hardware
Set Audio Output to analog. The next thing you might need to configure is Audio Output Device. Most people can just set it to surround51.

That's it, you should be getting multichannel output now.

If you have debugging-output enabled, you can make sure that xbmc is using the right device. Play a movie with 5.1 sound and check the log:
Code:
grep CALSADirectSound\ -\ using\ alsa\ device /var/tmp/${USER}-xbmc.log

I created a 20 seconds test movie that has a 5.1 DTS audio track. You can download it from one of those locations for testing purposes:
http://www.steekr.com/n/50-17/share/LNK5...80da0797a/
http://www.box.net/shared/srvt92qk61
The video itself contains just the xbmc logo and the wavs from alsa-util's speaker-test program mixed into a DTS track. If you play it, you should hear a female voice speaking the names of the channels and a slight rumble from your subwoofer after she said "rear left".

I hope that I was able to help... If you have further questions, don't hesitate to ask...
Thanks enkil.

I followed all the steps and it still wouldn't work (using onboard nvidia sound). So i popped in a pci soundblaster and all is good, thanks.

About the dts channel mix up. I have about 20 dts movies and the centre/sub channels vary movie to movie. Some movies work with your patch others work without the patch. Im not sure how to get around this problem using analog audio. (except for manually swapping audio cables).

Anyway thanks for your help.
Drop the patch and use the latest svn revision. The dts-issue should be fixed with svn revision 16446 (http://trac.xbmc.org/changeset/16446). The change in xbmc (hopefully) fixes the dts decoder xbmc is using instead of re-mapping the channels like I did. My workaround is wrong for a dts stream that doesn't have 6 channels. The change in revision 16446 should give you correct channel mapping even if the stream does not have 6 channels (like 4.1 or 5.0).

Most of my movies have dts audio, too. I only checked a few so far with the latest svn revision, but they all worked fine.
But it would be interesting to know if some of yours still have wrong channel mapping after you upgraded xbmc to the latest revision.
Nice one enkil. Just updated to rev-16456 and all dts movies play fine now.

Just want to thank the devs again for some excellent work.

cheers.