[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/9] audio/spiceaudio: always rate limit playback stream
From: |
Volker Rümelin |
Subject: |
[PATCH 3/9] audio/spiceaudio: always rate limit playback stream |
Date: |
Sun, 20 Sep 2020 19:17:23 +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>
---
audio/audio.c | 3 ++-
audio/spiceaudio.c | 10 ++++------
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/audio/audio.c b/audio/audio.c
index ad3f57b4c4..ba52259050 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -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) {
diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c
index c8d81ba442..c062742622 100644
--- a/audio/spiceaudio.c
+++ b/audio/spiceaudio.c
@@ -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;
}
--
2.26.2
- [PATCH 0/9] Audio fixes and improvements, Volker Rümelin, 2020/09/20
- [PATCH 1/9] audio: handle buf == NULL in put_buffer_out(), Volker Rümelin, 2020/09/20
- [PATCH 3/9] audio/spiceaudio: always rate limit playback stream,
Volker Rümelin <=
- [PATCH 2/9] audio/audio: fix video playback slowdown with spiceaudio, Volker Rümelin, 2020/09/20
- [PATCH 4/9] audio: align audio_generic_read with audio_pcm_hw_run_in, Volker Rümelin, 2020/09/20
- [PATCH 7/9] audio: run downstream playback queue unconditionally, Volker Rümelin, 2020/09/20
- [PATCH 8/9] audio: restore mixing-engine playback buffer size, Volker Rümelin, 2020/09/20
- [PATCH 6/9] audio: align audio_generic_write with audio_pcm_hw_run_out, Volker Rümelin, 2020/09/20
- [PATCH 5/9] audio: remove unnecessary calls to put_buffer_in, Volker Rümelin, 2020/09/20
- [PATCH 9/9] audio: revert tests for pcm_ops table, Volker Rümelin, 2020/09/20
- Re: [PATCH 0/9] Audio fixes and improvements, Gerd Hoffmann, 2020/09/23