Greetings all.
I supposed this is sort of the opposite of a bug report, because I'm trying to find out how to make the rest of my system do whatever it is that VLC is doing, if anyone can help!
I've got an HP laptop (which was a bad idea to begin with) with on-board intel HDA audio and an HDMI port. The HDMI cable passes to a projector via an HDMI splitter box that also does digital audio extraction (2.0 or 5.1) to coax or TOSLINK. This audio signal passes via fibre optic to an AV receiver. I know, I know, it's an ugly setup, but it was really my only option; the AV unit has no other inputs (OK, OK, it's not a proper AV receiver, it's a consumer blu-ray player with 5.1 speakers and happens to have a TOSLINK input, but it's the same principle ). The laptop runs Debian stable + backports, and has a Pulseaudio-ALSA sound stack. Pulseaudio is currently disabled whilst I try to get ALSA set up properly. What I want to do is output all audio signals from all programs (up-mixing where necessary) in 5.1 format to the AV receiver via this HDMI-TOSLINK Frankencable abomination, so I can make complete use of all my speakers.
I've spent the best part of two days wrestling with ALSA settings, trying to get the a52 module to send compressed 5.1 audio over the HDMI output so that the splitter and receiver can pick it up, in vain. However, I know this setup is workable, because VLC is somehow magically making it work. When set to use ALSA audio output, device: "HDA Intel PCH, HDMI 0 HDMI Audio Output", and "Use S/PDIF when available," I get full 5.1 surround out of the system when playing a speaker test video with an a52 audio track in VLC. This is just what I want to happen. I'm running VLC 2.2.1 Terry Pratchett (Weatherwax).
However, I can't get ALSA to do this internally for its own audio output. ALSA has an internal virtual sink for producing compressed 5.1 via the "a52" plugin, which can then be routed to S/PDIF interfaces or PCM hardware directly; I've tested this with a USB AureonII I temporarily hooked up to directly drive the optical fibre (bypassing the HDMI stuff) and it works fine over that, but it won't work over the internal HDMI the way VLC does. Interestingly, aplay -l shows that the Aureon explicitly presents an ALSA sink called
"iec958:CARD=Aureon51MkII,DEV=0
Aureon5.1MkII, USB Audio
IEC958 (S/PDIF) Digital Audio Output"
but the internal Intel card does not present any similar sink, which I suspect is why I am having such problems. I tried connecting the output of the a52 module to the HDMI PCM interface the way it's supposed to when an explicit SPDIF interface isn't defined, but it just makes the speakers click briefly before failing with file writing problems. The exact error message is:
speaker-test 1.0.28
Playback device is hdmi_a52
Stream parameters are 48000Hz, S16_LE, 6 channels
Sine wave rate is 600.0000Hz
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 3072 to 15360
Period size range from 1536 to 1536
Using max buffer size 15360
Periods = 4
was set period_size = 1536
was set buffer_size = 15360
0 - Front Left
Write error: -77,File descriptor in bad state
xrun_recovery failed: -77,File descriptor in bad state
Transfer failed: File descriptor in bad state
So, to (finally) get to my question: How, exactly, is VLC correctly putting out an SPDIF signal that can pass through the HDMI cable and signal splitter and be decoded at the other end, via ALSA, when ALSA is apparently not presenting any kind of HDMI SPDIF interface to be used? Is VLC also doing the SPDIF-to-PCM trick (which, I think I'm right in saying, is effectively a digital signal pretending to be analogue and being sufficiently low resolution that the audio DACs can reproduce it?) and sending that over the HDMI PCM interface, in which case I presumably just need to get some obscure PCM setting right, or is it somehow finding a proper SPDIF interface that I cannot see and using that?