Change PCM format for HDMI output

  • Hello!

    Background of my issue: I have a somewhat old TV which only supports 16 Bit and 20 Bit PCM audi input.

    ELD of TV

    Unfortunately something is going wrong somewhere and I do not get any audio from my TV in stock configuration. I assume there is a problem with the 20 Bit PCM format for my TV. By default, audio is passed to ALSA in 32 Bit format.

    default hw_params
    Code
    LibreELEC:~ # cat /proc/asound/card0/pcm3p/sub0/hw_params
    access: RW_INTERLEAVED
    format: S32_LE
    subformat: STD
    channels: 2
    rate: 48000 (48000/1)
    period_size: 2400
    buffer_size: 9600

    After some tries, i figured out that audio is playing fine from TV if passed as 16 Bit PCM format.

    audio working hw_params
    Code
    LibreELEC:~ # cat /proc/asound/card0/pcm3p/sub0/hw_params
    access: RW_INTERLEAVED
    format: S16_LE
    subformat: STD
    channels: 2
    rate: 48000 (48000/1)
    period_size: 6000
    buffer_size: 24000

    Now I am searching for any solution to convert the audi coming from Kodi to 16 Bit PCM format before passed to TV over HDMI. (Any solution welcome)

    My approach was to convert die audio stream in the ALSA layer by a plug, so i configured ~/.config/asound.conf as follows (based on the description from alsa-project.org)

    This works as expected at the ALSA layer and now a can play e.g. 24 Bit audio passed to ALSA default device by aplay and hear the sound from my TV.

    aplay 24 Bit audio

    But in Kodi, the default ALSA device is not updated (still shows analog output and no audio on TV) and the HDMI selection as audio output still uses the 32 Bit format for ALSA. Also, my complex_convert alias (from asound.conf) is not showing as ALSA sink in the Kodi audi selection list.

    Is it possible to use the complex_convert ALSA alias as audio sink for Kodi?


    Other approach: Kodi selects audio sample format as AE_FMT_S32NE, is there a way to force it to AE_FMT_S16LE?

    Kodi debug log

    Any ideas how I can solve my issue?

  • Yes, but this only changes the sampling rate, not the format. No audio from TV with "fixed" output configuration with either 44.1 or 48 kHz.

    Edited once, last by Bromor (August 19, 2018 at 8:56 AM).

  • As solution I added pulseaudio in between and now audio is playing fine from TV.

    Added to ~/.config/autostart.sh:

    Code
    pactl load-module module-alsa-sink device="default"