xpra icon
Bug tracker and wiki

Changes between Version 31 and Version 32 of Sound


Ignore:
Timestamp:
11/16/15 08:28:45 (5 years ago)
Author:
Antoine Martin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Sound

    v31 v32  
    33= Sound =
    44
    5 You can get more diagnostic messages by using the command line debug flag {{{-d sound}}} (or by setting {{{XPRA_SOUND_DEBUG=1}}}). (see [/wiki/Debugging Debugging])
     5Sound support has been stable since version 0.14, later versions add support for more codecs and better process isolation.
     6If you are having issues with sound forwarding, please see [/Sound/Debugging].
    67
    7 {{{XPRA_SOUND_QUEUE_TIME}}} can be used to control the default amount of buffering on the receiver.
    8 }}}
     8Unless you disable sound forwarding, you can start or stop it from the system tray at any time.
    99
    10 
    11 {{{#!div class="box"
    12 == Status and Configuration ==
    13 Sound support has been stable since version 0.14, later versions add support for more codecs and better process isolation.
    14 Unless you disable sound forwarding, you can start or stop it from the system tray at any time.
    1510The client and server will negotiate which codec to use. The most widely tested and supported codecs are [http://www.vorbis.com/ vorbis], [https://xiph.org/flac/ flac] and mp3.
    1611
     
    2419
    2520{{{#!div class="box"
    26 == Development ==
    27 Useful development documentation:
    28 * [http://harmattan-dev.nokia.com/docs/library/html/gstreamer0.10-doc/gstreamer-plugins-0.10/gstreamer-plugins-queue.html queue] element
    29 * [http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/chapter-dataaccess.html Pipeline manipulation]
    30 * [http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/chapter-buffering.html Buffering]
    31 * [http://docs.gstreamer.com/display/GstSDK/Basic+tutorial+12%3A+Streaming Basic tutorial: Streaming]
     21= Controls =
     22
     23The main controls are found in the configuration file or on the command line, documented in the [http://xpra.org/manual.html manual]:
     24* {{{speaker=on|off|disabled}}} / {{{microphone=on|off|disabled}}}: sound input and output forwarding support: ''on'' will start the forwarding as soon as the connection is established, ''off'' will require the user to enable it via the menu, disabled will prevent it from being used and the menu entry will be disabled
     25* {{{speaker-codec=CODEC}}} / {{{microphone-codec=CODEC}}}: Specify the codec(s) to use for sound output (speaker) or input (microphone). This parameter can be specified multiple times and the order in which the codecs are specified defines the preferred codec order. Use the special value ’help’ to get a list of options. When unspecified, all the available codecs are allowed and the first one is used.
     26* {{{sound-source=PLUGIN}}}: Specifies the GStreamer sound plugin used for capturing the sound stream. This affects "speaker forwarding" on the server, and "microphone" forwarding on the client. To get a list of options use the special value ''help''. It is also possible to specify plugin options using the form {{{ "−−sound−source=SOURCE name1=value1,name2=value2,etc"}}}, ie: {{{"−−sound−source=pulse device=device.alsa_input.pci−0000_00_14.2.analog−stereo"}}}
     27
     28Other controls only available through environment variables for fine tuning:
     29* {{{XPRA_GSTREAMER1}}} (defaults to {{{1}}}) set to {{{0}}} to try to use GStreamer 0.10 instead of 0.10
     30* {{{XPRA_ALLOW_SOUND_LOOP}}} (defaults to {{{0}}}) can be set to {{{1}}} to forward sound to / from the same pulseaudio server, potentially creating a loop (not recommended)
     31* {{{XPRA_MONITOR_DEVICE_NAME}}} to use a specific device if there is more than one device to choose from (can happen when using an existing pulseaudio server with more than one output device attached)
     32* {{{XPRA_SOUND_CODEC_ENABLE_xxxx}}} (replace xxxx with a codec name): can be used to force enable a specific codec (not recommended)
     33* {{{XPRA_SOUND_QUEUE_TIME}}} can be used to control the default amount of buffering on the receiver.
    3234}}}
    33 
    34 
    35 {{{#!div class="box"
    36 == Requirements ==
    37 
    38 * a build or package including {{{GStreamer}}} support for both client and server, including the "base" and "ugly" plugins (for mp3)
    39 * a client with sound output of any kind (even virtual)
    40 * a server with pulseaudio installed (for going beyond the simple test step) - other sound systems can be made to work but are unsupported, see the {{{sound-source}}} option
    41 * users must be "pulseaudio-enabled" - whatever that means in terms of permissions and user setup (policy, user group, etc: this is distribution specific)
    42 }}}
    43 
    44 
    45 {{{#!div class="box"
    46 == Standalone Tests ==
    47 You can run the following test commands to run/test individual parts of the sound pipeline:
    48 * {{{./xpra/sound/gstreamer_util.py}}} (named {{{GStreamer_Info.exe}}}) on MS Windows) - will dump all the gstreamer plugins installed, validates that the gstreamer installation is functional. At present, you will need at least the following plugins for mp3 encoding (mp3 is the default codec):
    49  * for the server: {{{pulsesrc}}}, {{{audioconvert}}}, {{{audioresample}}}, {{{lamemp3enc}}} and {{{appsink}}}
    50  * for the client: {{{appsrc}}}, {{{mp3parse}}}, {{{mad}}}, {{{volume}}}, {{{audioconvert}}}, {{{audioresample}}}, {{{queue}}} and {{{pulsesink}}}
    51 * {{{./xpra/sound/pulseaudio_util.py}}} will list the pulseaudio devices found if a pulseaudio server is running
    52 * {{{./xpra/sound/src.py}}} will dump the sound coming from the pulseaudio server to a file until interrupted (named {{{Sound_Record.exe}}} on MS Windows)
    53 * {{{./xpra/sound/sink.py}}} will play a sound file until interrupted - a "cheap mp3 player" ({{{Sound_Play.exe}}} on MS Windows)
    54 }}}
    55 
    56 
    57 {{{#!div class="box"
    58 == Test Sound Source Setup ==
    59 The easiest way of testing that a system is capable of forwarding and receiving sound is on a Posix system (Linux, BSD, etc).
    60 Using the {{{XPRA_SOUND_TEST}}} environment variable, we can instruct the xpra server to use a fake sound source instead of hooking into a pulseaudio server (which we do not have to / want to start, yet):
    61 {{{
    62 XPRA_SOUND_TEST=1 xpra start :10 --no-pulseaudio
    63 }}}
    64 Then we can just attach the client from the same system:
    65 {{{
    66 xpra attach
    67 }}}
    68 You should then hear a constant (rather annoying) tone.
    69 Getting this far ensures that sound forwarding does work on this system, albeit from a fake source instead of a pulseaudio server.
    70 }}}
    71 
    72 
    73 {{{#!div class="box"
    74 == Test Sound Output ==
    75 Since we use [http://gstreamer.freedesktop.org/ GStreamer] for sound support, the first thing to do is to check if gstreamer sound output works on your system.
    76 Using gst-launch:
    77 {{{
    78 gst-launch audiotestsrc ! audioconvert ! audioresample ! autoaudiosink
    79 }}}
    80 If the {{{autoaudiosink}}} does not work for you, you may want to try other options (availability varies): {{{pulsesink}}} ({{{PulseAudio}}}), {{{osxaudiosink}}} (OSX), {{{directsoundsink}}} (MS Windows), {{{alsasink}}} / {{{osssink}}} / {{{oss4sink}}} / {{{jackaudiosink}}} (Posix).
    81 If this does not work, please refer to [http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gst-running.html Running GStreamer Applications] documentation (in particular {{{GST_DEBUG}}})
    82 
    83 If you find a better sink to use with xpra, you can specify it this way:
    84 {{{
    85 XPRA_SOUND_SINK=value xpra attach ...
    86 }}}
    87 }}}
    88 
    89 
    90 {{{#!div class="box"
    91 == Simple Diagnostics ==
    92 Things to look for:
    93 * if the speaker is greyed out in the tray then sound is not enabled, check:
    94 * the speaker and/or microphone options are enabled in the default {{{xpra.conf}}} file, remove any {{{--no-speaker}}} or {{{--no-microphone}}} options.
    95 * Session Info shows sound attributes in 'Features' (see example screenshots below)
    96 * "xpra info" should show the pipeline state when a client is playing sound:
    97 {{{
    98 $ xpra info | grep -i speaker
    99 speaker.state=active
    100 }}}
    101 * {{{pavucontrol}}} both on the client and inside the xpra session (see example screenshots below)
    102 * run the client or server with the [/wiki/Logging debug logging] flag {{{-d sound}}}
    103 }}}
    104 
    105 
    106 {{{#!div class="box"
    107 == Using an existing pulseaudio server ==
    108 Next, we want to add pulseaudio, but without starting it ourselves, so we can simply re-use the existing server that gets started with most modern desktops.
    109 [[BR]]
    110 Check that pulseaudio is running in your Posix desktop:
    111 {{{
    112 ps -ef | grep pulseaudio
    113 }}}
    114 Start an xpra server:
    115 {{{
    116 xpra start :10 --no-pulseaudio
    117 }}}
    118 Or create a shadow of the current desktop session:
    119 {{{
    120 xpra shadow :0 --no-pulseaudio
    121 }}}
    122 Attach from the same machine:
    123 {{{
    124 xpra attach
    125 }}}
    126 The server log file should contain the warning message:
    127 {{{
    128 identical pulseaudio server, refusing to create a sound loop - sound disabled
    129 }}}
    130 Getting this far should ensure that all the components are installed, enabled and that the xpra server found the pulseaudio device to connect to.
    131 }}}
    132 
    133 
    134 {{{#!div class="box"
    135 == Test Remote Setup ==
    136 Using a second client machine (or a second desktop session, virtual machine, etc), we can connect this new client to the server and get the sound from the desktop session forwarded to the client.
    137 The server can be running the test source or a the desktop session's pulseaudio server. In the case of an existing pulseaudio server, simply start any sound application in the desktop session, the sound should come out in both this session's speakers (if any) and the client's speakers (if any / different!).
    138 {{{pavucontrol}}} on the server should show an Xpra entry in the {{{Recording}}} tab.
    139 The client should show an Xpra entry in the {{{Playback}}} tab (or whatever mixer/sound tool you have installed) - see screenshots below.
    140 }}}
    141 
    142 
    143 {{{#!div class="box"
    144 == Full Setup ==
    145 Finally, we may want an xpra session to use a dedicated pulseaudio server.
    146 This is more difficult and at present, unless you really know what you are doing and are prepared to pickup the pieces, you should not attempt to do this as a user which already has an existing pulseaudio server running. Simply clearing the environment and trying to start a new pulseaudio instance will not work without some serious hacks to the environment variables that pulseaudio uses to find existing instances. If this is what you really want, [http://winswitch.org/about/ winswitch] will do this for you.
    147 [[BR]]
    148 Now, assuming that you have a dedicated user, '''without''' any pulseaudio server running, and that the {{{pulseaudio}}} option is enabled (ie: no {{{--no-pulseaudio}}} command line option and no {{{pulseaudio = no}}} in the {{{xpra.conf}}} file). You should be able to setup a sound-capable environment by using simply:
    149 {{{
    150 xpra start :10
    151 }}}
    152 If, this does not work, you may want to try to start the pulseaudio server manually via:
    153 {{{
    154 xpra start :10 --no-pulseaudio \
    155   --start-child="pulseaudio --start --daemonize=false --system=false \
    156                 --exit-idle-time=-1 -n --load=module-suspend-on-idle \
    157                 --load=module-null-sink --load=module-native-protocol-unix \
    158                 --log-level=4 --log-target=stderr"
    159 }}}
    160 Notes:
    161  * you will need to use a tcp socket ({{{--bind-tcp=}}} or ssh forwarding to connect to this account - out of scope here.
    162 
    163 The default {{{log-level}}} in the default {{{xpra.conf}}} file is low, but if you raise it to 4 or above (ie: if you use the explicit command line above to start pulseaudio), you should then see these messages in the server log:
    164 {{{
    165 (..)
    166 D: [pulseaudio] main.c: Got org.PulseAudio1!
    167 D: [pulseaudio] main.c: Got org.pulseaudio.Server!
    168 I: [pulseaudio] main.c: Daemon startup complete.
    169 2013-01-07 17:42:55,732 xpra is ready.
    170 }}}
    171 And when connecting a sound capable client:
    172 {{{
    173 I: [pulseaudio] client.c: Created 0 "Native client (UNIX socket client)"
    174 (...)
    175 2013-01-07 17:44:32,205 will send sound using mp3 codec
    176 (...)
    177 2013-01-07 17:44:32,309 starting sound using null.monitor
    178 D: [pulseaudio] module-suspend-on-idle.c: Sink null becomes busy.
    179 }}}
    180 
    181 And yet more log messages as your start a sound application in this xpra session.
    182 }}}
    183 
    184 
    185 {{{#!div class="box"
    186 == ALSA, OSS, etc ==
    187 The instructions above will make sound work with all applications that use pulseaudio for output.
    188 For those that do not, please see [http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/PerfectSetup PulseAudio Perfect Setup] to route their sound to pulseaudio.
    189 }}}
    190 
    19135
    19236{{{#!div class="box"