If you are trying to play audio on your raspberry pi over hdmi and it is not working then you need to ensure that the raspberry pi is driving your tv or monitor in hdmi mode and not dvi mode. To do this type /opt/vc/bin/tvservice -s
If it’s running HDMI it will print something like state: HPD high|HDMI mode|HDCP off|composite off (0x12001a), 1920×1080 @ 60Hz, progressive
If it’s running DVI it will print something like state: HPD high|DVI mode|HDCP off|composite off (0x120016), 1280×720 @ 60Hz, progressive
This happens because the raspberry pi asks the monitor about itself and deduces the best resolution from this information. To view this information run: /opt/vc/bin/tvservice -d edid /opt/vc/bin/edidparser edid
This will then list the resolutions supported for your display device and the id number and the score for each. CEA (hdmi) are in tv format (1080i etc) and DMT (DVI) in screen resolution (1280×720 etc). Note down the id of the highest scoring CEA resolution.
Open /boot/config.txt and add: hdmi_group=1 hdmi_mode = x # The ID number you noted
Then save, quit and reboot. and /opt/vc/bin/tvservice -s should include “HDMI mode” as above.
I assume that including hdmi_drive=2 does the same thing – automatically choose the highest scorign CEA option.