Rudimentary guide to audio in XSpice

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



nahamu on #spice asked for some pointers to getting XSpice audio working.

Making this automatic in the XSpice script itself is still on my todo
list.  I'm afraid it is fiddly.  The easy part is getting Xspice to send
audio placed in a file across the wire; the hard part is getting
pulseaudio to put audio in the files nicely.

I'm attaching the script fragments I'm currently using so that others
can have a guide to what I do and try to replicate it.

This is not a guaranteed recipe for success; I'm afraid if it doesn't
work, you'll likely need to roll up your sleeves and do some debugging
on your own.

The basic premise is that if raw pcm data is written to a file in a
directory that the Xspice server is told to watch, then that data will
be converted to opus or celt and sent to the client.

My example presumes Opus and a 48K sample rate; if you're using Celt,
you'll want to switch the 48000 to 44100.

Basically, it starts with the 'launch_xspice' script.  That creates the
playback directory and tells Xspice to use it.  It also sets environment
variables that point pulse to a different configuration file.  If you're
using xdmcmp or something that would obliterate those environment
variables, then you'll need to modify your xsession scripts to set them
instead.

The pulse.conf file tells pulse to use a script to start the pulse
daemon.  The script generates a file in the playback directory and
launches pulse.  That launch is constrained by a script (thus hopefully
eliminated some default actions that are troubling), and the hopeful
result is that PCM data is written to the newly created file.

Note that you may have to edit the pulse.conf to hard code the
$SPICE_RUNDIR; I have a hard coded path in my setup - I put the
environment variable as a place holder.  I'm not sure if pulse will
respect that or not.

Cheers,

Jeremy
#!/bin/bash
export SPICE_RUNDIR=`pwd`
export PULSE_CLIENTCONFIG=$SPICE_RUNDIR/pulse.conf
export PULSE_STATE_PATH=$SPICE_RUNDIR/client/pulsestate
export PULSE_RUNTIME_PATH=$SPICE_RUNDIR/client/pulserun
mkdir -p $SPICE_RUNDIR/client/playback

Xspice --audio-fifo-dir=$SPICE_RUNDIR/client/playback "$@"

Attachment: spice-pulseaudio.sh
Description: Bourne shell script

# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.

default-sink = fifo
daemon-binary = $SPICE_RUNDIR/spice-pulseaudio.sh
#!/usr/bin/pulseaudio -nF
#
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.

# This startup script is used only if PulseAudio is started per-user
# (i.e. not in system mode)

.fail

### Automatically restore the volume of streams and devices
load-module module-device-restore
load-module module-stream-restore
load-module module-card-restore

### Automatically augment property information from .desktop files
### stored in /usr/share/application
load-module module-augment-properties

### Load network stack statically
load-module module-native-protocol-unix

### Automatically restore the default sink/source when changed by the user during runtime
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-null-sink
load-module module-always-sink

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

### Enable positioned event sounds
load-module module-position-event-sounds

### Cork music streams when a phone stream is active
#load-module module-cork-music-on-phone

### Publish to X11 - this is vital for Spice
load-module module-x11-publish

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

.nofail

### If autoexit on idle is enabled we want to make sure we only quit
### when no local session needs us anymore.
load-module module-console-kit
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]