ALSA Not Selecting Correct Output Channel Map

Bug #1296017 reported by Grant
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
alsa-driver (Ubuntu)
Expired
Undecided
Unassigned

Bug Description

Hi All
As preface to this question, please know that I'm a complete noob with Linux - forgive my lack of understanding the basics, and any dumb questions that may give rise to.

The issue - possible ALSA driver bug - is experienced when running xbmc, via OpenELEC. Playback of multichannel FLAC files is failing with 4.0-CH surround music (ie: Quadraphonic). PB fails inasmuch as xbmc sends the audio (MCH-PCM > HDMI > AVR) in a format incompatible with the AVR.

After much dialogue with the relevant xbmc devs, I've been told this is a driver problem (ALSA), and to report it here at Launchpad.
(FYI: discussion begins here -> http://forum.xbmc.org/showthread.php?tid=170338&pid=1638835#pid1638835, see posts by "gjwAudio" )

What Happens:
4.0 audio is output over HDMI as FL,FR,BL,BR, but my AVR does not recognize this format, and defaults to 2-CH (stereo) - no back channel information.

What Should Happen:
4.0 audio should be sent as 5.1 PCM, with appropriate "extra" channels muted.

Hypothesis:
ALSA is not flagging 4.0 channel map as invalid for this receiver (based on audio-related EDID info), and xbmc configures 1:1 output mapping (FL,FR,BL,BR > FL,FR,BL,BR).

Testing in OpenELEC:
Three FLAC sample files were used: 3.0, 4.0 and 5.1 channels. xbmc configured both 3.0 & 5.1 files as 5.1 PCM, and played correctly through the AVR. The 4.0 file was configured 1:1, and the back channels failed to play.

When setting xbmc for global fixed output of 5.1 channels, all three files played correctly - however, this fixed setting also locks the sample rate, and forces unnecessary re-sampling, depending on the particular song being played. It also prevents legitimate upmixing of 2.0 video soundtracks to "surround".

The xbmc devs explain the behaviour thus:
( http://forum.xbmc.org/showthread.php?tid=170338&pid=1651346#pid1651346 )
"This happens when opening 3.0 (FL,FR,FC)
  - you can't have gaps, and in ALSA map, FC is at pos 5 (FL,FR,BL,BR,FC)
  - only even numbers of channels are allowed

This is why 3.0 opens as 5.1.

4.0 as FL,FR,BL,BR is valid, and most devices don't have issues with this. We can't just open 5.1 for this case. "

  --and-- (regarding the new audio engine "ActiveAE")
( http://forum.xbmc.org/showthread.php?tid=170338&pid=1651708#pid1651708 )
"ActiveAE plays no role in this scenario. It is the ALSA sink and the driver. The driver should not open in 4.0 mode if the device does not support it. This needs to be fixed in the driver. Others will complain if we opened 4.0 as 5.1 because this would disable upmixing in the AVR. "

  --and--
( http://forum.xbmc.org/showthread.php?tid=170338&pid=1655015#pid1655015 )
"If you don't have configured fixed mode, XBMC tries to open the channels layout with best match to the input stream. In case this is FL,FR,BL,BR - which also matches ALSA channel map, we try to open this layout. If the audio device does not support this format, ALSA should fail opening. Then we try the next layout which would be 5.1 in this case."

  --and--
( http://forum.xbmc.org/showthread.php?tid=170338&pid=1655895#pid1655895 )
"If ALSA opens that mask, then that's a driver problem and should be reported upstream to the ALSA devs."

Testing in Windows:
As another check on the xbmc audio output logic, I was asked to run the same FLACs through a Windows install (same beta release version of xbmc).

All files played correctly under Windows. Please note the "5.1 PCM" indicator lit up on the AVR, for every file. This suggests the correct EDID info was available to xbmc through the Windows driver(s).

Linux Setup:
OpenELEC v4.0 beta 2 (Gotham) - Generic x86_64; Intel 847 Celeron NUC, KVR1333D3S9/4G RAM, Kingston SMS200S3/30G mSATA > 2m HDMI > Anthem Statement D2 (AVR) > Samsung PN51E6500.

Windows Setup:
xbmc v13.0 beta2 (Gotham), Asus X502C - i3-3217U, 4 GB RAM, Intel HD 4000 graphics, Win 8.1 > 2m HDMI > Anthem Statement D2 (AVR) > Samsung PN51E6500.

It is useful to know, the same fault occurs under OpenELEC stable build v3.x.

I hope this is enough information to begin looking into why the EDID info is not getting through to the xbmc software.

Thanks in advance for your help and consideration.
Grant

Sample FLACs:
https://db.tt/AaMpYdPJ
https://db.tt/DfNjgb1t
https://db.tt/n40qUvHI

Revision history for this message
Raymond (superquad-vortex2) wrote :

post the out put of alsa-info.sh

xrandr --verbose

this depend on whether your HDMI codec support multi channel LPCM and your HDMI monitor/receiver 's EDID has speaker allocation pass to your graphic driver , the graphic driver extract SAD from EDID and pass ELD to audio driver

https://lkml.org/lkml/2013/10/31/326

Changed in alsa-driver (Ubuntu):
status: New → Incomplete
Revision history for this message
Grant (gjwaudio1) wrote :

Thank you Raymond, for your reply, and describing the info path from EDID to audio driver.

Not sure if this affects audio issue, but I should mention I'm using xorg.conf to add a screen mode (1920x1080@60p), which seems to be absent from the EDID. The AVR (Anthem Statement D2) includes a Gennum VXP video processor, and is quite capable of accepting anything up to this resolution.

Anthem specifies the D2 supports HDMI v1.1 (including PCM 24/96 Stereo & six-channel PCM 24/96).

Please see below the ALSA-info and xrandr outputs as requested.

Thanks.

Revision history for this message
Grant (gjwaudio1) wrote :
Revision history for this message
Raymond (superquad-vortex2) wrote :

control.12 {
  iface PCM
  device 7
  name ELD
  value '10000b006c32000f000000000000000040ed000053746174656d656e742044320d1f07151fff3d1fff000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
  comment {
   access 'read volatile'
   type BYTES
   count 83
  }
 }

did you find the speaker allocation ?

cat /proc/asound/card0/eld#*.*

you can query the channel map using

http://git.alsa-project.org/?p=alsa-lib.git;a=blob_plain;f=test/chmap.c;hb=HEAD

Revision history for this message
Raymond (superquad-vortex2) wrote :

HDMI2 connected 1920x1080+0+0 (0x4c) normal (normal left inverted right x axis y axis) 930mm x 523mm
        Identifier: 0x45
        Timestamp: -345342475
        Subpixel: unknown
        Gamma: 1.0:1.0:1.0
        Brightness: 1.0
        Clones:
        CRTC: 0
        CRTCs: 0 1
        Transform: 1.000000 0.000000 0.000000
                    0.000000 1.000000 0.000000
                    0.000000 0.000000 1.000000
                   filter:
        EDID:
                00ffffffffffff0040ed000000000000
                0011010380703f780aee91a3544c9926
                0f5054254b00814f7140a94fa9408180
                8140714f3119011d007251d01e206e28
                5500a20b3200001e011d00bc52d01e20
                b8285540a20b3200001e000000fc0053
                746174656d656e742044320a000000fd
                0017560e670e000a20202020202001b5
                02032cf4528182838485868790919293
                9495969fa0a1a2290d1f07151fff3d1f
                ff830f000066030c002200808c0aa014
                51f01600267c4300a20b320000988c0a
                a02051201810187e2300a20b32000098
                011d8018711c1620582c2500a20b3200
                009e011d80d0721c1620102c2580a20b
                3200009e000000000000000000000088
        Broadcast RGB: Automatic
                supported: Automatic, Full, Limited 16:235
        audio: auto
                supported: force-dvi, off, auto, on

edid seem ok

 Audio data block
    Linear PCM, max channels 5
    Supported sample rates (kHz): 96 88.2 48 44.1 32
    Supported sample sizes (bits): 24 20 16
    AC-3, max channels 5
    Supported sample rates (kHz): 96 88.2 48 44.1 32
    Maximum bit rate: 248 kHz
    DTS, max channels 5
    Supported sample rates (kHz): 96 88.2 48 44.1 32
    Maximum bit rate: 248 kHz
  Speaker allocation data block

Revision history for this message
Grant (gjwaudio1) wrote :
Revision history for this message
Grant (gjwaudio1) wrote :

Hi Raymond - sorry, but I cannot understand what I do to run the channel map script you linked to above (recall: severe NooB at everything Linux).

I copied the code to a file on the OE system ( ~/.xbmc/userdata/channelmap ), but no joy trying to run it.

Thanks for your patience.

Revision history for this message
Grant (gjwaudio1) wrote :

Hi Raymond

01). I am stuck trying to query the channel map. chmap script won't run on my OpenELEC system. Here's what the SSH session did:
> -------------------------------------------------------------------------------------
> login as: root
> root@192.168.0.170's password:
> ##############################################
> # OpenELEC - The living room PC for everyone #
> # ...... visit http://www.openelec.tv ...... #
> ##############################################
> OpenELEC (official) Version: 3.95.2
> OpenELEC:~ # cd ~/.xbmc/userdata
> OpenELEC:~/.xbmc/userdata # ./chmap
> ./chmap: line 228: /usr/bin/sed: not found
> ./chmap: line 228: /usr/bin/sed: not found
> ./chmap: cd: line 1: can't cd to
> /home/integer0/projects/misc/chmap/alsa-lib/test
> ./chmap: eval: line 1: gcc: not foundnOpenELEC:~/.xbmc/userdata #
> -------------------------------------------------------------------------------------

Is there a way to make this portable enough to run on my stripped down system ?

02). Regarding the Audio data block you extracted from EDID above:

a). Although "max channels" value is specified, what enumerates specific configurations supported by the device ?

In my case, 2.0 and 5.1 are the only recognized channel maps. Since the AVR is "only" HDMI v1.1 compatible, is it possible the EDID does not transmit full channel map info ?

b). Would it be possible to create a "full spec" EDID.BIN (to use as override), that reflects the D2's available channel formats, and thus cause ALSA to send the 4.0 material on 5.1 mapping ?

Thank you for helping.

Grant (gjwaudio1)
description: updated
Revision history for this message
Raymond (superquad-vortex2) wrote :

did you install libasound2-dev and compile chmap.c ?

gcc chmap.c -o chmap -l asound

Revision history for this message
Raymond (superquad-vortex2) wrote :
Revision history for this message
David Henningsson (diwic) wrote :

Hi,

You have filed this bug in the Ubuntu bugtracker, but you don't seem to be running Ubuntu. Is this a problem in Ubuntu 14.04 as well?

Revision history for this message
Grant (gjwaudio1) wrote :

Hi David

I was sent here by people who know WAY more than I about Linux. They stated my issue was occurring at the driver level, and so "get thee to the ALSA people" was my instruction.

Is this a problem in Ubuntu - I can only suggest you take my 3 sample files (linked above) and try it.

The interaction between xbmc and ALSA is what I'm trying to clarify, for that's where something is happening/not happening to give me a problem (as descried above).

HTH.

Revision history for this message
David Henningsson (diwic) wrote :

> I was sent here by people who know WAY more than I about Linux. They stated my issue was occurring at the driver level, and so
> "get thee to the ALSA people" was my instruction.

The ALSA people are here: http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

Revision history for this message
Raymond (superquad-vortex2) wrote :
Revision history for this message
Grant (gjwaudio1) wrote :

@David
With all due respect, I want to report a bug in ALSA, and I don't understand how joining a developers mailing list will further that goal. Please keep in mind I know very little about the whole Linux world, so where to go, and who to contact about a driver problem is... a problem :)

The initial link I was given (https://bugs.launchpad.net/bugs/bugtrackers/alsa-mantis) took me to a page without any "report bug" action I could find. All roads link to "https://bugtrack.alsa-project.org/alsa-bug" - a dead end.

Search-engine-ing "ALSA" lead me here, where such a button existed. Clearly I need help in getting the right info to the right people. Including diagnostics on my limited-capability OS (http://openelec.tv/).

Thank you for patience and any advice.

Revision history for this message
Grant (gjwaudio1) wrote :

@Raymond
Sorry for slow reply.

> did you install libasound2-dev and compile chmap.c ?
> gcc chmap.c -o chmap -l asound

OpenELEC (OE) is designed to do one thing - run xbmc - and the creators have stripped out much of the usual Linux environment, and block things like apt-get. I don't think there is any way to compile on OE.

I am aware of the even-numbers-only channel mapping in ALSA, but thank you for pointing to a definitive reference.

The upmix code you link to has no use in this discussion.

As in post #8 above: Is there a way to compile chmap.c into a portable (standalone) script, that could be run on my OE machine ?

Thanks again for your help.

Revision history for this message
David Henningsson (diwic) wrote :

 > With all due respect, I want to report a bug in ALSA, and I don't understand how joining a developers mailing list will further
 > that goal.

Well, if you want the bug fixed (and not only reported), go where the developers are.

 > The initial link I was given (https://bugs.launchpad.net/bugs/bugtrackers/alsa-mantis) took me to a page without any "report
 > bug" action I could find. All roads link to "https://bugtrack.alsa-project.org/alsa-bug" - a dead end.

Aha. This bug tracker has been discontinued, because nobody had time to look after it. I now updated the launchpad page to reflect that. Thanks for the heads up.

 > Please keep in mind I know very little about the whole Linux world, so where to go, and who to contact about a driver problem
 > is... a problem :)

Yeah, it can be bewildering. As a general rule of thumb:

 1) contact your Linux distribution first, in your case, that would be OpenELEC. Do they have a mailinglist, a bug tracker, etc? You might want to do a little research first, see if other bugs reported are answered/taken care of, or if it all seems dead.

 2) the people at your Linux distribution might advise you to contact upstream, in your case ALSA. If ALSA had a working bug tracker, that would be the place to go. They don't, which is why I recommended you to try the alsa-devel mailinglist instead. That said, that is not a guarantee for success either - almost every project could use more qualified people. Sometimes the right few people that can solve your problem are just busy doing something else.

(Note to people googling this five years from now :-) Remember that these things can change rapidly. Maybe in five years there'll be another recommended way to contact the ALSA developers.)

But hey - welcome to Linux! :-) I hope you'll find some community, place, distro etc where you find some nice people to collaborate with, about interesting things. Enjoy!

Revision history for this message
Grant (gjwaudio1) wrote :

Hi David

Thank you for clearing up my bugtracker confusion. I've got in touch with an ALSA team member, and I'm sure he can help work out a solution.

As a consolation prize, if it's a driver level fix, the Ubuntu People should eventually benefit too :)

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for alsa-driver (Ubuntu) because there has been no activity for 60 days.]

Changed in alsa-driver (Ubuntu):
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.