Title：How to fix HDMI audio in Android-x86 if it doesn’t work out of the box
Okay. I’m writing this mini tutorial after several hours of reading and trying different things. I hope it works for you too.
Let’s say you have a laptop and boot Android-x86 from there. Maybe from HDD or maybe from USB, I think it doesn’t matter. And you connect your TV to it. You modify Grub to set HDMI-only output (‘video=LVDS-1:d’ did for me), and you get video.
If you then notice you have no sound at all, try this. Oh, and beforehand, have a short WAV file stored in the system.
1) Open a terminal (from Android menu) and ask for root access with ‘su’.
2) Check what number your HDMI card is:
# cat /proc/asound/cards
Generally, “0” is onboard audio and “1” is HDMI.
3) Check which devices are associated to your HDMI card:
# ls -l /dev/snd/
Here you have you take note of all the pcmC*D*p values, where C* is the number of the card from step 2.
4) Activate sound for the card with the following commands:
# 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
In this example, I’m using card “1” (check step 2 for yours).
5) Then, testing. To check which is the correct device you’ll need the WAV file mentioned before:
# alsa_aplay -Dplughw:1,3 /storage/path_to_file/sample.wav
# alsa_aplay -Dplughw:1,7 /storage/path_to_file/sample.wav
# alsa_aplay -Dplughw:1,8 /storage/path_to_file/sample.wav
# alsa_aplay -Dplughw:1,9 /storage/path_to_file/sample.wav
In this example, I checked devices “3”, “7”, “8” and “9” from card “1” (check step 2 for your card, and step 3 for its devices). You’ll hear sound in the right one.
6) When you get the correct device, proceed to edit the boot script to make the changes permanent:
# vi /system/etc/init.sh
Add these lines in the “function init_hal_audio()” section, right below “esac”:
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
mv /dev/snd/pcmC1D3p /dev/snd/pcmC1D3p.original
ln -sf /dev/snd/pcmC1D7p /dev/snd/pcmC1D3p
“c1” is your HDMI card (step 2),
“pcmC1D7p” is your audible device (step 5),
and “pcmC1D3p” is the FIRST one of the card (as seen in step 3).
This will allow you to keep the onboard sound if you choose to boot without HDMI video.
7) Reboot to check if you did everything okay.