How does VLC send S/PDIF signals over HDMI via ALSA?

*nix specific usage questions
tnm23
New Cone
New Cone
Posts: 2
Joined: 19 Oct 2015 18:25

How does VLC send S/PDIF signals over HDMI via ALSA?

Postby tnm23 » 19 Oct 2015 19:44

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 :-P ). 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?

Rémi Denis-Courmont
Developer
Developer
Posts: 15124
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: How does VLC send S/PDIF signals over HDMI via ALSA?

Postby Rémi Denis-Courmont » 19 Oct 2015 20:41

You can find the ALSA device used by VLC from the VLC verbose/debug logs ("using ALSA device: ..."). It's presumably either "hdmi" or "iec958" with some parameters.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

tnm23
New Cone
New Cone
Posts: 2
Joined: 19 Oct 2015 18:25

Re: How does VLC send S/PDIF signals over HDMI via ALSA?

Postby tnm23 » 20 Oct 2015 01:57

Thanks. This looks like the relevant section, but I'm afraid I'm really struggling to see exactly what's going on and how the signal is being sent out. Do these mysterious-looking "AES" arguments have anything to do with it? How is VLC actually trying to use the hardware?

alsa debug: using ALSA device: hdmi:CARD=PCH,DEV=0,AES0=0x2,AES1=0x82,AES2=0x0,AES3=0x2
lua debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/art/03_lastfm.luac
alsa debug: Hooks PCM
Slave: Hardware PCM card 0 'HDA Intel PCH' device 3 subdevice 0
alsa debug: device name : HDMI 0
alsa debug: device ID : HDMI 0
alsa debug: subdevice name: subdevice #0
alsa debug: initial hardware setup:
ACCESS: MMAP_INTERLEAVED RW_INTERLEAVED
FORMAT: S16_LE S32_LE
SUBFORMAT: STD
SAMPLE_BITS: [16 32]
FRAME_BITS: [32 256]
CHANNELS: [2 8]
RATE: [32000 192000]
PERIOD_TIME: (20 256000]
PERIOD_SIZE: [4 8192]
PERIOD_BYTES: [128 262144]
PERIODS: [2 32]
BUFFER_TIME: (41 512000]
BUFFER_SIZE: [8 16384]
BUFFER_BYTES: [128 65536]
TICK_TIME: ALL
lua debug: skipping script (unmatched scope) /usr/lib/vlc/lua/meta/art/02_frenchtv.luac
lua debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/art/03_lastfm.luac
alsa debug: final HW setup:
ACCESS: RW_INTERLEAVED
FORMAT: S16_LE
SUBFORMAT: STD
SAMPLE_BITS: 16
FRAME_BITS: 32
CHANNELS: 2
RATE: 48000
PERIOD_TIME: (42666 42667)
PERIOD_SIZE: 2048
PERIOD_BYTES: 8192
PERIODS: 8
BUFFER_TIME: (341333 341334)
BUFFER_SIZE: 16384
BUFFER_BYTES: 65536
TICK_TIME: 0
alsa debug: initial software parameters:
tstamp_mode: NONE
period_step: 1
avail_min: 2048
start_threshold: 1
stop_threshold: 16384
silence_threshold: 0
silence_size: 0
boundary: 4611686018427387904
alsa debug: final software parameters:
tstamp_mode: NONE
period_step: 1
avail_min: 2048
start_threshold: 1
stop_threshold: 16384
silence_threshold: 0
silence_size: 0
boundary: 4611686018427387904
core debug: output 'spdi' 48000 Hz 3F2R/LFE frame=1536 samples/6144 bytes
core debug: looking for audio volume module matching "any": 2 candidates
core debug: no audio volume modules matched
core debug: input 'a52 ' 48000 Hz 3F2R/LFE frame=1536 samples/1536 bytes
core debug: pass-through: 'a52 '->'spdi' 48000 Hz->48000 Hz 3F2R/LFE->3F2R/LFE


Return to “VLC media player for Linux and friends Troubleshooting”

Who is online

Users browsing this forum: No registered users and 10 guests