aboutsummaryrefslogtreecommitdiff
path: root/audio
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2023-10-05 12:17:28 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2023-10-08 21:08:27 +0200
commit8f527a3c0d2866df1affe8f0fb8ab73fbbb8ac52 (patch)
treef802631ccaf9986d204b8f95a8f99840524414cc /audio
parentc753bf479ab75fe245c2de6a414b60b9e25a2bd7 (diff)
audio: extract audio_define_default
It will be used soon to define a default audio device from the command line. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'audio')
-rw-r--r--audio/audio.c19
-rw-r--r--audio/audio.h1
2 files changed, 13 insertions, 7 deletions
diff --git a/audio/audio.c b/audio/audio.c
index 67a7e25254..887219e0ce 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1686,8 +1686,6 @@ static const VMStateDescription vmstate_audio = {
}
};
-static void audio_validate_opts(Audiodev *dev, Error **errp);
-
void audio_create_default_audiodevs(void)
{
const char *drvname = getenv("QEMU_AUDIO_DRV");
@@ -1706,7 +1704,6 @@ void audio_create_default_audiodevs(void)
if (audio_driver_lookup(audio_prio_list[i])) {
QDict *dict = qdict_new();
Audiodev *dev = NULL;
- AudiodevListEntry *e;
Visitor *v;
qdict_put_str(dict, "driver", audio_prio_list[i]);
@@ -1717,10 +1714,7 @@ void audio_create_default_audiodevs(void)
visit_type_Audiodev(v, NULL, &dev, &error_fatal);
visit_free(v);
- audio_validate_opts(dev, &error_abort);
- e = g_new0(AudiodevListEntry, 1);
- e->dev = dev;
- QSIMPLEQ_INSERT_TAIL(&default_audiodevs, e, next);
+ audio_define_default(dev, &error_abort);
}
}
}
@@ -2165,6 +2159,17 @@ void audio_define(Audiodev *dev)
QSIMPLEQ_INSERT_TAIL(&audiodevs, e, next);
}
+void audio_define_default(Audiodev *dev, Error **errp)
+{
+ AudiodevListEntry *e;
+
+ audio_validate_opts(dev, errp);
+
+ e = g_new0(AudiodevListEntry, 1);
+ e->dev = dev;
+ QSIMPLEQ_INSERT_TAIL(&default_audiodevs, e, next);
+}
+
void audio_init_audiodevs(void)
{
AudiodevListEntry *e;
diff --git a/audio/audio.h b/audio/audio.h
index 53b1d7e622..6da5e8f6f0 100644
--- a/audio/audio.h
+++ b/audio/audio.h
@@ -169,6 +169,7 @@ void audio_sample_from_uint64(void *samples, int pos,
uint64_t left, uint64_t right);
void audio_define(Audiodev *audio);
+void audio_define_default(Audiodev *dev, Error **errp);
void audio_parse_option(const char *opt);
void audio_create_default_audiodevs(void);
void audio_init_audiodevs(void);