Skip to contentSkip to conversation

audio: cleanups & add a manual test

PATCH Superseded Marc-André Lureau 1 participant 13 messages Feb 16 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover audio: cleanups & add a manual test

Hi

This is the combination of the two earlier series:
[PATCH 00/37] audio: cleanups & add a manual test [PATCH 00/43] audio: more cleanups (2/2 for 11.0)

Patches missing r-b trailers:
- scripts/modinfo: use argparse
- scripts/modinfo: make --devices optional
- scripts/modinfo: add --skip-missing-deps
- util: add some extra stubs for qemu modules initialization
- tests: start manual audio backend test
- audio: use DEFINE_TYPES
- audio: replace type_init() with DEFINE_TYPES
- audio: keep a strong reference on the backend
- replay: remove dependency on audio/
- audio: fix leak of audio capture name

---
Marc-André Lureau (85):
audio: remove obsolete/obscure functions
adlib: remove dead code
audio/adlib: drop ts_helper HWVoice field
audio/dbus: make "dbus" the default backend when using -display dbus qemu-options.hx: clarify default audio backend selection qemu-options.hx: document -audiodev dbus
audio: replace vm_running with runstate_is_running()
audio: list backends as modules
build-sys: create a libaudio
scripts/modinfo: add type annotations
scripts/modinfo: remove trailing ;
scripts/modinfo: use in instead of find() scripts/modinfo: use f-strings
scripts/modinfo: use argparse
scripts/modinfo: make --devices optional
scripts/modinfo: add --skip-missing-deps
util: add some extra stubs for qemu modules initialization
tests: start manual audio backend test
audio: constify audsettings argument
audio: introduce AudioMixengBackend
audio: use DEFINE_TYPES
audio: simplify audio_init()
audio: move object creation to audio_driver_init()
audio: add QOM module-objects for each backend
audio: remove set_dbus_server from audio_driver
audio: lookup "audio-" object types, and realize them
audio: drop audio driver registration
module: remove audio module support
audio: replace type_init() with DEFINE_TYPES
audio: keep a strong reference on the backend
audio: make list type declaration private
audio: make create_pdos() private
replay: remove dependency on audio/
audio: make all the backend-specific APIs take the be
audio: make AudioBackend truly abstract
audio: split AudioBackend
audio: AUD_ -> audio_be_
audio-be: add common pre-conditions
audio-be: add some state trace for debugging
audio: split AudioMixengBackend code in audio-mixeng-be.c
audio: make audio_driver init() & fini() optional audio/dbus: convert to QOM lifecycle methods
audio/spice: convert to QOM lifecycle methods
audio/wav: convert to QOM lifecycle methods audio/noaudio: convert to QOM lifecycle methods audio/alsa: convert to QOM lifecycle methods
audio/oss: convert to QOM lifecycle methods
audio/pa: convert to QOM lifecycle methods
audio/sdl: convert to QOM lifecycle methods
audio/pw: convert to QOM lifecycle methods
audio/jack: convert to QOM lifecycle methods
audio/sndio: convert to QOM lifecycle methods audio/coreaudio: convert to QOM lifecycle methods audio/dsound: convert to QOM lifecycle methods
audio: remove audio_driver init/fini/next
audio: remove audio_driver
audio: move pcm_ops into AudioMixengBackendClass
audio: constify some add_capture() arguments
audio/alsa: replace custom logging with error_report and trace events audio/coreaudio: replace custom logging with error_report audio/dbus: remove unused AUDIO_CAP macro
audio/dsound: replace custom logging with error_report & trace audio/jack: replace custom logging with report & trace audio/noaudio: remove unused AUDIO_CAP macro
audio/oss: replace custom logging with report & trace audio/pa: replace custom logging with report & trace audio/pw: replace custom logging with error_report audio/sdl: replace custom logging with error_report audio/sndio: replace custom logging with error_report audio/spice: remove unused AUDIO_CAP macro
audio/wav: replace custom logging with error_report audio/mixeng: replace redundant pcm_info fields with AudioFormat
audio: replace int endianness with bool big_endian in audsettings
audio: replace ldebug with trace events
audio: rework DEBUG_POLL
audio: replace DEBUG_CAPTURE with traces
audio: replace DEBUG_OUT with traces
audio: replace DEBUG_AUDIO with trace
tests/audio: add an invalid settings test
audio: rework invalid audsettings error
audio: rework audio_bug()
audio: replace remaining dolog() and AUD_log
audio: remove AUD_log/ldebug
audio: remove AudioMixengBackendClass.name
audio: fix leak of audio capture name

 MAINTAINERS                                        |    1 +
 meson.build                                        |   27 +-
 audio/audio_int.h                                  |  168 +-
 audio/audio_template.h                             |  212 +-
 audio/dsound_template.h                            |   89 +-
 include/qemu/audio-capture.h                       |   28 +-
 include/qemu/audio.h                               |  183 +-
 include/qemu/module.h                              |    3 +-
 include/qemu/timer.h                               |    1 +
 include/system/replay.h                            |   11 +-
 replay/replay-internal.h                           |    2 +
 audio/alsaaudio.c                                  |  273 ++-
 audio/audio-be.c                                   |  274 +++
 audio/audio-mixeng-be.c                            | 1770 +++++++++++++++
 audio/audio.c                                      | 2246 ++------------------
 audio/audio_win_int.c                              |   31 +-
 audio/dbusaudio.c                                  |  168 +-
 audio/dsoundaudio.c                                |  265 ++-
 audio/jackaudio.c                                  |  127 +-
 audio/mixeng.c                                     |    1 -
 audio/noaudio.c                                    |   78 +-
 audio/ossaudio.c                                   |  300 ++-
 audio/paaudio.c                                    |  261 +--
 audio/pwaudio.c                                    |  214 +-
 audio/sdlaudio.c                                   |  176 +-
 audio/sndioaudio.c                                 |  108 +-
 audio/spiceaudio.c                                 |  113 +-
 audio/wavaudio.c                                   |  101 +-
 audio/wavcapture.c                                 |    9 +-
 hw/audio/ac97.c                                    |   44 +-
 hw/audio/adlib.c                                   |   33 +-
 hw/audio/asc.c                                     |   22 +-
 hw/audio/cs4231a.c                                 |   24 +-
 hw/audio/es1370.c                                  |   28 +-
 hw/audio/gus.c                                     |   13 +-
 hw/audio/hda-codec.c                               |   36 +-
 hw/audio/lm4549.c                                  |   26 +-
 hw/audio/pcspk.c                                   |    8 +-
 hw/audio/sb16.c                                    |   30 +-
 hw/audio/via-ac97.c                                |   22 +-
 hw/audio/virtio-snd.c                              |   38 +-
 hw/audio/wm8750.c                                  |   47 +-
 hw/display/xlnx_dp.c                               |   18 +-
 hw/usb/dev-audio.c                                 |   20 +-
 replay/replay-audio.c                              |   51 +-
 replay/replay.c                                    |    2 +-
 replay/stubs-system.c                              |    8 +-
 system/vl.c                                        |    2 -
 tests/audio/audio-stubs.c                          |   69 +
 tests/audio/test-audio.c                           |  619 ++++++
 ui/dbus.c                                          |   20 +-
 ui/vnc.c                                           |    6 +-
 util/module.c                                      |    3 +
 audio/coreaudio.m                                  |  201 +-
 audio/meson.build                                  |   12 +-
 audio/trace-events                                 |   46 +
 qemu-options.hx                                    |   35 +-
 .../codeconverter/codeconverter/test_regexps.py    |    1 -
 scripts/modinfo-generate.py                        |  146 +-
 tests/audio/meson.build                            |   23 +
 tests/meson.build                                  |    1 +
 ui/meson.build                                     |    3 +
 62 files changed, 4983 insertions(+), 3914 deletions(-)

---
base-commit: ece408818d27f745ef1b05fb3cc99a1e7a5bf580
change-id: 20260216-audio-89652d2709f1

Best regards,

Signature · 1 line
Marc-André Lureau <[email protected]>
#1 lore raw

PATCH 1/85 audio: remove obsolete/obscure functions

AUD_init_time_stamp_{in,out} and AUD_get_elapsed_usec_{in,out} are only used by the adlib device. The result isn't actually being used since ADLIB_KILL_TIMERS was set some 20y ago. Let's drop this dead code now.

Drop QEMUAudioTimeStamp as well as reported by Akihiko Odaki.

---
 audio/audio_template.h                             | 34 ----------------------
 include/qemu/audio.h                               | 10 -------
 hw/audio/adlib.c                                   | 18 +-----------
 .../codeconverter/codeconverter/test_regexps.py    |  1 -
 4 files changed, 1 insertion(+), 62 deletions(-)
audio/audio_template.h +0 -34
index 7a8c431f2d7..1ab3c47fd76 100644
@@ -569,40 +569,6 @@ bool glue(AUD_is_active_, TYPE)(SW *sw)
     return sw ? sw->active : 0;
 }
 
-void glue (AUD_init_time_stamp_, TYPE) (SW *sw, QEMUAudioTimeStamp *ts)
-{
-    if (!sw) {
-        return;
-    }
-
-    ts->old_ts = sw->hw->ts_helper;
-}
-
-uint64_t glue (AUD_get_elapsed_usec_, TYPE) (SW *sw, QEMUAudioTimeStamp *ts)
-{
-    uint64_t delta, cur_ts, old_ts;
-
-    if (!sw) {
-        return 0;
-    }
-
-    cur_ts = sw->hw->ts_helper;
-    old_ts = ts->old_ts;
-    /* dolog ("cur %" PRId64 " old %" PRId64 "\n", cur_ts, old_ts); */
-
-    if (cur_ts >= old_ts) {
-        delta = cur_ts - old_ts;
-    } else {
-        delta = UINT64_MAX - old_ts + cur_ts;
-    }
-
-    if (!delta) {
-        return 0;
-    }
-
-    return muldiv64 (delta, sw->hw->info.freq, 1000000);
-}
-
 #undef TYPE
 #undef HW
 #undef SW
include/qemu/audio.h +0 -10
index a92e0b70ef0..a1a64ad340d 100644
@@ -50,10 +50,6 @@ struct AudioBackendClass {
 
 typedef struct AudioBackend AudioBackend;
 
-typedef struct QEMUAudioTimeStamp {
-    uint64_t old_ts;
-} QEMUAudioTimeStamp;
-
 bool AUD_backend_check(AudioBackend **be, Error **errp);
 
 SWVoiceOut *AUD_open_out (
@@ -71,9 +67,6 @@ int  AUD_get_buffer_size_out (SWVoiceOut *sw);
 void AUD_set_active_out(SWVoiceOut *sw, bool on);
 bool AUD_is_active_out(SWVoiceOut *sw);
 
-void     AUD_init_time_stamp_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts);
-uint64_t AUD_get_elapsed_usec_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts);
-
 #define AUDIO_MAX_CHANNELS 16
 typedef struct Volume {
     bool mute;
@@ -112,9 +105,6 @@ size_t AUD_read (SWVoiceIn *sw, void *pcm_buf, size_t size);
 void AUD_set_active_in(SWVoiceIn *sw, bool on);
 bool AUD_is_active_in(SWVoiceIn *sw);
 
-void     AUD_init_time_stamp_in (SWVoiceIn *sw, QEMUAudioTimeStamp *ts);
-uint64_t AUD_get_elapsed_usec_in (SWVoiceIn *sw, QEMUAudioTimeStamp *ts);
-
 void audio_cleanup(void);
 
 typedef struct st_sample st_sample;
hw/audio/adlib.c +1 -17
index 8b9fe53e17b..efab5107a4c 100644
@@ -34,8 +34,6 @@
 
 #define DEBUG 0
 
-#define ADLIB_KILL_TIMERS 1
-
 #define ADLIB_DESC "Yamaha YM3812 (OPL2)"
 
 #if DEBUG
@@ -71,7 +69,6 @@ struct AdlibState {
     uint64_t dexp[2];
     SWVoiceOut *voice;
     int left, pos, samples;
-    QEMUAudioTimeStamp ats;
     FM_OPL *opl;
     PortioList port_list;
 };
@@ -88,19 +85,7 @@ static void adlib_kill_timers (AdlibState *s)
 
     for (i = 0; i < 2; ++i) {
         if (s->ticking[i]) {
-            uint64_t delta;
-
-            delta = AUD_get_elapsed_usec_out (s->voice, &s->ats);
-            ldebug (
-                "delta = %f dexp = %f expired => %d",
-                delta / 1000000.0,
-                s->dexp[i] / 1000000.0,
-                delta >= s->dexp[i]
-                );
-            if (ADLIB_KILL_TIMERS || delta >= s->dexp[i]) {
-                adlib_stop_opl_timer (s, i);
-                AUD_init_time_stamp_out (s->voice, &s->ats);
-            }
+            adlib_stop_opl_timer(s, i);
         }
     }
 }
@@ -149,7 +134,6 @@ static void timer_handler (void *opaque, int c, double interval_Sec)
 #endif
 
     s->dexp[n] = interval_Sec * 1000000.0;
-    AUD_init_time_stamp_out (s->voice, &s->ats);
 }
 
 static int write_audio (AdlibState *s, int samples)
scripts/codeconverter/codeconverter/test_regexps.py +0 -1
index 2b9f5b80111..f92389e9618 100644
@@ -202,7 +202,6 @@ def test_struct_re():
     uint64_t dexp[2];
     SWVoiceOut *voice;
     int left, pos, samples;
-    QEMUAudioTimeStamp ats;
     FM_OPL *opl;
     PortioList port_list;
 } AdlibState;
Signature · 1 line
2.53.0
#2 lore raw

PATCH 2/85 adlib: remove dead code

In reply to Marc-André Lureau

Previous commit drop the need for this field.

---
 hw/audio/adlib.c | 2 --
 1 file changed, 2 deletions(-)
hw/audio/adlib.c +0 -2
index efab5107a4c..f79654627f5 100644
@@ -66,7 +66,6 @@ struct AdlibState {
     int64_t exp[2];
 #endif
     int16_t *mixbuf;
-    uint64_t dexp[2];
     SWVoiceOut *voice;
     int left, pos, samples;
     FM_OPL *opl;
@@ -133,7 +132,6 @@ static void timer_handler (void *opaque, int c, double interval_Sec)
     s->exp[n] = exp;
 #endif
 
-    s->dexp[n] = interval_Sec * 1000000.0;
 }
 
 static int write_audio (AdlibState *s, int samples)
Signature · 1 line
2.53.0
#3 lore raw

PATCH 3/85 audio/adlib: drop ts_helper HWVoice field

In reply to Marc-André Lureau

Previous commits made this dead code.

---
 audio/audio_int.h | 2 --
 audio/audio.c     | 2 --
 2 files changed, 4 deletions(-)
audio/audio_int.h +0 -2
index b2b8002477c..20b4c87b0b6 100644
@@ -77,7 +77,6 @@ typedef struct HWVoiceOut {
     struct audio_pcm_info info;
 
     f_sample *clip;
-    uint64_t ts_helper;
 
     STSampleBuffer mix_buf;
     void *buf_emul;
@@ -99,7 +98,6 @@ typedef struct HWVoiceIn {
     t_sample *conv;
 
     size_t total_samples_captured;
-    uint64_t ts_helper;
 
     STSampleBuffer conv_buf;
     void *buf_emul;
audio/audio.c +0 -2
index b7a28f79d4f..a218570a4f4 100644
@@ -1240,7 +1240,6 @@ static void audio_run_out(AudioBackend *s)
 #endif
 
         if (played) {
-            hw->ts_helper += played;
             audio_capture_mix_and_clear (hw, prev_rpos, played);
         }
 
@@ -1320,7 +1319,6 @@ static void audio_run_in(AudioBackend *s)
 
         min = audio_pcm_hw_find_min_in (hw);
         hw->total_samples_captured += captured - min;
-        hw->ts_helper += captured;
 
         for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
             sw->total_hw_samples_acquired -= min;
Signature · 1 line
2.53.0
#4 lore raw

PATCH 4/85 audio/dbus: make "dbus" the default backend when using -display dbus

In reply to Marc-André Lureau

Set "using_dbus_display" during early_dbus_init(), so that we can try to create the "dbus" audio backend by default from audio_prio_list.

This makes dbus audio work by default when using an audio device, without having to setup and wire up the -audiodev manually.

The added FIXME is addressed in the following commits.

---
 audio/audio.c     |  3 +++
 audio/dbusaudio.c |  8 +++++++-
 ui/dbus.c         | 22 +++++++++++++++++-----
 3 files changed, 27 insertions(+), 6 deletions(-)
audio/audio.c +3 -0
index a218570a4f4..9563583cd1e 100644
@@ -58,6 +58,9 @@
     that we generate the list.
 */
 const char *audio_prio_list[] = {
+#ifdef CONFIG_GIO
+    "dbus",
+#endif
     "spice",
     CONFIG_AUDIO_DRIVERS
     "none",
audio/dbusaudio.c +7 -1
index d729a810aa6..1fe7c4ed647 100644
@@ -32,6 +32,7 @@
 #endif
 
 #include "ui/dbus.h"
+#include "ui/dbus-display.h"
 #include "ui/dbus-display1.h"
 
 #define AUDIO_CAP "dbus"
@@ -408,8 +409,13 @@ dbus_enable_in(HWVoiceIn *hw, bool enable)
 static void *
 dbus_audio_init(Audiodev *dev, Error **errp)
 {
-    DBusAudio *da = g_new0(DBusAudio, 1);
+    DBusAudio *da;
 
+    if (!qemu_using_dbus_display(errp)) {
+        return NULL;
+    }
+
+    da = g_new0(DBusAudio, 1);
     da->dev = dev;
     da->out_listeners = g_hash_table_new_full(g_str_hash, g_str_equal,
                                                 g_free, g_object_unref);
ui/dbus.c +17 -5
index 31f6eb1189f..0be1931d208 100644
@@ -35,6 +35,7 @@
 #include "ui/egl-context.h"
 #endif
 #include "qemu/audio.h"
+#include "audio/audio_int.h" /* FIXME: use QOM dynamic cast instead of drv->name */
 #include "qapi/error.h"
 #include "trace.h"
 
@@ -218,9 +219,20 @@ dbus_display_complete(UserCreatable *uc, Error **errp)
         return;
     }
 
-    if (dd->audiodev && *dd->audiodev) {
-        AudioBackend *audio_be = audio_be_by_name(dd->audiodev, errp);
-        if (!audio_be || !audio_be_set_dbus_server(audio_be, dd->server, dd->p2p, errp)) {
+    {
+        AudioBackend *audio_be = audio_get_default_audio_be(NULL);
+
+        if (audio_be && !g_str_equal(audio_be->drv->name, "dbus")) {
+            audio_be = NULL;
+        }
+        if (dd->audiodev && *dd->audiodev) {
+            audio_be = audio_be_by_name(dd->audiodev, errp);
+            if (!audio_be) {
+                return;
+            }
+        }
+        if (audio_be &&
+            !audio_be_set_dbus_server(audio_be, dd->server, dd->p2p, errp)) {
             return;
         }
     }
@@ -475,6 +487,8 @@ early_dbus_init(DisplayOptions *opts)
 #endif
     }
 
+    using_dbus_display = 1;
+
     type_register_static(&dbus_vc_type_info);
 }
 
@@ -488,8 +502,6 @@ dbus_init(DisplayState *ds, DisplayOptions *opts)
         exit(1);
     }
 
-    using_dbus_display = 1;
-
     object_new_with_props(TYPE_DBUS_DISPLAY,
                           object_get_objects_root(),
                           "dbus-display", &error_fatal,
Signature · 1 line
2.53.0
#5 lore raw

PATCH 5/85 qemu-options.hx: clarify default audio backend selection

In reply to Marc-André Lureau
---
 qemu-options.hx | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)
qemu-options.hx +18 -7
index 33fcfe7ce66..15a6f82043a 100644
@@ -896,11 +896,16 @@ DEF("audiodev", HAS_ARG, QEMU_OPTION_audiodev,
     QEMU_ARCH_ALL)
 SRST
 ``-audiodev [driver=]driver,id=id[,prop[=value][,...]]``
-    Adds a new audio backend driver identified by id. There are global
-    and driver specific properties. Some values can be set differently
-    for input and output, they're marked with ``in|out.``. You can set
-    the input's property with ``in.prop`` and the output's property with
-    ``out.prop``. For example:
+    Adds a new audio backend driver identified by id.
+
+    If no audio backend is specified, QEMU will attempt to select a
+    default one. The ``-display`` option may influence which backend is
+    selected.
+
+    There are global and driver specific properties. Some values can be
+    set differently for input and output, they're marked with ``in|out.``.
+    You can set the input's property with ``in.prop`` and the output's
+    property with ``out.prop``. For example:
 
     ::
 
@@ -2198,8 +2203,11 @@ DEF("display", HAS_ARG, QEMU_OPTION_display,
     , QEMU_ARCH_ALL)
 SRST
 ``-display type``
-    Select type of display to use. Use ``-display help`` to list the available
-    display types. Valid values for type are
+    Select type of display to use. This may also influence the default
+    audio backend selection.
+
+    Use ``-display help`` to list the available display types. Valid values
+    for type are
 
     ``spice-app[,gl=on|off]``
         Start QEMU as a Spice server and launch the default Spice client
@@ -2209,6 +2217,9 @@ SRST
     ``dbus``
         Export the display over D-Bus interfaces. (Since 7.0)
 
+        If no audio backend is specified and the dbus display backend is
+        specified, the dbus audio backend is used by default.
+
         The connection is registered with the "org.qemu" name (and queued when
         already owned).
 
Signature · 1 line
2.53.0
#6 lore raw

PATCH 6/85 qemu-options.hx: document -audiodev dbus

In reply to Marc-André Lureau

Document the backend introduced in commit 739362d420 ("audio: add dbus audio backend").

---
 qemu-options.hx | 10 ++++++++++
 1 file changed, 10 insertions(+)
qemu-options.hx +10 -0
index 15a6f82043a..4043e8ca22b 100644
@@ -991,6 +991,16 @@ SRST
     ``in|out.buffer-count=count``
         Sets the count of the buffers.
 
+``-audiodev dbus,id=id[,prop[=value][,...]]``
+    Creates a D-Bus backend. It must be associated with the display
+    (as ``-display dbus,audiodev=id``). (Since 7.0)
+
+    D-Bus specific options are:
+
+    ``nsamples``
+        Number of samples per read/write (default to 480, 10ms at 48kHz)
+        (Since 10.0)
+
 ``-audiodev dsound,id=id[,prop[=value][,...]]``
     Creates a backend using Microsoft's DirectSound. This backend is
     only available on Windows and only supports playback.
Signature · 1 line
2.53.0
#7 lore raw

PATCH 7/85 audio: replace vm_running with runstate_is_running()

In reply to Marc-André Lureau

AudioBackend had a vm_running field which was set in audio_vm_change_state_handler().

The state change handler "bool running" argument is true when vm_prepare_start() calls it, and the VM runstate is either SUSPENDED or RUNNING.

Audio hw voices shouldn't be running when the VM is suspended, but only when running. Thus replacing the vm_running field with a call to runstate_is_running() is both simpler and more correct.

---
 audio/audio_int.h | 1 -
 audio/audio.c     | 5 ++---
 2 files changed, 2 insertions(+), 4 deletions(-)
audio/audio_int.h +0 -1
index 20b4c87b0b6..25de0e3f9cf 100644
@@ -252,7 +252,6 @@ typedef struct AudioBackend {
     QLIST_HEAD (cap_listhead, CaptureVoiceOut) cap_head;
     int nb_hw_voices_out;
     int nb_hw_voices_in;
-    int vm_running;
     int64_t period_ticks;
 
     bool timer_running;
audio/audio.c +2 -3
index 9563583cd1e..68698b13e15 100644
@@ -933,7 +933,7 @@ void AUD_set_active_out(SWVoiceOut *sw, bool on)
             hw->pending_disable = 0;
             if (!hw->enabled) {
                 hw->enabled = true;
-                if (s->vm_running) {
+                if (runstate_is_running()) {
                     if (hw->pcm_ops->enable_out) {
                         hw->pcm_ops->enable_out(hw, true);
                     }
@@ -979,7 +979,7 @@ void AUD_set_active_in(SWVoiceIn *sw, bool on)
         if (on) {
             if (!hw->enabled) {
                 hw->enabled = true;
-                if (s->vm_running) {
+                if (runstate_is_running()) {
                     if (hw->pcm_ops->enable_in) {
                         hw->pcm_ops->enable_in(hw, true);
                     }
@@ -1598,7 +1598,6 @@ static void audio_vm_change_state_handler (void *opaque, bool running,
     HWVoiceOut *hwo = NULL;
     HWVoiceIn *hwi = NULL;
 
-    s->vm_running = running;
     while ((hwo = audio_pcm_hw_find_any_enabled_out(s, hwo))) {
         if (hwo->pcm_ops->enable_out) {
             hwo->pcm_ops->enable_out(hwo, running);
Signature · 1 line
2.53.0
#8 lore raw

PATCH 8/85 audio: list backends as modules

In reply to Marc-André Lureau

Windows doesn't support modules, atm, but we can treat it as a regular audio unit regardless.

MacOs does support module, so this is fine.

---
 audio/meson.build | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
audio/meson.build +2 -3
index b2dca2c6409..23fb66d571f 100644
@@ -8,12 +8,11 @@ system_ss.add(files(
 # deprecated since v10.2, to be removed
 system_ss.add(files('audio-hmp-cmds.c', 'wavcapture.c'))
 
-system_ss.add(when: coreaudio, if_true: files('coreaudio.m'))
-system_ss.add(when: dsound, if_true: files('dsoundaudio.c', 'audio_win_int.c'))
-
 audio_modules = {}
 foreach m : [
   ['alsa', alsa, files('alsaaudio.c')],
+  ['coreaudio', coreaudio, files('coreaudio.m')],
+  ['dsound', dsound, files('dsoundaudio.c', 'audio_win_int.c')],
   ['oss', oss, files('ossaudio.c')],
   ['pa', pulse, files('paaudio.c')],
   ['sdl', sdl, files('sdlaudio.c')],
Signature · 1 line
2.53.0
#9 lore raw

PATCH 9/85 build-sys: create a libaudio

In reply to Marc-André Lureau

This can help create tests, for example.

---
 meson.build       | 10 +++++++++-
 audio/meson.build |  3 ++-
 2 files changed, 11 insertions(+), 2 deletions(-)
meson.build +9 -1
index 4af32c3e1f2..904605b844f 100644
@@ -4070,11 +4070,19 @@ libhwcore = static_library('hwcore', sources: hwcore_ss.sources() + genh,
 hwcore = declare_dependency(objects: libhwcore.extract_all_objects(recursive: false))
 common_ss.add(hwcore)
 
+audio_ss = audio_ss.apply({})
+libaudio = static_library('qemuaudio', audio_ss.sources() + genh,
+                          dependencies: [audio_ss.dependencies()],
+                          build_by_default: false)
+
+audio = declare_dependency(objects: libaudio.extract_all_objects(recursive: false),
+                           dependencies: [audio_ss.dependencies(), qom])
+
 ###########
 # Targets #
 ###########
 
-system_ss.add(authz, blockdev, chardev, crypto, io, qmp)
+system_ss.add(authz, blockdev, chardev, crypto, io, qmp, audio)
 common_ss.add(qom, qemuutil)
 
 libuser = static_library('user',
audio/meson.build +2 -1
index 23fb66d571f..a5fec14fb3a 100644
@@ -1,4 +1,5 @@
-system_ss.add(files(
+audio_ss = ss.source_set()
+audio_ss.add(files(
   'audio.c',
   'mixeng.c',
   'noaudio.c',
Signature · 1 line
2.53.0
#10 lore raw

PATCH 10/85 scripts/modinfo: add type annotations

In reply to Marc-André Lureau

Type annotations allow easier code reading, refactoring, checking etc.

---
 scripts/modinfo-generate.py | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
scripts/modinfo-generate.py +8 -6
index aaf23544c46..5a8abcae5d3 100644
@@ -2,14 +2,16 @@
 
 import os
 import sys
+from typing import Optional
 
-def print_array(name, values):
+
+def print_array(name: str, values: list[str]) -> None:
     if len(values) == 0:
         return
     list = ", ".join(values)
     print("    .%s = ((const char*[]){ %s, NULL })," % (name, list))
 
-def parse_line(line):
+def parse_line(line: str) -> tuple[str, str]:
     kind = ""
     data = ""
     get_kind = False
@@ -31,7 +33,7 @@ def parse_line(line):
             continue
     return (kind, data)
 
-def generate(name, lines, enabled):
+def generate(name: str, lines: list[str], enabled: set[str]) -> Optional[set[str]]:
     arch = ""
     objs = []
     deps = []
@@ -68,17 +70,17 @@ def generate(name, lines, enabled):
     print("},{")
     return {dep.strip('" ') for dep in deps}
 
-def print_pre():
+def print_pre() -> None:
     print("/* generated by scripts/modinfo-generate.py */")
     print("#include \"qemu/osdep.h\"")
     print("#include \"qemu/module.h\"")
     print("const QemuModinfo qemu_modinfo[] = {{")
 
-def print_post():
+def print_post() -> None:
     print("    /* end of list */")
     print("}};")
 
-def main(args):
+def main(args: list[str]) -> None:
     if len(args) < 3 or args[0] != '--devices':
         print('Expected: modinfo-generate.py --devices '
               'config-device.mak [modinfo files]', file=sys.stderr)
Signature · 1 line
2.53.0
#11 lore raw

PATCH 11/85 scripts/modinfo: remove trailing ;

In reply to Marc-André Lureau
---
 scripts/modinfo-generate.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/modinfo-generate.py +1 -1
index 5a8abcae5d3..83ffa4a7c52 100644
@@ -48,7 +48,7 @@ def generate(name: str, lines: list[str], enabled: set[str]) -> Optional[set[str
             elif kind == 'opts':
                 opts.append(data)
             elif kind == 'arch':
-                arch = data;
+                arch = data
             elif kind == 'kconfig':
                 # don't add a module which dependency is not enabled
                 # in kconfig
Signature · 1 line
2.53.0
#12 lore raw

PATCH 12/85 scripts/modinfo: use in instead of find()

In reply to Marc-André Lureau

Minor style improvement

---
 scripts/modinfo-generate.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/modinfo-generate.py +1 -1
index 83ffa4a7c52..63093a0f820 100644
@@ -39,7 +39,7 @@ def generate(name: str, lines: list[str], enabled: set[str]) -> Optional[set[str
     deps = []
     opts = []
     for line in lines:
-        if line.find("MODINFO_START") != -1:
+        if "MODINFO_START" in line:
             (kind, data) = parse_line(line)
             if kind == 'obj':
                 objs.append(data)
Signature · 1 line
2.53.0