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_q...@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