[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 07/18] Introduce machine's default-audiodev property
From: |
Martin Kletzander |
Subject: |
[PATCH 07/18] Introduce machine's default-audiodev property |
Date: |
Mon, 25 Apr 2022 10:21:50 +0200 |
Many machine types have default audio devices with no way to set the underlying
audiodev. Instead of adding an option for each and every one of them this new
property can be used as a default during machine initialisation when creating
such devices.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
---
hw/core/machine.c | 23 +++++++++++++++++++++++
include/hw/boards.h | 1 +
2 files changed, 24 insertions(+)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index cb9bbc844d24..d055a126d398 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -596,6 +596,22 @@ static void machine_set_memdev(Object *obj, const char
*value, Error **errp)
ms->ram_memdev_id = g_strdup(value);
}
+static char *machine_get_default_audiodev(Object *obj, Error **errp)
+{
+ MachineState *ms = MACHINE(obj);
+
+ return g_strdup(ms->default_audiodev);
+}
+
+static void machine_set_default_audiodev(Object *obj, const char *value,
+ Error **errp)
+{
+ MachineState *ms = MACHINE(obj);
+
+ g_free(ms->default_audiodev);
+ ms->default_audiodev = g_strdup(value);
+}
+
HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine)
{
int i;
@@ -867,6 +883,12 @@ static void machine_class_init(ObjectClass *oc, void *data)
object_class_property_set_description(oc, "confidential-guest-support",
"Set confidential guest scheme to
support");
+ object_class_property_add_str(oc, "default-audiodev",
+ machine_get_default_audiodev,
+ machine_set_default_audiodev);
+ object_class_property_set_description(oc, "default-audiodev",
+ "Audiodev to use for default machine
devices");
+
/* For compatibility */
object_class_property_add_str(oc, "memory-encryption",
machine_get_memory_encryption, machine_set_memory_encryption);
@@ -961,6 +983,7 @@ static void machine_finalize(Object *obj)
g_free(ms->device_memory);
g_free(ms->nvdimms_state);
g_free(ms->numa_state);
+ g_free(ms->default_audiodev);
}
bool machine_usb(MachineState *machine)
diff --git a/include/hw/boards.h b/include/hw/boards.h
index d64b5481e834..5be1de50af03 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -346,6 +346,7 @@ struct MachineState {
*/
MemoryRegion *ram;
DeviceMemoryState *device_memory;
+ char *default_audiodev;
ram_addr_t ram_size;
ram_addr_t maxram_size;
--
2.35.1
- [PATCH 04/18] hw/audio/lm4549: Add errp error reporting to init function, (continued)
- [PATCH 04/18] hw/audio/lm4549: Add errp error reporting to init function, Martin Kletzander, 2022/04/25
- [PATCH 10/18] hw/input/tsc210x.c: Support machine-default audiodev with fallback, Martin Kletzander, 2022/04/25
- [PATCH 08/18] audio: Add easy dummy audio initialiser, Martin Kletzander, 2022/04/25
- [PATCH 17/18] audio: Remove unused can_be_default, Martin Kletzander, 2022/04/25
- [PATCH 06/18] ui/vnc: Require audiodev=, Martin Kletzander, 2022/04/25
- [PATCH 07/18] Introduce machine's default-audiodev property,
Martin Kletzander <=
- [PATCH 11/18] hw/arm: Support machine-default audiodev with fallback, Martin Kletzander, 2022/04/25
- [PATCH 14/18] audio: Require AudioState in AUD_add_capture, Martin Kletzander, 2022/04/25
- [PATCH 12/18] hw/ppc: Support machine-default audiodev with fallback, Martin Kletzander, 2022/04/25
- [PATCH 16/18] audio: Remove legacy audio environment variables and options, Martin Kletzander, 2022/04/25
- [PATCH 13/18] audio: Make AUD_register_card fallible and require audiodev=, Martin Kletzander, 2022/04/25