qemu-stable
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 05/11] hw/audio/virtio-sound: free all stream buffers on reset


From: Volker Rümelin
Subject: [PATCH v2 05/11] hw/audio/virtio-sound: free all stream buffers on reset
Date: Sun, 18 Feb 2024 09:33:45 +0100

All remaining stream buffers in the stream queues must
be freed after a reset. This is the initial state of the
virtio-sound device.

Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
---
 hw/audio/virtio-snd.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c
index e5497b6bf6..2b630ada82 100644
--- a/hw/audio/virtio-snd.c
+++ b/hw/audio/virtio-snd.c
@@ -1318,12 +1318,23 @@ static void virtio_snd_reset(VirtIODevice *vdev)
 {
     VirtIOSound *s = VIRTIO_SND(vdev);
     virtio_snd_ctrl_command *cmd;
+    uint32_t i;
 
     while (!QTAILQ_EMPTY(&s->cmdq)) {
         cmd = QTAILQ_FIRST(&s->cmdq);
         QTAILQ_REMOVE(&s->cmdq, cmd, next);
         virtio_snd_ctrl_cmd_free(cmd);
     }
+
+    for (i = 0; i < s->snd_conf.streams; i++) {
+        VirtIOSoundPCMStream *stream = &s->streams[i];
+        VirtIOSoundPCMBuffer *buffer;
+
+        while ((buffer = QSIMPLEQ_FIRST(&stream->queue))) {
+            QSIMPLEQ_REMOVE_HEAD(&stream->queue, entry);
+            virtio_snd_pcm_buffer_free(buffer);
+        }
+    }
 }
 
 static void virtio_snd_class_init(ObjectClass *klass, void *data)
-- 
2.35.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]