The virtio_snd_pcm_set_params values are latched
into a VirtIOSoundPCMStream instance during
the PREPARE request where they are converted into
audsettings. Only the `period_bytes` value is used
afterwards.
Having both audsettings and virtio_snd_pcm_set_params
next to each other grows sizeof and adds confusion to
snapshot handling.
Signed-off-by: Roman Kiryanov <rkir@google.com>
---
hw/audio/virtio-snd.c | 6 +++---
include/hw/audio/virtio-snd.h | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c
index bd6a5d71bb..6d820b56a6 100644
--- a/hw/audio/virtio-snd.c
+++ b/hw/audio/virtio-snd.c
@@ -461,7 +461,7 @@ static uint32_t virtio_snd_pcm_prepare(VirtIOSound *s, uint32_t stream_id)
stream->info.channels_max = as.nchannels;
stream->info.formats = supported_formats;
stream->info.rates = supported_rates;
- stream->params = *params;
+ stream->period_bytes = params->period_bytes;
stream->as = as;
if (stream->info.direction == VIRTIO_SND_D_OUTPUT) {
@@ -1271,7 +1271,7 @@ static void virtio_snd_pcm_in_cb(void *data, int available)
return_rx_buffer(stream, buffer);
break;
}
- to_read = stream->params.period_bytes - buffer->size;
+ to_read = stream->period_bytes - buffer->size;
to_read = MIN(to_read, available);
to_read = MIN(to_read, max_size - buffer->size);
size = audio_be_read(stream->s->audio_be,
@@ -1284,7 +1284,7 @@ static void virtio_snd_pcm_in_cb(void *data, int available)
}
buffer->size += size;
available -= size;
- if (buffer->size >= stream->params.period_bytes) {
+ if (buffer->size >= stream->period_bytes) {
return_rx_buffer(stream, buffer);
break;
}
diff --git a/include/hw/audio/virtio-snd.h b/include/hw/audio/virtio-snd.h
index f8bb5c95b9..a767f68301 100644
--- a/include/hw/audio/virtio-snd.h
+++ b/include/hw/audio/virtio-snd.h
@@ -135,8 +135,8 @@ struct VirtIOSoundPCM {
struct VirtIOSoundPCMStream {
virtio_snd_pcm_info info;
- virtio_snd_pcm_set_params params;
uint32_t id;
+ uint32_t period_bytes; /* from virtio_snd_pcm_set_params */
VirtIOSound *s;
bool flushing;
audsettings as;
--
2.53.0.473.g4a7958ca14-goog