[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 11/11] hw/audio/virtio-sound: add placeholder for buffer write
From: |
Volker Rümelin |
Subject: |
[PATCH v2 11/11] hw/audio/virtio-sound: add placeholder for buffer write position |
Date: |
Sun, 18 Feb 2024 09:33:51 +0100 |
When a running audio stream is migrated, on average half of a
recording stream buffer is lost or half of a playback stream
buffer is played twice. Add a placeholder for the write position
of the current stream buffer to the migrated data. Additional
program code is required to resolve the above issues. However,
the placeholder makes it possible to add code in a backwards and
forwards compatible way.
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
---
hw/audio/virtio-snd.c | 2 ++
include/hw/audio/virtio-snd.h | 2 ++
2 files changed, 4 insertions(+)
diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c
index b0a0ff2456..453c3a37ba 100644
--- a/hw/audio/virtio-snd.c
+++ b/hw/audio/virtio-snd.c
@@ -82,6 +82,7 @@ static const VMStateDescription vmstate_virtio_snd_stream = {
.name = "virtio-sound-stream",
.fields = (const VMStateField[]) {
VMSTATE_UINT32(state, VirtIOSoundPCMStream),
+ VMSTATE_UINT32(buf_wpos, VirtIOSoundPCMStream),
VMSTATE_UINT32(info.hdr.hda_fn_nid, VirtIOSoundPCMStream),
VMSTATE_UINT32(info.features, VirtIOSoundPCMStream),
VMSTATE_UINT64(info.formats, VirtIOSoundPCMStream),
@@ -1395,6 +1396,7 @@ static int virtio_snd_post_load(VirtIODevice *vdev)
virtio_snd_pcm_set_active(stream, true);
}
}
+ stream->buf_wpos = 0;
}
for (i = 0; i < VIRTIO_SND_VQ_MAX; i++) {
diff --git a/include/hw/audio/virtio-snd.h b/include/hw/audio/virtio-snd.h
index 457d18d196..9be0276996 100644
--- a/include/hw/audio/virtio-snd.h
+++ b/include/hw/audio/virtio-snd.h
@@ -124,6 +124,8 @@ struct VirtIOSoundPCMStream {
virtio_snd_pcm_set_params params;
uint32_t id;
uint32_t state;
+ /* placeholder: write position in current VirtIOSoundPCMBuffer */
+ uint32_t buf_wpos;
/* channel position values (VIRTIO_SND_CHMAP_XXX) */
uint8_t positions[VIRTIO_SND_CHMAP_MAX_SIZE];
VirtIOSound *s;
--
2.35.3
- [PATCH v2 01/11] hw/audio/virtio-sound: return correct command response size, (continued)
- [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, 2024/02/18
- [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 <=