From: Volker Rümelin <[email protected]> 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 <[email protected]> [AM: trivial variable rename s -> vsnd] Signed-off-by: Alexander Mikhalitsyn <[email protected]> Reviewed-by: Marc-André Lureau <[email protected]> Reviewed-by: Manos Pitsidianakis <[email protected]> --- v4: - reduced a scope of loop counter variable in virtio_snd_reset (as suggested by Manos Pitsidianakis) --- hw/audio/virtio-snd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c index b2b711457bb..d51fc386593 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -1352,6 +1352,16 @@ static void virtio_snd_reset(VirtIODevice *vdev) QTAILQ_REMOVE(&vsnd->cmdq, cmd, next); virtio_snd_ctrl_cmd_free(cmd); } + + for (uint32_t i = 0; i < vsnd->snd_conf.streams; i++) { + VirtIOSoundPCMStream *stream = &vsnd->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, const void *data) -- 2.47.3
