I suggest to use the same option names as the pulseaudio backend.
out.latency is the effective Pipewire buffer size.
Ack.
Thanks,
Dorinda.
On Sat, Mar 11, 2023 at 5:19 PM Volker Rümelin <vr_qemu@t-online.de>
wrote:
> Based-on:<20230306171020.381116-1-dbassey@redhat.com>
> ([PATCH v7] audio/pwaudio.c: Add Pipewire audio backend for QEMU)
>
> This is sample code for the review of the pipewire backed. The
> code actually works.
>
> An email with explanations for the changes will follow.
>
> Signed-off-by: Volker Rümelin<vr_qemu@t-online.de>
> ---
> audio/pwaudio.c | 67
+++++++++++++++++++++++++++++++++----------------
> qapi/audio.json | 10 +++-----
> 2 files changed, 49 insertions(+), 28 deletions(-)
>
> diff --git a/audio/pwaudio.c b/audio/pwaudio.c
> index d357761152..8e2a38938f 100644
> --- a/audio/pwaudio.c
> +++ b/audio/pwaudio.c
> @@ -23,7 +23,6 @@
> #define AUDIO_CAP "pipewire"
> #define RINGBUFFER_SIZE (1u << 22)
> #define RINGBUFFER_MASK (RINGBUFFER_SIZE - 1)
> -#define BUFFER_SAMPLES 512
>
> #include "audio_int.h"
>
> @@ -48,6 +47,7 @@ typedef struct PWVoice {
> struct pw_stream *stream;
> struct spa_hook stream_listener;
> struct spa_audio_info_raw info;
> + uint32_t highwater_mark;
> uint32_t frame_size;
> struct spa_ringbuffer ring;
> uint8_t buffer[RINGBUFFER_SIZE];
> @@ -82,7 +82,7 @@ playback_on_process(void *data)
> void *p;
> struct pw_buffer *b;
> struct spa_buffer *buf;
> - uint32_t n_frames, req, index, n_bytes;
> + uint32_t req, index, n_bytes;
> int32_t avail;
>
> if (!v->stream) {
> @@ -105,8 +105,7 @@ playback_on_process(void *data)
> if (req == 0) {
> req = 4096 * v->frame_size;
> }
I don't understand how the req == 0 case can work at all. The
downstream
audio device is the thinnest point in the playback stream. We can't
write more audio frames than the audio device will consume.