All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Volker Rümelin" <vr_qemu@t-online.de>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org, Geoffrey McRae <geoff@hostfission.com>
Subject: [PATCH 06/12] spiceaudio: add a pcm_ops buffer_get_free function
Date: Fri, 23 Sep 2022 20:36:34 +0200	[thread overview]
Message-ID: <20220923183640.8314-6-vr_qemu@t-online.de> (raw)
In-Reply-To: <38d7417a-fc26-be39-6a63-99c79ee15fc9@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>
---
 audio/spiceaudio.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c
index a8d370fe6f..22892a7b9d 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.35.3



  parent reply	other threads:[~2022-09-23 19:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-23 18:34 [PATCH 00/12] audio: misc. improvements and bug fixes Volker Rümelin
2022-09-23 18:36 ` [PATCH 01/12] audio: refactor code in audio_run_out() Volker Rümelin
2022-09-27 11:54   ` Marc-André Lureau
2022-09-23 18:36 ` [PATCH 02/12] audio: fix GUS audio playback with out.mixing-engine=off Volker Rümelin
2022-09-27 11:54   ` Marc-André Lureau
2022-09-23 18:36 ` [PATCH 03/12] audio: run downstream playback queue unconditionally Volker Rümelin
2022-09-27 11:54   ` Marc-André Lureau
2022-09-23 18:36 ` [PATCH 04/12] alsaaudio: reduce playback latency Volker Rümelin
2022-09-27 11:54   ` Marc-André Lureau
2022-09-23 18:36 ` [PATCH 05/12] audio: add more audio rate control functions Volker Rümelin
2022-09-27 11:54   ` Marc-André Lureau
2022-09-23 18:36 ` Volker Rümelin [this message]
2022-09-27 11:54   ` [PATCH 06/12] spiceaudio: add a pcm_ops buffer_get_free function Marc-André Lureau
2022-09-23 18:36 ` [PATCH 07/12] spiceaudio: update comment Volker Rümelin
2022-09-27 11:54   ` Marc-André Lureau
2022-09-23 18:36 ` [PATCH 08/12] audio: swap audio_rate_get_bytes() function parameters Volker Rümelin
2022-09-27 11:54   ` Marc-André Lureau
2022-09-23 18:36 ` [PATCH 09/12] audio: rename audio_sw_bytes_free() Volker Rümelin
2022-09-27 11:54   ` Marc-André Lureau
2022-09-23 18:36 ` [PATCH 10/12] audio: refactor audio_get_avail() Volker Rümelin
2022-09-27 11:54   ` Marc-André Lureau
2022-09-23 18:36 ` [PATCH 11/12] audio: fix sw->buf size for audio recording Volker Rümelin
2022-09-27 11:54   ` Marc-André Lureau
2022-10-01 12:08     ` Volker Rümelin
2022-09-23 18:36 ` [PATCH 12/12] audio: prevent an integer overflow in resampling code Volker Rümelin
2022-10-11 13:31 ` [PATCH 00/12] audio: misc. improvements and bug fixes Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220923183640.8314-6-vr_qemu@t-online.de \
    --to=vr_qemu@t-online.de \
    --cc=geoff@hostfission.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.