Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Feature ? PipeWire audio system replaces the PulseAudio system. #38

Open
James7zy opened this issue Feb 8, 2022 · 6 comments
Open

Comments

@James7zy
Copy link

James7zy commented Feb 8, 2022

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?

@al1img
Copy link
Collaborator

al1img commented Feb 8, 2022

Yes, no need to change the front end. Backend (snd_be) doesn't support PipeWire as a sound backend. There are two approaches to use PipeWire:

  1. Add PipeWire support to snd_be. For this purpose PipeWire pcm device class should be implemented. This class should implement SoundItf::PcmDevice interface. See how it is done for PulseAudio (PulsePcm class).
  2. Use PipeWire PulseAudio server to convert PulseAudio protocol to PipeWire protocol. See https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/Config-PulseAudio. No need for snd_be modification in this case.

@James7zy
Copy link
Author

James7zy commented Feb 9, 2022

@al1img

Thank you very much.
​ Could i ask you another questiones about alsa configuration? when i use following configuration alsa can works,but there are some errors. I am very confused about that. I think when I use this configuration ,backend(SND_BE) sholud give some error informaion. Or it is an invalid configuration.
​ This configuration can play normally, but cannot record. If i use "STREAM, unique-id=alsa < pipewire > ", it has the same scene.

Thank you give me a solution that adapts to pipewire audio system.

vsnd = [
        [ 'CARD, buffer-size=262144, short-name=VCard, long-name=Virtual sound card, sample-rates=44100, sample-formats=s16_le',
            'PCM, name=vsnd', 'STREAM, unique-id=alsa<pulse>, type=p', 'STREAM, unique-id=alsa<pulse>, type=c'
        ]
]

image

@al1img
Copy link
Collaborator

al1img commented Feb 9, 2022

What are the errors exactly? Are you able to record with CLI arecord tool using the specified ALSA device?

@James7zy
Copy link
Author

James7zy commented Feb 10, 2022

Hi @al1img ,
Thank you for your reply.

​ I will provide more information to discuss this issue.

  1. Playback and Capture are normal in domain0.

  2. configuraton:unique-id=alsa for Xen.

# Sound cards
vsnd = [ 
		[ 'CARD, buffer-size=1310720, short-name=VCard, long-name=Virtual sound card, channels-max=2,sample-rates=8000;22050;44100;48000, sample-formats=s8;u8;s16_le;s16_be;u16_le;u16_be;s24_le;s24_be;u24_le;u24_be;s32_le;s32_be;u32_le;u32_be;f32_le;f32_be;f64_le;f64_be;iec958_subframe_le;iec958_subframe_be;mu_law;a_law;ima_adpcm;mpeg;gsm',
			'PCM, name=vsnd', 'STREAM, unique-id=alsa<pipewire>, type=p', 'STREAM, unique-id=alsa<pipewire>, type=c'
		]
]

Start domain-u with this configuration. pipewire PCM device created successfully.Both front-end and back-end are connected successfully.

image

Playback

  • Playback has some underrun occurred in backend.Using the player on domain-U can hear the sound but there are some noise.
    image

Capture

  • The stream of capture has created in frontend.
    image

using arecord in domain-U is unnormal.

arecord -t wav test.wav

image

  • The information of SND_BE :

    Frame:0 bytes:0,state:3
    

image

Recording with tool audacity has the same result.
image

Question:

Q1.
Is this configuration reasonable?

 unique-id=alsa<pipewire>

Q2:
Is this unexpected error about 'underrun occurred' during playback related to buffer-size parameter in the xl-cfg?

Q3:
Why the recording is not normal?Could you give me some advices?

Kernel version:

Frontend: Linux5.11.0

Backend: snd_be release v0.2.1

Xen :xen-4.15.1

Domain0: AGL linux.

DomainU:Ubuntu 20.04

@James7zy
Copy link
Author

James7zy commented Feb 10, 2022

Yes, no need to change the front end. Backend (snd_be) doesn't support PipeWire as a sound backend. There are two approaches to use PipeWire:

  1. Add PipeWire support to snd_be. For this purpose PipeWire pcm device class should be implemented. This class should implement SoundItf::PcmDevice interface. See how it is done for PulseAudio (PulsePcm class).

**Do you have any development plans for SND_BE with support for pipewire ?

@al1img
Copy link
Collaborator

al1img commented Feb 10, 2022

Q1: Yes, once alsa device pipewire exists in Dom0.

Q2: Yes, this error relates to the buffer-size parameter. For Alsa backend, this parameter should be the same as real device buffer. Can be obtained by the following command on Dom0: aplay -D pipewire --dump-hw-params some_wave_file.wav (BUFFER_SIZE).

Q3: Regardless of underrun error, I see there are successful writes to the PCM device as well. Does read error occur immediately after launching arecord command or after some period of time?

To resolve the issue I suggest the following:

  • check playback and record for the pipewire device on Dom0: option -D pipewire for aplay and arecord commands;

Playback and Capture are normal in domain0

  • adjust the buffer size;
  • or you can try to switch to pulse audio backend, this backend is more tolerant to the buffer size.

**Do you have any development plans for SND_BE with support for pipewire ?

Not yet, but we are happy to collaborate on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants