Ubuntu – How to force the rediscovery of PulseAudio virtual sound devices

avahinetworkingpulseaudiosound

I'm using the PulseAudio feature of network sound devices (not Multicast/RTP) to play sound from my netbook on the audio equipment connected to the HTPC when at home. This creates a virtual sound device that I can then use instead of the physical built-in one. Most of the time this works just fine. Sometimes however, the virtual sound device just doesn't appear. Disconnecting from and reconnecting to the network helps sometimes but not always and it's annoying and potentially bad for existing TCP connections.

So my question basically is: Is there some way to tell PulseAudio "Hey, just look again if you really can't find a network sound device."?


Edit: Unloading and reloading the module-zeroconf-discover with pacmd does not help either and it doesn't appear to be an avahi problem per se since avahi-browse -t --all | grep PulseAudio shows lots of right-looking stuff, even when the devices aren't listed in pavucontrol or pacmd list-sinks.


Edit 2: I'm using Ubuntu 12.04 on both boxes for all the difference it might make.

Best Answer

  1. On the "Sink" PC (On whose speaker you wanna play the sound) open the PulseAudio command shell by going into Terminal and issuing the following command.

    $ pacmd

    You will see a Python-like shell with the following welcome message.

    Welcome to PulseAudio! Use "help" for usage information. >>>
  2. List the devices that can play the sound on the PC by the command in the PulseAudio shell.
    >>> list-sinks
    Now you'll see a detailed list of all the sound sinks.
  3. Just note down the complete name of the sink of your choice. It would appear as an attribute of the sound card. For example in my case it is:

    1 sink(s) available. index: 0 name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
    ...

The string of my interest is just "alsa_output.pci-0000_00_1b.0.analog-stereo"

  1. Now Go onto the Source PC (i.e. origin of the audio multimedia streams), open up the terminal and issue the following command

    $ pactl load-module module-tunnel-sink "server=192.168.1.105 sink=alsa_output.pci-0000_00_1b.0.analog-stereo sink_name=home_theater"

    Here 192.168.1.105 is the IP address of the sink PC, "alsa_output.pci-0000_00_1b.0.analog-stereo" is the string you just copied from sink's terminal and "home_theater" is just a fancy name to call this virtual sound output device on your computer.

  2. Finally select this virtual sound device by :
    $ pacmd set-default-sink home_theater

    Wallah !!