poniedziałek, 18 maja 2015

Kodi HDMI & Analog audio at the same time

XMBC / Kodi - dual audio output HDMI & Analog

I have a HTPC with Kodi connected to TV with HDMI (Nvidia 240 GT) and also to amplituner using analog output from motherboard audio. The HTPC is running Debian Sid Linux and Kodi 14.2.

The problem

To send the audio output to TV and amplituner at the same time, one can use special setup of ALSA or Pulseaudio. Newest versions of XBMC / Kodi accept for me only the special setup of Pulseaudio, anyway, it still works :)
The TV has delay in processing the HDMI input. As a result there is an enormous echo!
Somehow we need to delay the analog output, to match the delay done by TV to HDMI signal.

Solution

Advanced configuration of Pulseaudio using LADSPA delay filter (you can configure the delay amount to match the TV).
  1. Install LADSPA filters (in Debian it is ladspa-sdk package)
  2. Backup your ~/.config/pulse/default.pa file
  3. Put the below contents into your ~/.config/pulse/default.pa. I had to disable autodetection to be able to recognize sinks propery, for me hw:0,0 is internal card analog output, hw:1,7 is Nvidia HDMI. Please modify it to match your system.
    The green values control the delay of LADSPA delay_5s filter. Refer to LADSPA documentation for explanations - generally just modify the first number.
  4. Restart the system and test! You may need to check Kodi audio settings and change the output device.
#!/usr/bin/pulseaudio -nF

.fail

### Load audio drivers statically
### (it's probably better to not load these drivers manually, but instead
### use module-udev-detect -- see below -- for doing this automatically)
load-module module-alsa-sink device=hw:0,0 sink_name=internal
load-module module-alsa-sink device=hw:1,7 sink_name=nvhdmi

### Apply delay to internal sink
load-module module-ladspa-sink sink_name=internal_delay master=internal plugin=delay label=delay_5s control=0.18,1

### Combine delayed internal sink with hdmi sink
load-module module-combine-sink sink_name=combine slaves=nvhdmi,internal_delay

### Load several protocols
load-module module-native-protocol-unix

### Automatically restore the default sink/source when changed by the user
### during runtime
### NOTE: This should be loaded as early as possible so that subsequent modules
### that look up the default sink/source get the right value
load-module module-default-device-restore

### Automatically move streams to the default sink if the sink they are
### connected to dies, similar for sources
load-module module-rescue-streams

### Make sure we always have a sink around, even if it is a null sink.
load-module module-always-sink

### Honour intended role device property
load-module module-intended-roles

### Automatically suspend sinks/sources that become idle for too long
#load-module module-suspend-on-idle

### Make some devices default
set-default-sink combine

Brak komentarzy:

Prześlij komentarz