diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2023-10-05 12:17:28 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2023-10-08 21:08:27 +0200 |
commit | 8f527a3c0d2866df1affe8f0fb8ab73fbbb8ac52 (patch) | |
tree | f802631ccaf9986d204b8f95a8f99840524414cc /audio/audio.c | |
parent | c753bf479ab75fe245c2de6a414b60b9e25a2bd7 (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/audio.c')
-rw-r--r-- | audio/audio.c | 19 |
1 files changed, 12 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; |