Setup HDMI 5.1 Surround Sound

379 views
Skip to first unread message

Florian E

unread,
Mar 27, 2018, 5:25:43 AM3/27/18
to Android-x86
Hey,

i'm trying to setup 5.1 PCM sound profile.
In Ubuntu i can switch to "Digital Surround 5.1 (HDMI 2) Output" and my device is streaming 5.1 PCM Multichannel just fine.

Any Idea how to manage this in Android x86?


youling 257

unread,
Mar 27, 2018, 5:46:24 AM3/27/18
to Android-x86
alsa_amixer -c0 contents or -c1

which "HDMI/DP,pcm=xxx Jack" is on ?

for example,

alsa_amixer -c1 set 'IEC958',0 on
alsa_amixer -c1 set 'IEC958',1 on
alsa_amixer -c1 set 'IEC958',2 on
alsa_amixer -c1 set 'IEC958',3 on
setprop hal.audio.out pcmC1D7p
killall audioserver

在 2018年3月27日星期二 UTC+8下午5:25:43,Florian E写道:

Florian E

unread,
Mar 27, 2018, 6:54:54 AM3/27/18
to Android-x86

alsa_amixer -c0 contents output is:
 
1|x86_64:/ # alsa_amixer -c0 contents
numid=37,iface=CARD,name='HDMI/DP,pcm=10 Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=off
numid=13,iface=CARD,name='HDMI/DP,pcm=3 Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=off
numid=19,iface=CARD,name='HDMI/DP,pcm=7 Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=on
numid=25,iface=CARD,name='HDMI/DP,pcm=8 Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=off
numid=31,iface=CARD,name='HDMI/DP,pcm=9 Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=off
numid=10,iface=CARD,name='Headphone Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=off
numid=9,iface=CARD,name='Mic Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=off
numid=2,iface=MIXER,name='Master Playback Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=1,iface=MIXER,name='Master Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=87,step=0
  : values=87,87
  | dBscale-min=-65.25dB,step=0.75dB,mute=0
numid=8,iface=MIXER,name='Mic Boost Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=3,step=0
  : values=1,1
  | dBscale-min=0.00dB,step=10.00dB,mute=0
numid=5,iface=MIXER,name='Mic Playback Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=off,off
numid=4,iface=MIXER,name='Mic Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=31,step=0
  : values=0,0
  | dBscale-min=-34.50dB,step=1.50dB,mute=0
numid=7,iface=MIXER,name='Capture Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=6,iface=MIXER,name='Capture Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=63,step=0
  : values=51,51
  | dBscale-min=-17.25dB,step=0.75dB,mute=0
numid=3,iface=MIXER,name='Loopback Mixing'
  ; type=ENUMERATED,access=rw------,values=1,items=2
  ; Item #0 'Disabled'
  ; Item #1 'Enabled'
  : values=0
numid=14,iface=MIXER,name='IEC958 Playback Con Mask'
  ; type=IEC958,access=r-------,values=1
  : values=[AES0=0x0f AES1=0xff AES2=0x00 AES3=0x00]
numid=20,iface=MIXER,name='IEC958 Playback Con Mask',index=1
  ; type=IEC958,access=r-------,values=1
  : values=[AES0=0x0f AES1=0xff AES2=0x00 AES3=0x00]
numid=26,iface=MIXER,name='IEC958 Playback Con Mask',index=2
  ; type=IEC958,access=r-------,values=1
  : values=[AES0=0x0f AES1=0xff AES2=0x00 AES3=0x00]
numid=32,iface=MIXER,name='IEC958 Playback Con Mask',index=3
  ; type=IEC958,access=r-------,values=1
  : values=[AES0=0x0f AES1=0xff AES2=0x00 AES3=0x00]
numid=38,iface=MIXER,name='IEC958 Playback Con Mask',index=4
  ; type=IEC958,access=r-------,values=1
  : values=[AES0=0x0f AES1=0xff AES2=0x00 AES3=0x00]
numid=15,iface=MIXER,name='IEC958 Playback Pro Mask'
  ; type=IEC958,access=r-------,values=1
  : values=[AES0=0x0f AES1=0x00 AES2=0x00 AES3=0x00]
numid=21,iface=MIXER,name='IEC958 Playback Pro Mask',index=1
  ; type=IEC958,access=r-------,values=1
  : values=[AES0=0x0f AES1=0x00 AES2=0x00 AES3=0x00]
numid=27,iface=MIXER,name='IEC958 Playback Pro Mask',index=2
  ; type=IEC958,access=r-------,values=1
  : values=[AES0=0x0f AES1=0x00 AES2=0x00 AES3=0x00]
numid=33,iface=MIXER,name='IEC958 Playback Pro Mask',index=3
  ; type=IEC958,access=r-------,values=1
  : values=[AES0=0x0f AES1=0x00 AES2=0x00 AES3=0x00]
numid=39,iface=MIXER,name='IEC958 Playback Pro Mask',index=4
  ; type=IEC958,access=r-------,values=1
  : values=[AES0=0x0f AES1=0x00 AES2=0x00 AES3=0x00]
numid=16,iface=MIXER,name='IEC958 Playback Default'
  ; type=IEC958,access=rw------,values=1
  : values=[AES0=0x04 AES1=0x00 AES2=0x00 AES3=0x00]
numid=22,iface=MIXER,name='IEC958 Playback Default',index=1
  ; type=IEC958,access=rw------,values=1
  : values=[AES0=0x04 AES1=0x00 AES2=0x00 AES3=0x00]
numid=28,iface=MIXER,name='IEC958 Playback Default',index=2
  ; type=IEC958,access=rw------,values=1
  : values=[AES0=0x04 AES1=0x00 AES2=0x00 AES3=0x00]
numid=34,iface=MIXER,name='IEC958 Playback Default',index=3
  ; type=IEC958,access=rw------,values=1
  : values=[AES0=0x04 AES1=0x00 AES2=0x00 AES3=0x00]
numid=40,iface=MIXER,name='IEC958 Playback Default',index=4
  ; type=IEC958,access=rw------,values=1
  : values=[AES0=0x04 AES1=0x00 AES2=0x00 AES3=0x00]
numid=17,iface=MIXER,name='IEC958 Playback Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=23,iface=MIXER,name='IEC958 Playback Switch',index=1
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=29,iface=MIXER,name='IEC958 Playback Switch',index=2
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=35,iface=MIXER,name='IEC958 Playback Switch',index=3
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=41,iface=MIXER,name='IEC958 Playback Switch',index=4
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=12,iface=PCM,name='Capture Channel Map'
  ; type=INTEGER,access=r----R--,values=2,min=0,max=36,step=0
  : values=0,0
  |     | TLV size error (257, 8, 0)!

numid=11,iface=PCM,name='Playback Channel Map'
  ; type=INTEGER,access=r----R--,values=2,min=0,max=36,step=0
  : values=0,0
  |     | TLV size error (257, 8, 0)!

numid=18,iface=PCM,name='ELD',device=3
  ; type=BYTES,access=r--v----,values=0
  : values=
numid=43,iface=PCM,name='Playback Channel Map',device=3
  ; type=INTEGER,access=rw---R--,values=8,min=0,max=36,step=0
  : values=0,0,0,0,0,0,0,0
  |     | TLV size error (258, 8, 0)!

numid=24,iface=PCM,name='ELD',device=7
  ; type=BYTES,access=r--v----,values=52
  : values=0x10,0x00,0x0c,0x00,0x68,0x86,0x00,0x4f,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x3d,0xcb,0x42,0x0b,0x54,0x58,0x2d,0x4e,0x52,0x35,0x30,0x39,0x09,0x7f
,0x07,0x0f,0x7f,0x07,0x17,0x07,0x50,0x3f,0x06,0xc0,0x4d,0x02,0x00,0x57,0x06,0x00
,0x5f,0x7e,0x01,0x67,0x54,0x00
numid=44,iface=PCM,name='Playback Channel Map',device=7
  ; type=INTEGER,access=rw---R--,values=8,min=0,max=36,step=0
  : values=0,0,0,0,0,0,0,0
  |     | TLV size error (258, 8, 0)!

numid=30,iface=PCM,name='ELD',device=8
  ; type=BYTES,access=r--v----,values=0
  : values=
numid=45,iface=PCM,name='Playback Channel Map',device=8
  ; type=INTEGER,access=rw---R--,values=8,min=0,max=36,step=0
  : values=0,0,0,0,0,0,0,0
  |     | TLV size error (258, 8, 0)!

numid=36,iface=PCM,name='ELD',device=9
  ; type=BYTES,access=r--v----,values=0
  : values=
numid=46,iface=PCM,name='Playback Channel Map',device=9
  ; type=INTEGER,access=rw---R--,values=8,min=0,max=36,step=0
  : values=0,0,0,0,0,0,0,0
  |     | TLV size error (258, 8, 0)!

numid=42,iface=PCM,name='ELD',device=10
  ; type=BYTES,access=r--v----,values=0
  : values=
numid=47,iface=PCM,name='Playback Channel Map',device=10
  ; type=INTEGER,access=rw---R--,values=8,min=0,max=36,step=0
  : values=0,0,0,0,0,0,0,0
  |     | TLV size error (258, 8, 0)!



If i use alsa_aplay -D plughw:CARD=PCH,DEV=7 test.wav it plays on 5.1 multichannel, but the speaker order is not correct. (Center is Subwoofer, FL is Center ...)

youling 257

unread,
Mar 27, 2018, 7:59:21 AM3/27/18
to Android-x86
setprop hal.audio.out pcmC0D7p
killall audioserver

as i know,you can't use Android adjust HDMI volume.

在 2018年3月27日星期二 UTC+8下午6:54:54,Florian E写道:
Message has been deleted

Florian E

unread,
Mar 27, 2018, 8:33:18 AM3/27/18
to Android-x86
This works but i still only have stereo sound, no 5.1

if i play the wav file with aplay 5.1 works
if i play it with mediacodec / vlc / ijkplayer the file only plays in stereo.

any further ideas?

youling 257

unread,
Mar 27, 2018, 8:35:29 AM3/27/18
to Android-x86
when i hear ac3,i thought "MX Player AC3 & DTS Custom Codec"

Florian E

unread,
Mar 27, 2018, 8:48:20 AM3/27/18
to Android-x86
For testing i also use those *.wav files from the frauenhofer iis:


with alsa_aplay everything is ok - with mediaplayer its only stereo 

youling 257

unread,
Mar 27, 2018, 9:19:42 AM3/27/18
to Android-x86
try Kodi,setting audio number channel

在 2018年3月27日星期二 UTC+8下午8:48:20,Florian E写道:

Florian E

unread,
Mar 27, 2018, 9:42:29 AM3/27/18
to Android-x86
thanks for the hint - I did,

even with enabled stereo upmixing and setting it fixed to 5.1 - still stereo output.

Florian E

unread,
Mar 28, 2018, 2:41:52 AM3/28/18
to Android-x86
Android says it's possible to set the flag AUDIO_OUTPUT_FLAG_DIRECT in audio_policy.conf to bypass audioflinger


but that's not working, seems the property to set the correct output device is also bypassed now

Get this in logcat:

W APM_AudioPolicyManager: getOutput() could not find output for stream 3, samplingRate 0,format 0, channels 3, flags 0



youling 257

unread,
Mar 28, 2018, 5:12:18 AM3/28/18
to Android-x86
edit /system/etc/audio_policy.conf

audio_hw_modules {
  primary {
    outputs {
      primary {
        sampling_rates 48000
        channel_masks AUDIO_CHANNEL_OUT_5POINT1

then killall audioserver

在 2018年3月28日星期三 UTC+8下午2:41:52,Florian E写道:

Florian E

unread,
Mar 28, 2018, 5:23:54 AM3/28/18
to Android-x86
Did that,
no changes.

i also recompiled AudioMixer.cpp with verbose log it always says:

AudioMixer: Track 0 needs downmix

somewhere there has to be another setting saying the system is not multichannel capable


Florian E

unread,
Mar 28, 2018, 10:55:22 AM3/28/18
to Android-x86
Seems after setting the new output device and killall audioserver the playback mixerthread is not updated

logcat says:

3637  3637 V AudioFlinger: mSampleRate=48000, mChannelMask=0x3, mChannelCount=2, mFormat=1, mFrameSize=4, mFrameCount=512, mNormalFrameCount=1024

So the playback thread keeps setup on 2 channels. this line comes after every server restart

i tried setting the mChannelMask to AUDIO_CHANNEL_OUT_5POINT1 in AudioFlinger::openOutput - but output keeps on 2 channels.

any dev here who can help me figure this out?

Florian E

unread,
Mar 29, 2018, 9:00:32 AM3/29/18
to Android-x86
I tried a few things now but no success so far.
for me it all looks like a configuration is missing somewhere.

it seems there is a different audio_hw.c in 

/hardware/intel/audio_media/hdmi/tinyaudio_hw.c

but i couln't find out if this is even used or not.
does anyone got a hint for me where to continue?

Chih-Wei Huang

unread,
Mar 29, 2018, 10:29:37 PM3/29/18
to Android-x86
2018-03-29 21:00 GMT+08:00 'Florian E' via Android-x86
<andro...@googlegroups.com>:
> I tried a few things now but no success so far.
> for me it all looks like a configuration is missing somewhere.
>
> it seems there is a different audio_hw.c in
>
> /hardware/intel/audio_media/hdmi/tinyaudio_hw.c

This is only used for intel-hdmi-lpe device.
Basically you should check hardware/libaudio/.

> but i couln't find out if this is even used or not.
> does anyone got a hint for me where to continue?

I'm afraid you asked a topic that
nobody has ever tried in android-x86.
Welcome to debug and fix it.



--
Chih-Wei
Android-x86 project
http://www.android-x86.org

Florian E

unread,
Mar 30, 2018, 9:15:52 AM3/30/18
to Android-x86
thanks for your answer,

i'll try to set it up modifing audio_hw.c (out_write mainly i think)
do you know whats the DOBLY_ENABLE flag is used for? i saw it a few times in the av folder.

is there a fast way to rebuild hardware/libaudio? it doesn't seem to change anything if i use mma here and replace lib, lib64 an bin from out folders on my device.
only rebuilding all seem to use the new code so far and this takes 4:30h 

Chih-Wei Huang

unread,
Mar 30, 2018, 11:20:09 PM3/30/18
to Android-x86
2018-03-30 21:15 GMT+08:00 'Florian E' via Android-x86
<andro...@googlegroups.com>:
> thanks for your answer,
>
> i'll try to set it up modifing audio_hw.c (out_write mainly i think)
> do you know whats the DOBLY_ENABLE flag is used for? i saw it a few times in
> the av folder.

No idea.

> is there a fast way to rebuild hardware/libaudio? it doesn't seem to change
> anything if i use mma here and replace lib, lib64 an bin from out folders on
> my device.

You can just build the module by specifying its name:

m -j8 audio.primary.x86


> only rebuilding all seem to use the new code so far and this takes 4:30h

Should not take so long in the later incremental build.

Florian E

unread,
Apr 3, 2018, 8:47:50 AM4/3/18
to Android-x86
In the end it was quite easy to set up.
Just change

out_get_channels
and
pcm_config_out

in audio_hw.c to your needs.

i just needed to find out that lib/hw/ is used instead of lib64/hw even it's a 64bit build.

now it's working
Reply all
Reply to author
Forward
0 new messages