[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/26] spiceaudio: add a pcm_ops buffer_get_free function
From: |
Gerd Hoffmann |
Subject: |
[PULL 06/26] spiceaudio: add a pcm_ops buffer_get_free function |
Date: |
Thu, 13 Oct 2022 08:52:04 +0200 |
From: Volker Rümelin <vr_qemu@t-online.de>
It seems there is a demand [1] for low latency playback over
SPICE. Add a pcm_ops buffer_get_free function to reduce the
playback latency. The mixing engine buffer becomes a temporary
buffer.
[1] https://lists.nongnu.org/archive/html/qemu-devel/2022-01/msg01644.html
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20220923183640.8314-6-vr_qemu@t-online.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
audio/spiceaudio.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c
index a8d370fe6f31..22892a7b9d42 100644
--- a/audio/spiceaudio.c
+++ b/audio/spiceaudio.c
@@ -120,6 +120,13 @@ static void line_out_fini (HWVoiceOut *hw)
spice_server_remove_interface (&out->sin.base);
}
+static size_t line_out_get_free(HWVoiceOut *hw)
+{
+ SpiceVoiceOut *out = container_of(hw, SpiceVoiceOut, hw);
+
+ return audio_rate_peek_bytes(&out->rate, &hw->info);
+}
+
static void *line_out_get_buffer(HWVoiceOut *hw, size_t *size)
{
SpiceVoiceOut *out = container_of(hw, SpiceVoiceOut, hw);
@@ -133,8 +140,6 @@ static void *line_out_get_buffer(HWVoiceOut *hw, size_t
*size)
*size = MIN((out->fsize - out->fpos) << 2, *size);
}
- *size = audio_rate_get_bytes(&hw->info, &out->rate, *size);
-
return out->frame + out->fpos;
}
@@ -142,6 +147,8 @@ static size_t line_out_put_buffer(HWVoiceOut *hw, void
*buf, size_t size)
{
SpiceVoiceOut *out = container_of(hw, SpiceVoiceOut, hw);
+ audio_rate_add_bytes(&out->rate, size);
+
if (buf) {
assert(buf == out->frame + out->fpos && out->fpos <= out->fsize);
out->fpos += size >> 2;
@@ -282,6 +289,7 @@ static struct audio_pcm_ops audio_callbacks = {
.init_out = line_out_init,
.fini_out = line_out_fini,
.write = audio_generic_write,
+ .buffer_get_free = line_out_get_free,
.get_buffer_out = line_out_get_buffer,
.put_buffer_out = line_out_put_buffer,
.enable_out = line_out_enable,
--
2.37.3
- [PULL 00/26] Kraxel 20221013 patches, Gerd Hoffmann, 2022/10/13
- [PULL 01/26] audio: refactor code in audio_run_out(), Gerd Hoffmann, 2022/10/13
- [PULL 02/26] audio: fix GUS audio playback with out.mixing-engine=off, Gerd Hoffmann, 2022/10/13
- [PULL 03/26] audio: run downstream playback queue unconditionally, Gerd Hoffmann, 2022/10/13
- [PULL 04/26] alsaaudio: reduce playback latency, Gerd Hoffmann, 2022/10/13
- [PULL 06/26] spiceaudio: add a pcm_ops buffer_get_free function,
Gerd Hoffmann <=
- [PULL 07/26] spiceaudio: update comment, Gerd Hoffmann, 2022/10/13
- [PULL 08/26] audio: swap audio_rate_get_bytes() function parameters, Gerd Hoffmann, 2022/10/13
- [PULL 15/26] cirrus_vga: fix potential memory overflow, Gerd Hoffmann, 2022/10/13
- [PULL 23/26] qemu-edid: Restrict input parameter -d to avoid division by zero, Gerd Hoffmann, 2022/10/13
- [PULL 05/26] audio: add more audio rate control functions, Gerd Hoffmann, 2022/10/13
- [PULL 10/26] audio: refactor audio_get_avail(), Gerd Hoffmann, 2022/10/13
- [PULL 12/26] audio: prevent an integer overflow in resampling code, Gerd Hoffmann, 2022/10/13
- [PULL 16/26] docs: add firmware feature flags, Gerd Hoffmann, 2022/10/13
- [PULL 17/26] pci-ids: drop PCI_DEVICE_ID_VIRTIO_IOMMU, Gerd Hoffmann, 2022/10/13
- [PULL 22/26] ui/gtk: Fix the implicit mouse ungrabbing logic, Gerd Hoffmann, 2022/10/13