From: Alexander Mikhalitsyn <alexander@mihalicyn.com>
To: qemu-devel@nongnu.org
Cc: "Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
"Volker Rümelin" <vr_qemu@t-online.de>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Daniel P . Berrangé" <berrange@redhat.com>,
"Alexander Mikhalitsyn" <alexander@mihalicyn.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Stéphane Graber" <stgraber@stgraber.org>,
"Alexander Mikhalitsyn" <aleksandr.mikhalitsyn@futurfusion.io>
Subject: [PATCH v5 08/10] hw/audio/virtio-sound: introduce virtio_snd_pcm_open()
Date: Mon, 3 Aug 2026 10:11:57 +0200 [thread overview]
Message-ID: <20260803081159.91981-9-alexander@mihalicyn.com> (raw)
In-Reply-To: <20260803081159.91981-1-alexander@mihalicyn.com>
From: Volker Rümelin <vr_qemu@t-online.de>
Split out the function virtio_snd_pcm_open() from
virtio_snd_pcm_prepare(). A later patch also needs
the new function. There is no functional change.
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
[AM: trivial rebase changes]
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
---
hw/audio/virtio-snd.c | 58 ++++++++++++++++++++++++-------------------
1 file changed, 32 insertions(+), 26 deletions(-)
diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c
index 1c218569cfd..7944d2b3b95 100644
--- a/hw/audio/virtio-snd.c
+++ b/hw/audio/virtio-snd.c
@@ -429,6 +429,37 @@ static void virtio_snd_get_qemu_audsettings(audsettings *as,
as->big_endian = false; /* Conforming to VIRTIO 1.0: always little endian. */
}
+/*
+ * Open a stream.
+ *
+ * @stream: VirtIOSoundPCMStream *stream
+ */
+static void virtio_snd_pcm_open(VirtIOSoundPCMStream *stream)
+{
+ virtio_snd_get_qemu_audsettings(&stream->as, &stream->params);
+ stream->info.channels_max = stream->as.nchannels;
+
+ if (stream->info.direction == VIRTIO_SND_D_OUTPUT) {
+ stream->voice.out = audio_be_open_out(stream->s->audio_be,
+ stream->voice.out,
+ "virtio-sound.out",
+ stream,
+ virtio_snd_pcm_out_cb,
+ &stream->as);
+ audio_be_set_volume_out_lr(stream->s->audio_be,
+ stream->voice.out, 0, 255, 255);
+ } else {
+ stream->voice.in = audio_be_open_in(stream->s->audio_be,
+ stream->voice.in,
+ "virtio-sound.in",
+ stream,
+ virtio_snd_pcm_in_cb,
+ &stream->as);
+ audio_be_set_volume_in_lr(stream->s->audio_be,
+ stream->voice.in, 0, 255, 255);
+ }
+}
+
/*
* Close a stream and free all its resources.
*
@@ -454,8 +485,6 @@ static void virtio_snd_pcm_close(VirtIOSoundPCMStream *stream)
*/
static uint32_t virtio_snd_pcm_prepare(VirtIOSound *s, uint32_t stream_id)
{
- audsettings as;
- virtio_snd_pcm_set_params *params;
VirtIOSoundPCMStream *stream;
stream = virtio_snd_pcm_get_stream(s, stream_id);
@@ -474,30 +503,7 @@ static uint32_t virtio_snd_pcm_prepare(VirtIOSound *s, uint32_t stream_id)
return cpu_to_le32(VIRTIO_SND_S_BAD_MSG);
}
- params = virtio_snd_pcm_get_params(s, stream_id);
-
- virtio_snd_get_qemu_audsettings(&as, params);
- stream->info.channels_max = as.nchannels;
-
- stream->as = as;
-
- if (stream->info.direction == VIRTIO_SND_D_OUTPUT) {
- stream->voice.out = audio_be_open_out(s->audio_be,
- stream->voice.out,
- "virtio-sound.out",
- stream,
- virtio_snd_pcm_out_cb,
- &as);
- audio_be_set_volume_out_lr(s->audio_be, stream->voice.out, 0, 255, 255);
- } else {
- stream->voice.in = audio_be_open_in(s->audio_be,
- stream->voice.in,
- "virtio-sound.in",
- stream,
- virtio_snd_pcm_in_cb,
- &as);
- audio_be_set_volume_in_lr(s->audio_be, stream->voice.in, 0, 255, 255);
- }
+ virtio_snd_pcm_open(stream);
stream->state = VIRTIO_SND_PCM_STATE_PREPARED;
--
2.47.3
next prev parent reply other threads:[~2026-08-03 8:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 8:11 [PATCH v5 00/10] hw/audio/virtio-sound: basic migration support Alexander Mikhalitsyn
2026-08-03 8:11 ` [PATCH v5 01/10] hw/audio/virtio-sound: remove channel positions field from VirtIOSoundPCMStream Alexander Mikhalitsyn
2026-08-03 8:11 ` [PATCH v5 02/10] hw/audio/virtio-sound: drop unused struct VirtIOSoundPCMStream.flushing field Alexander Mikhalitsyn
2026-08-03 8:11 ` [PATCH v5 03/10] hw/audio/virtio-sound: remove command and stream mutexes Alexander Mikhalitsyn
2026-08-03 8:11 ` [PATCH v5 04/10] hw/audio/virtio-sound: allocate an array of streams Alexander Mikhalitsyn
2026-08-03 8:11 ` [PATCH v5 05/10] hw/audio/virtio-sound: free all stream buffers on reset Alexander Mikhalitsyn
2026-08-03 8:11 ` [PATCH v5 06/10] hw/audio/virtio-sound: split out virtio_snd_pcm_start_stop() Alexander Mikhalitsyn
2026-08-03 8:11 ` [PATCH v5 07/10] hw/audio/virtio-sound: add stream state variable Alexander Mikhalitsyn
2026-08-03 8:11 ` Alexander Mikhalitsyn [this message]
2026-08-03 8:11 ` [PATCH v5 09/10] hw/audio/virtio-sound: introduce virtio_snd_set_active() Alexander Mikhalitsyn
2026-08-03 8:11 ` [PATCH v5 10/10] hw/audio/virtio-sound: add missing vmstate fields Alexander Mikhalitsyn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260803081159.91981-9-alexander@mihalicyn.com \
--to=alexander@mihalicyn.com \
--cc=aleksandr.mikhalitsyn@futurfusion.io \
--cc=berrange@redhat.com \
--cc=kraxel@redhat.com \
--cc=manos.pitsidianakis@linaro.org \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stgraber@stgraber.org \
--cc=vr_qemu@t-online.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.