diff mbox series

[10/18] hw/input/tsc210x.c: Support machine-default audiodev with fallback

Message ID 0b13f27f5389d0a75b9e3046830f88fd37de54f2.1650874791.git.mkletzan@redhat.com
State New
Headers show
Series RFC: Remove deprecated audio features | expand

Commit Message

Martin Kletzander April 25, 2022, 8:21 a.m. UTC
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
---
 hw/input/tsc210x.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c
index f16a8090b7c7..f0b02bc72280 100644
--- a/hw/input/tsc210x.c
+++ b/hw/input/tsc210x.c
@@ -1098,6 +1098,14 @@  static void tsc210x_init(TSC210xState *s,
 
     qemu_add_mouse_event_handler(tsc210x_touchscreen_event, s, 1, name);
 
+    const char *audiodev_id = audio_maybe_init_dummy("tsc.defaudio");
+    s->card.name = g_strdup(audiodev_id);
+    s->card.state = audio_state_by_name(s->card.name);
+    if (!s->card.state) {
+        error_setg(&error_fatal, "Cannot find audiodev with id '%s'",
+                   s->card.name);
+    }
+
     AUD_register_card(s->name, &s->card);
 
     qemu_register_reset((void *) tsc210x_reset, s);