[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
- [PATCH v2 00/11] virtio-sound migration part 1, Volker Rümelin, 2024/02/18
- [PATCH v2 01/11] hw/audio/virtio-sound: return correct command response size, Volker Rümelin, 2024/02/18
- [PATCH v2 02/11] hw/audio/virtio-sound: fix segmentation fault in tx/rx xfer handler, Volker Rümelin, 2024/02/18
- [PATCH v2 03/11] hw/audio/virtio-sound: remove command and stream mutexes, Volker Rümelin, 2024/02/18
- [PATCH v2 05/11] hw/audio/virtio-sound: free all stream buffers on reset,
Volker Rümelin <=
- [PATCH v2 04/11] hw/audio/virtio-sound: allocate an array of streams, Volker Rümelin, 2024/02/18
- [PATCH v2 06/11] hw/audio/virtio-sound: split out virtio_snd_pcm_start_stop(), Volker Rümelin, 2024/02/18
- [PATCH v2 07/11] hw/audio/virtio-sound: add stream state variable, Volker Rümelin, 2024/02/18
- [PATCH v2 08/11] hw/audio/virtio-sound: introduce virtio_snd_pcm_open(), Volker Rümelin, 2024/02/18
- [PATCH v2 10/11] hw/audio/virtio-sound: add missing vmstate fields, Volker Rümelin, 2024/02/18
- [PATCH v2 09/11] hw/audio/virtio-sound: introduce virtio_snd_set_active(), Volker Rümelin, 2024/02/18
- [PATCH v2 11/11] hw/audio/virtio-sound: add placeholder for buffer write position, Volker Rümelin, 2024/02/18