]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
audio/spiceaudio: always rate limit playback stream
authorVolker Rümelin <vr_qemu@t-online.de>
Sun, 20 Sep 2020 17:17:23 +0000 (19:17 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Wed, 23 Sep 2020 06:19:42 +0000 (08:19 +0200)
The playback rate with the spiceaudio backend is currently too
fast if there's no spice client connected or the spice client
can't play audio. Rate limit the audio playback stream in all
cases. To calculate the rate correctly the limiter has to know
the maximum buffer size.

Fixes: 8c198ff065 ("spiceaudio: port to the new audio backend api")
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-id: 20200920171729.15861-3-vr_qemu@t-online.de
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
audio/audio.c
audio/spiceaudio.c

index 7b660dd0c4d0568386c414561a13a625feaeca1b..d5891e1928bcdb14934f23f2d2ca2f8e487e7e41 100644 (file)
@@ -1089,7 +1089,8 @@ static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, size_t live)
     size_t clipped = 0;
 
     while (live) {
-        size_t size, decr, proc;
+        size_t size = live * hw->info.bytes_per_frame;
+        size_t decr, proc;
         void *buf = hw->pcm_ops->get_buffer_out(hw, &size);
 
         if (size == 0) {
index c8d81ba442909420c3c0b5b67e731c89434b59a5..c062742622e4af71129c447b45088cd65329ac4b 100644 (file)
@@ -130,13 +130,11 @@ static void *line_out_get_buffer(HWVoiceOut *hw, size_t *size)
     }
 
     if (out->frame) {
-        *size = audio_rate_get_bytes(
-            &hw->info, &out->rate,
-            (out->fsize - out->fpos) * hw->info.bytes_per_frame);
-    } else {
-        audio_rate_start(&out->rate);
-        *size = LINE_OUT_SAMPLES << 2;
+        *size = MIN((out->fsize - out->fpos) << 2, *size);
     }
+
+    *size = audio_rate_get_bytes(&hw->info, &out->rate, *size);
+
     return out->frame + out->fpos;
 }