qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v10] audio/pwaudio.c: Add Pipewire audio backend for QEMU


From: Volker Rümelin
Subject: Re: [PATCH v10] audio/pwaudio.c: Add Pipewire audio backend for QEMU
Date: Mon, 10 Apr 2023 10:09:16 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1

Hi Dorinda,

This commit adds a new audiodev backend to allow QEMU to use Pipewire as
both an audio sink and source. This backend is available on most systems

Add Pipewire entry points for QEMU Pipewire audio backend
Add wrappers for QEMU Pipewire audio backend in qpw_pcm_ops()
qpw_write function returns the current state of the stream to pwaudio
and Writes some data to the server for playback streams using pipewire
spa_ringbuffer implementation.
qpw_read function returns the current state of the stream to pwaudio and
reads some data from the server for capture streams using pipewire
spa_ringbuffer implementation. These functions qpw_write and qpw_read
are called during playback and capture.
Added some functions that convert pw audio formats to QEMU audio format
and vice versa which would be needed in the pipewire audio sink and
source functions qpw_init_in() & qpw_init_out().
These methods that implement playback and recording will create streams
for playback and capture that will start processing and will result in
the on_process callbacks to be called.
Built a connection to the Pipewire sound system server in the
qpw_audio_init() method.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
---
v10:
improve error handling
fix volume functions
add locks in enable_in out functions
cleanup in reverse order of intialization
add triggers for the sync method on the core object
add waiting function for pw_thread_loop_signal
improve trace

  audio/audio.c                 |   3 +
  audio/audio_template.h        |   4 +
  audio/meson.build             |   1 +
  audio/pwaudio.c               | 906 ++++++++++++++++++++++++++++++++++
  audio/trace-events            |   8 +
  meson.build                   |   8 +
  meson_options.txt             |   4 +-
  qapi/audio.json               |  44 ++
  qemu-options.hx               |  21 +
  scripts/meson-buildoptions.sh |   8 +-
  10 files changed, 1004 insertions(+), 3 deletions(-)
  create mode 100644 audio/pwaudio.c

diff --git a/audio/trace-events b/audio/trace-events
index e1ab643add..d6c36139e5 100644
--- a/audio/trace-events
+++ b/audio/trace-events
@@ -18,6 +18,14 @@ dbus_audio_register(const char *s, const char *dir) "sender = %s, 
dir = %s"
  dbus_audio_put_buffer_out(size_t len) "len = %zu"
  dbus_audio_read(size_t len) "len = %zu"
+# pwaudio.c
+pw_state_changed(int nodeid, const char *s) "node id: %d stream state: %s"
+pw_read(int32_t avail, uint32_t index, size_t len) "avail=%d index=%u len=%zu"
+pw_write(int32_t filled, int32_t avail, uint32_t index, size_t len) "filled=%d 
avail=%d index=%u len=%zu"
+pw_vol(const char *ret) "set volume: %s"
+pw_timer(uint64_t buf_samples) "buffer samples = %lu"

The compilation fails on Windows. It's "%" PRIu64 instead of "%lu". Btw. I think it would be better to trace the 'quantum' instead of 'buffer samples'.

FAILED: libqemuutil.a.p/meson-generated_.._trace_trace-audio.c.obj
"cc" "-m64" "-mcx16" "-Ilibqemuutil.a.p" "-I." "-I../qemu" "-Iqapi" "-Itrace" "-Iui" "-Iui/shader" "-IC:/usr/msys64/mingw64/include/glib-2.0" "-IC:/usr/msys64/mingw64/lib/glib-2.0/include" "-IC:/usr/msys64/mingw64/include/pixman-1" "-fdiagnostics-color=auto" "-Wall" "-Winvalid-pch" "-Werror" "-std=gnu11" "-O2" "-g" "-iquote" "." "-iquote" "C:/usr/msys64/home/ruemelin/git/qemu" "-iquote" "C:/usr/msys64/home/ruemelin/git/qemu/include" "-iquote" "C:/usr/msys64/home/ruemelin/git/qemu/tcg/i386" "-U_FORTIFY_SOURCE" "-D_FORTIFY_SOURCE=2" "-fno-pie" "-no-pie" "-D_GNU_SOURCE" "-D_FILE_OFFSET_BITS=64" "-D_LARGEFILE_SOURCE" "-fno-strict-aliasing" "-fno-common" "-fwrapv" "-Wundef" "-Wwrite-strings" "-Wmissing-prototypes" "-Wstrict-prototypes" "-Wredundant-decls" "-Wold-style-declaration" "-Wold-style-definition" "-Wtype-limits" "-Wformat-security" "-Wformat-y2k" "-Winit-self" "-Wignored-qualifiers" "-Wempty-body" "-Wnested-externs" "-Wendif-labels" "-Wexpansion-to-defined" "-Wimplicit-fallthrough=2" "-Wmissing-format-attribute" "-Wno-missing-include-dirs" "-Wno-shift-negative-value" "-Wno-psabi" "-fstack-protector-strong" "-pthread" -MD -MQ libqemuutil.a.p/meson-generated_.._trace_trace-audio.c.obj -MF "libqemuutil.a.p/meson-generated_.._trace_trace-audio.c.obj.d" -o libqemuutil.a.p/meson-generated_.._trace_trace-audio.c.obj "-c" trace/trace-audio.c
In file included from trace/trace-audio.c:5:
C:/usr/msys64/home/ruemelin/git/qemu/audio/trace-events: In function '_nocheck__trace_pw_timer': C:/usr/msys64/home/ruemelin/git/qemu/audio/trace-events:26:22: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'uint64_t' {aka 'long long unsigned int'} [-Werror=format=]
   26 | pw_timer(uint64_t buf_samples) "buffer samples = %lu"
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~
......
   29 | # audio.c
      |
      |                        |
      |                        uint64_t {aka long long unsigned int}
C:/usr/msys64/home/ruemelin/git/qemu/audio/trace-events:26:22: error: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'uint64_t' {aka 'long long unsigned int'} [-Werror=format=]
   26 | pw_timer(uint64_t buf_samples) "buffer samples = %lu"
      |                      ^~~~~~~~~~~
|                                                               |
| uint64_t {aka long long unsigned int}
cc1.exe: all warnings being treated as errors

With best regards,
Volker

+pw_audio_init(void) "Initialize Pipewire context"
+
  # audio.c
  audio_timer_start(int interval) "interval %d ms"
  audio_timer_stop(void) ""






reply via email to

[Prev in Thread] Current Thread [Next in Thread]