sharing audio output over network on linux

problem:

after connecting my raspberry pi to DAC amplifier I wanted to play songs/youtube videos on my laptop and be able to hear them from the speakers connected to the pi.

tools I tried:

  • spotifyd
    • took much time to get built on the poor pi
    • had so frequent unexpected closes
    • only works with spotify -obviously-
    • ~1 sec delay between pause button click and the actual pause
  • pulseaudio's built in streaming
    • package paprefs helped with configuration
    • sound was so choppy, delay was unfeasible, local video and network audio got out of sync
    • a bit hard to switch between local audio and remote audio outputs
  • roc-toolkit
    • too convoluted for me
  • trx
    • so tiny, easy and quick builds on x86 and arm
    • uses lossy opus encoding
    • delay is acceptable
    • available in some official package repos

recommendation: trx

  • debian + pulseaudio instructions:

    • install trx + at scheduling utility on both server and client machines
    sudo apt-get install trx at
    
    • on server:
      • run trx receiver in background:
    echo "trx-rx" | at now
    
    • on client:
      • create pulse audio user config file at /etc/pulse/default.pa.d/user.pa
      • tell pulse to create a dummy audio sink to be used with trx and set it as default, do this by adding these lines to the created file (change the name rpi to whatever you like)
    load-module module-null-sink sink_name=rpi
    set-default-sink rpi
    
    • restart pulse:
    pulseaudio -k
    
    • run trx transmitter taking audio stream from rpi monitor:
    echo "PULSE_SOURCE=rpi.monitor trx-tx -h rpi" | at now
    

Leave a Reply