Giter Club home page Giter Club logo

snd_be's Introduction

Sound backend

Dependencies:

Required:

  • libxenbe

Optional:

  • alsa
  • pulse
  • Doxygen

How to configure

mkdir ${BUILD_DIR}
cd ${BUILD_DIR}
cmake ${PATH_TO_SOURCES} -D${VAR1}=${VAL1} -D{VAR2}=${VAL2} ...

There are variables and options. Options can be set to ON and OFF.

Supported options:

Option Description
WITH_DOC Creates target to build documentation. It required Doxygen to be installed. If configured, documentation can be create with make doc
WITH_PULSE Builds with pulse audio backend
WITH_ALSA Builds with alsa backend
WITH_MOCKBELIB Use test mock backend library

Supported variables:

Variable Description
CMAKE_BUILD_TYPE Realease, Debug, RelWithDebInfo, MinSizeRel
CMAKE_INSTALL_PREFIX Default install path
XEN_INCLUDE_PATH Path to Xen tools includes if they are located in non standard place
XENBE_INCLUDE_PATH Path to libxenbe includes if they are located in non standard place
IF_INCLUDE_PATH Path to the interface headers if they are located in non standard place
XENBEMOCK_INCLUDE_PATH Path to the mock headers if they are located in non standard place
XEN_LIB_PATH Path to Xen tools libraries if they are located in non standard place
XENBE_LIB_PATH Path to libxenbe if it is located in non standard place
XENBEMOCK_LIB_PATH Path to libxenbemock if it is located in non standard place

Example:

// Debug build with pulse backend
cmake ${PATH_TO_SOURCES} -DWITH_PULSE=ON -DCMAKE_BUILD_TYPE=Debug

How to build:

cd ${BUILD_DIR}
make     // build sources
make doc // build documentation

How to install

make install // to default location
make DESTDIR=${PATH_TO_INSTALL} install //to other location

Configuration:

Backend configuration is done in domain configuration file. See vsnd on http://xenbits.xen.org/docs/unstable-staging/man/xl.cfg.5.html#Devices

In order to match virtual stream with real one, stream unique-id parameter is used. This parameter has following format:

pcmtype<device>propname:propvalue

All fields except pcmtype are optional.

  • pcmtype - specifies PCM type: "pulse" or "alsa";
  • device - device name
    • for pulse: sink or source name
    • for alsa: alsa device like HW:0;1 (note that ";" used instead of "," because "," is field separator in domain config file)
  • propname (relevant for pulse) - stream property name: like media.role etc.
  • propvalue (relevant for pulse) - stream property value: like navi, phone etc.

Stream property is used to identify pulse stream by other system modules such as audio manager etc.

Some configuration examples:

# The backend will provide default pulse device for the configured stream playback.
vsnd = [[ 'card, backend=DomD, buffer-size=65536, short-name=VCard, long-name=Virtual sound card, sample-rates=48000, sample-formats=s16_le',
          'pcm, name=dev1', 'stream, unique-id=pulse, type=P' ]]

# The backend will use ALSA device hw:0,0 for playback. Pay attention that "0,0" have to be replaced by "0;0", and sample format is s24_le.
vsnd = [[ 'card, backend=DomD, buffer-size=32768, short-name=VCard, long-name=Virtual sound card, sample-rates=48000, sample-formats=s24_le',
          'pcm, name=dev1', 'stream, unique-id=alsa<hw:0;0>, type=P' ]]

Other unique-id values example:

# the backend will provide default pulse device for the configured stream
unique-id=pulse
# the backend will provide pulse pci-0000_00_1f.3.analog-stereo device for the configured stream
unique-id=pulse<pci-0000_00_1f.3.analog-stereo> 
# the backend will provide default pulse device for the configured stream and set media.role property of stream to navi
unique-id=pulse<>media.role:navi
# the backend will provide alsa card0 device 0 for the configured stream 
unique-id=alsa<hw:0;0>

How to run:

snd_be -v${LOG_MASK}

Example:

snd_be -v *:Debug

snd_be's People

Contributors

al1img avatar klogg avatar rshym avatar

Stargazers

 avatar llnull avatar

Watchers

 avatar Oleksandr Andrushchenko avatar James Cloos avatar  avatar Stefan Kadow avatar  avatar

snd_be's Issues

Sound cut-off when play wav in front-end

I run this backend in linux domain and use android domain as frontend, kernel version is 4.19,
and I use [tinyplay 1.wav] to play sound in android console, the sound is cutting-off with long clips.
Are there any advice about this issue? Thank you very much!

Use local version of sndif protocol

It makes sense to use the local version of the protocol which allows use-cases such as "old Xen - backend with newer sndif".
This has also been implemented by the display protocol, so this change will look consistent

Selecting sound card with Pulse Audio back end

Hello,

I have got audio working from HVM guest with Pulse Audio as back end. Following is my vsnd config:

vsnd = [[ 'card, backend=Domain-0, buffer-size=65536, short-name=VCard, long-name=Virtual sound card, sample-rates=44100, sample-formats=s16_le', 'pcm, name=dev1', 'stream, unique-id=pulse, type=P' ]]

Currently audio is playing through default sound card. However, I want to play it through another sound card present in Dom 0. How can I select the other sound card (say hw:2,0)?

I tried setting following parameter, but it did not work: unique-id=pulse<hw:2;0>

Audio Manager on backend side

Investigate audio manager solutions.

  • snd backend and other applications should use the AudioManager to open input/output audio channels;
  • applications and the backend should assign an attribute
  • Audio manager provides audio channels based on assigned attributes and global mixing policy;
  • The mixing policies are common for all applications including snd backend.

Check IVI/Genivi Audio Manager as main audio manager solution.

How to create capture CARD configure

Hi ,
Could someone to tell me how to create capture to normal record.

I have used following configuration, but it does not work.

vsnd = [
[ 'CARD, buffer-size=262144, short-name=VCard, long-name=Virtual sound card',
'PCM, name=vsndp',
'STREAM, unique-id=pulse, type=p',
'STREAM, unique-id=pulse, type=c'
]
]

ALSA back end is not working

Hello,

I am trying to play audio from a HVM guest (ubuntu). My Dom 0 is also ubuntu. I am using snd_be for this purpose.
Current status:

  1. Audio playback from Dom 0 works fine (aplay music.wav)
  2. Audio playback from Dom U works fine with pulse audio as back end
  3. Audio playback from Dom U does not work with ALSA as back end

Here is my vsnd config:
vsnd = [[ 'card, backend=Domain-0, buffer-size=22050, short-name=VCard, long-name=Virtual sound card, sample-rates=8000;11025;16000;22050;32000;44100;48000, sample-formats=s16_le', 'pcm, name=dev1', 'stream, unique-id=alsa, type=P' ]]

Following are the output of aplya -v and aplay --dump-hw-params respectively. Can you please help me understand what is going wrong here?

================================================================
axx@axx-xxx-RV2:~$ aplay -v ~/SampleAudio/music.wav
Playing WAVE '/home/amd/SampleAudio/music.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
ALSA <-> PulseAudio PCM I/O Plugin
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 44100
exact rate : 44100 (44100/1)
msbits : 16
buffer_size : 22050
period_size : 5512
period_time : 125000
tstamp_mode : NONE
tstamp_type : GETTIMEOFDAY
period_step : 1
avail_min : 5512
period_event : 0
start_threshold : 22050
stop_threshold : 22050
silence_threshold: 0
silence_size : 0
boundary : 6206523236469964800

================================================================

amd@amd-Bilby-RV2:~$ aplay ~/SampleAudio/music.wav --dump-hw-params
Playing WAVE '/home/amd/SampleAudio/music.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
HW Params of device "default":

ACCESS: RW_INTERLEAVED
FORMAT: U8 S16_LE S16_BE S24_LE S24_BE S32_LE S32_BE FLOAT_LE FLOAT_BE MU_LAW A_LAW S24_3LE S24_3BE
SUBFORMAT: STD
SAMPLE_BITS: [8 32]
FRAME_BITS: [8 1024]
CHANNELS: [1 32]
RATE: [1 384000]
PERIOD_TIME: (2 4294967295)
PERIOD_SIZE: [1 1398102)
PERIOD_BYTES: [128 1398102)
PERIODS: [3 1024]
BUFFER_TIME: (7 4294967295]
BUFFER_SIZE: [3 4194304]
BUFFER_BYTES: [384 4194304]
TICK_TIME: ALL

================================================================

Regards,
Jyotirmoy

New Feature ? PipeWire audio system replaces the PulseAudio system.

New Feature ?
I want to use PipeWire instead of PulseAudio system. I think is that PulseAudio and PipeWireare at the same level,so I just change the configuration 'STREAM, unique-id=PipeWire, type=p'. I don't know whether it's correct.
Or should I write new code to adapt PipeWire system . Could you give me some advices.

PipeWire home page: https://pipewire.org/

I have used following configuration, but domainU does not work. I have installed PipeWire in domain0 and shut down all PulseAudio services.

vsnd = [
[ 'CARD, buffer-size=262144, short-name=VCard, long-name=Virtual sound card',
'PCM, name=vsndp',
'STREAM, unique-id=PipeWire, type=p',
'STREAM, unique-id=PipeWire, type=c'
]
]

​ I have checked “unique-id” process in Xen4.15.1. It just give it an id to process in backend.

if (MATCH_OPTION(XENSND_FIELD_STREAM_UNIQUE_ID, param, oparg)) {
            stream->unique_id = strdup(oparg);

#define MATCH_OPTION(prefix, arg, oparg) \
            match_option_size((prefix "="), sizeof((prefix)), (arg), &(oparg))

int match_option_size(const char *prefix, size_t len,
                                char *arg, char **argopt)
          {
              int rc = strncmp(prefix, arg, len);
              if (!rc) *argopt = arg+len;
              return !rc;
          }

​ I have read front code in linux5.11.0. It just use ALSA abstract interface to create CARD、PCM and STREAM,So i think front not to rewirite,Only just to adapt pipewire system in SND_BE?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.