From e8c2e283f0954de255a32ea70d577d5e61992399 Mon Sep 17 00:00:00 2001
From: Qi Zhou <atmgnd@outlook.com>
Date: Thu, 10 Sep 2020 19:09:29 +0800
Subject: [PATCH] Fix video playback slowdown when spice client no audio enabled
You will get video playback slowdown on the following cases
1. use official spice client with audio channel disabled, use --spice-disable-audio
option
2. thirtpart client doesn't implement audio channel
ref: https://github.com/qemu/qemu/commit/fb35c2cec58985f0b8d2733f1b91927542eeb3fd
Signed-off-by: Qi Zhou <atmgnd@outlook.com>
---
audio/audio.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/audio/audio.c b/audio/audio.c
index ce8c6dec5f..50febe190f 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1091,7 +1091,11 @@ static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, size_t live)
while (live) {
size_t size, decr, proc;
void *buf = hw->pcm_ops->get_buffer_out(hw, &size);
- if (!buf || size == 0) {
+
+ if (!buf) {
+ hw->mix_buf->pos = (hw->mix_buf->pos + live) % hw->mix_buf->size;
+ return clipped + live;
+ } else if ( size == 0) {
break;
}
--
2.17.1
Am 10.09.20 um 13:17 schrieb zhou qi: > From e8c2e283f0954de255a32ea70d577d5e61992399 Mon Sep 17 00:00:00 2001 > From: Qi Zhou <atmgnd@outlook.com> > Date: Thu, 10 Sep 2020 19:09:29 +0800 > Subject: [PATCH] Fix video playback slowdown when spice client no audio enabled > > You will get video playback slowdown on the following cases > > 1. use official spice client with audio channel disabled, use --spice-disable-audio > option > 2. thirtpart client doesn't implement audio channel > > ref: https://github.com/qemu/qemu/commit/fb35c2cec58985f0b8d2733f1b91927542eeb3fd > Signed-off-by: Qi Zhou <atmgnd@outlook.com> > --- > audio/audio.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/audio/audio.c b/audio/audio.c > index ce8c6dec5f..50febe190f 100644 > --- a/audio/audio.c > +++ b/audio/audio.c > @@ -1091,7 +1091,11 @@ static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, size_t live) > while (live) { > size_t size, decr, proc; > void *buf = hw->pcm_ops->get_buffer_out(hw, &size); > - if (!buf || size == 0) { > + > + if (!buf) { > + hw->mix_buf->pos = (hw->mix_buf->pos + live) % hw->mix_buf->size; > + return clipped + live; > + } else if ( size == 0) { > break; > } > Hello Qi, your patch breaks audio playback with the dsoundaudio backend. I suggest you make the following changes: - Test for size == 0 first and leave the loop in that case. - For buf == NULL drop size bytes. Don't leave the loop with break or return. - Verify all audio backends adhere to the new rules and fix them if necessary. It's quite possible no patches are needed. - Rate limit the audio stream in function line_out_get_buffer() in audio/spiceaudio.c for the noaudio case too. Have a look at audio/spiceaudio.c at version v4.1.0. The code there was correct. Please don't forget to run scripts/checkpatch.pl on your next patches and don't forget to CC the maintainer. With best regards, Volker
> Hello Qi, > > your patch breaks audio playback with the dsoundaudio backend. > > I suggest you make the following changes: > > - Test for size == 0 first and leave the loop in that case. > - For buf == NULL drop size bytes. Don't leave the loop with break or return. > - Verify all audio backends adhere to the new rules and fix them if necessary. It's quite possible no patches are needed. > - Rate limit the audio stream in function line_out_get_buffer() in audio/spiceaudio.c for the noaudio case too. Have a look at audio/spiceaudio.c at version v4.1.0. The code there was correct. > > Please don't forget to run scripts/checkpatch.pl on your next patches and don't forget to CC the maintainer. > > With best regards, > > Volker Hello Qi, I wonder if you are already working on an improved fix. Otherwise I will send my patches this weekend to the mailing list. With best regards, Volker
Sorry for the late reply, I am not working on improve this patch(at least not now), And you are welcome to send your patches. 发件人: Volker Rümelin <vr_qemu@t-online.de> 发送时间: 2020年9月18日 1:22 收件人: zhou qi <atmgnd@outlook.com> 抄送: qemu-devel@nongnu.org <qemu-devel@nongnu.org> 主题: Re: [PATCH] Fix video playback slowdown when spice client no audio enabled > Hello Qi, > > your patch breaks audio playback with the dsoundaudio backend. > > I suggest you make the following changes: > > - Test for size == 0 first and leave the loop in that case. > - For buf == NULL drop size bytes. Don't leave the loop with break or return. > - Verify all audio backends adhere to the new rules and fix them if necessary. It's quite possible no patches are needed. > - Rate limit the audio stream in function line_out_get_buffer() in audio/spiceaudio.c for the noaudio case too. Have a look at audio/spiceaudio.c at version v4.1.0. The code there was correct. > > Please don't forget to run scripts/checkpatch.pl on your next patches and don't forget to CC the maintainer. > > With best regards, > > Volker Hello Qi, I wonder if you are already working on an improved fix. Otherwise I will send my patches this weekend to the mailing list. With best regards, Volker
Because I don't received any feedback, so i have decide resend again. with more detail.
@DirtY.iCE.hu, Can you review this patch? or someone else has time ?
Issue: video playback slowdown, using spice client --spice-disable-audio option
How to reproduce:
1. compile qemu master for x86_64 target with spice enabled.
2. laucher a windows 7 virtual machine with some like: qemu-system-x86_64 --enable-kvm -M q35,accel=kvm -display none -spice port=5907,addr=0.0.0.0,disable-ticketing -device intel-hda,id=s0 -device hda-duplex,id=s0-codec0,bus=s0.0,cad=0
3. connect the virtual machine using official remote-viewer without spice audio channel. which is:
remote-viewer spice://localhost:5907 --spice-disable-audio
4. open windows sample video using default media player. video location: C:\Users\Public\Videos\Sample Videos\Wildlife.wmv
You will see the video playback speed is very slow.
I HAVE TEST QEMU 4.2.1 DOES NOT HAVE THIS ISSUE. And I believe this issue was indroduced by this commit: https://github.com/qemu/qemu/commit/fb35c2cec58985f0b8d2733f1b91927542eeb3fd
best regards
发件人: zhou qi <atmgnd@outlook.com>
发送时间: 2020年9月10日 19:17
收件人: qemu-devel@nongnu.org <qemu-devel@nongnu.org>
主题: [PATCH] Fix video playback slowdown when spice client no audio enabled
From e8c2e283f0954de255a32ea70d577d5e61992399 Mon Sep 17 00:00:00 2001
From: Qi Zhou <atmgnd@outlook.com>
Date: Thu, 10 Sep 2020 19:09:29 +0800
Subject: [PATCH] Fix video playback slowdown when spice client no audio enabled
You will get video playback slowdown on the following cases
1. use official spice client with audio channel disabled, use --spice-disable-audio
option
2. thirtpart client doesn't implement audio channel
ref: https://github.com/qemu/qemu/commit/fb35c2cec58985f0b8d2733f1b91927542eeb3fd
Signed-off-by: Qi Zhou <atmgnd@outlook.com>
---
audio/audio.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/audio/audio.c b/audio/audio.c
index ce8c6dec5f..50febe190f 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1091,7 +1091,11 @@ static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, size_t live)
while (live) {
size_t size, decr, proc;
void *buf = hw->pcm_ops->get_buffer_out(hw, &size);
- if (!buf || size == 0) {
+
+ if (!buf) {
+ hw->mix_buf->pos = (hw->mix_buf->pos + live) % hw->mix_buf->size;
+ return clipped + live;
+ } else if ( size == 0) {
break;
}
--
2.17.1
© 2016 - 2024 Red Hat, Inc.