* [PATCH 0/3] DirectSound fixes for 5.0
@ 2020-04-01 18:59 Volker Rümelin
2020-04-01 19:00 ` [PATCH 1/3] dsoundaudio: fix never-ending playback loop Volker Rümelin
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Volker Rümelin @ 2020-04-01 18:59 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: QEMU, Zoltán Kővágó
[-- Attachment #1: Type: text/plain, Size: 456 bytes --]
Three audio fixes for DirectSound on Windows. They were tested
on a Windows 10 Home system with HAXM accelerator.
Volker Rümelin (3):
dsoundaudio: fix never-ending playback loop
dsoundaudio: fix "Could not lock capture buffer" warning
dsoundaudio: dsound_get_buffer_in should honor *size
audio/audio.c | 12 +++++-------
audio/dsoundaudio.c | 13 ++++++++++---
2 files changed, 15 insertions(+), 10 deletions(-)
--
2.16.4
[-- Attachment #2: Type: text/html, Size: 603 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] dsoundaudio: fix never-ending playback loop
2020-04-01 18:59 [PATCH 0/3] DirectSound fixes for 5.0 Volker Rümelin
@ 2020-04-01 19:00 ` Volker Rümelin
2020-04-01 19:00 ` [PATCH 2/3] dsoundaudio: fix "Could not lock capture buffer" warning Volker Rümelin
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Volker Rümelin @ 2020-04-01 19:00 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: QEMU, Zoltán Kővágó
Currently the DirectSound backend fails to stop audio playback
in dsound_enable_out(). The call to IDirectSoundBuffer_GetStatus()
in dsound_get_status_out() returns a status word with the flag
DSERR_BUFFERLOST set (probably because of a buffer underrun).
The function dsound_get_status_out() correctly calls
dsound_restore_out() and returns an error. This is wrong. If
dsound_restore_out() succeeds the program should continue without
an error.
To reproduce the bug start qemu on a Windows host with
-soundhw pcspk -audiodev dsound,id=audio0. On the guest
FreeDOS 1.2 command line enter beep. The image Day 1 - F-Bird
from the QEMU Advent Calendar 2018 shows the bug as well.
Fixes: 2762955f72 "dsoundaudio: remove *_retries kludges"
Buglink: https://bugs.launchpad.net/qemu/+bug/1699628
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
---
audio/dsoundaudio.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c
index bd57082a8d..af70dd128e 100644
--- a/audio/dsoundaudio.c
+++ b/audio/dsoundaudio.c
@@ -280,8 +280,10 @@ static int dsound_get_status_out (LPDIRECTSOUNDBUFFER dsb, DWORD *statusp,
}
if (*statusp & DSERR_BUFFERLOST) {
- dsound_restore_out(dsb, s);
- return -1;
+ if (dsound_restore_out(dsb, s)) {
+ return -1;
+ }
+ *statusp &= ~DSERR_BUFFERLOST;
}
return 0;
--
2.16.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] dsoundaudio: fix "Could not lock capture buffer" warning
2020-04-01 18:59 [PATCH 0/3] DirectSound fixes for 5.0 Volker Rümelin
2020-04-01 19:00 ` [PATCH 1/3] dsoundaudio: fix never-ending playback loop Volker Rümelin
@ 2020-04-01 19:00 ` Volker Rümelin
2020-04-01 19:00 ` [PATCH 3/3] dsoundaudio: dsound_get_buffer_in should honor *size Volker Rümelin
2020-04-01 21:58 ` [PATCH 0/3] DirectSound fixes for 5.0 Volker Rümelin
3 siblings, 0 replies; 5+ messages in thread
From: Volker Rümelin @ 2020-04-01 19:00 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: QEMU, Zoltán Kővágó
IDirectSoundCaptureBuffer_Lock() fails on Windows when called
with len = 0. Return early from dsound_get_buffer_in() in this
case.
To reproduce the warning start a linux guest. In the guest
start Audacity and you will see a lot of "Could not lock
capture buffer" warnings.
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
---
audio/dsoundaudio.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c
index af70dd128e..ea1595dcd1 100644
--- a/audio/dsoundaudio.c
+++ b/audio/dsoundaudio.c
@@ -544,6 +544,11 @@ static void *dsound_get_buffer_in(HWVoiceIn *hw, size_t *size)
req_size = audio_ring_dist(cpos, hw->pos_emul, hw->size_emul);
req_size = MIN(req_size, hw->size_emul - hw->pos_emul);
+ if (req_size == 0) {
+ *size = 0;
+ return NULL;
+ }
+
err = dsound_lock_in(dscb, &hw->info, hw->pos_emul, req_size, &ret, NULL,
&act_size, NULL, false, ds->s);
if (err) {
--
2.16.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] dsoundaudio: dsound_get_buffer_in should honor *size
2020-04-01 18:59 [PATCH 0/3] DirectSound fixes for 5.0 Volker Rümelin
2020-04-01 19:00 ` [PATCH 1/3] dsoundaudio: fix never-ending playback loop Volker Rümelin
2020-04-01 19:00 ` [PATCH 2/3] dsoundaudio: fix "Could not lock capture buffer" warning Volker Rümelin
@ 2020-04-01 19:00 ` Volker Rümelin
2020-04-01 21:58 ` [PATCH 0/3] DirectSound fixes for 5.0 Volker Rümelin
3 siblings, 0 replies; 5+ messages in thread
From: Volker Rümelin @ 2020-04-01 19:00 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: QEMU, Zoltán Kővágó
This patch prevents an underflow of variable samples in function
audio_pcm_hw_run_in(). See commit 599eac4e5a "audio:
audio_generic_get_buffer_in should honor *size". This time the
while loop in audio_pcm_hw_run_in() will terminate nevertheless,
because it seems the recording stream in Windows is always rate
limited.
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
---
audio/audio.c | 12 +++++-------
audio/dsoundaudio.c | 2 +-
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/audio/audio.c b/audio/audio.c
index 9ac9a20c41..7a9e680355 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1491,15 +1491,13 @@ size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size)
size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size)
{
- size_t src_size, copy_size;
- void *src = hw->pcm_ops->get_buffer_in(hw, &src_size);
- copy_size = MIN(size, src_size);
+ void *src = hw->pcm_ops->get_buffer_in(hw, &size);
- memcpy(buf, src, copy_size);
- hw->pcm_ops->put_buffer_in(hw, src, copy_size);
- return copy_size;
-}
+ memcpy(buf, src, size);
+ hw->pcm_ops->put_buffer_in(hw, src, size);
+ return size;
+}
static int audio_driver_init(AudioState *s, struct audio_driver *drv,
bool msg, Audiodev *dev)
diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c
index ea1595dcd1..d3522f0e00 100644
--- a/audio/dsoundaudio.c
+++ b/audio/dsoundaudio.c
@@ -542,7 +542,7 @@ static void *dsound_get_buffer_in(HWVoiceIn *hw, size_t *size)
}
req_size = audio_ring_dist(cpos, hw->pos_emul, hw->size_emul);
- req_size = MIN(req_size, hw->size_emul - hw->pos_emul);
+ req_size = MIN(*size, MIN(req_size, hw->size_emul - hw->pos_emul));
if (req_size == 0) {
*size = 0;
--
2.16.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] DirectSound fixes for 5.0
2020-04-01 18:59 [PATCH 0/3] DirectSound fixes for 5.0 Volker Rümelin
` (2 preceding siblings ...)
2020-04-01 19:00 ` [PATCH 3/3] dsoundaudio: dsound_get_buffer_in should honor *size Volker Rümelin
@ 2020-04-01 21:58 ` Volker Rümelin
3 siblings, 0 replies; 5+ messages in thread
From: Volker Rümelin @ 2020-04-01 21:58 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: QEMU, Zoltán Kővágó
[-- Attachment #1: Type: text/plain, Size: 157 bytes --]
Sorry, please ignore this patch series. Patch 1/3 "dsoundaudio:
fix never-ending playback loop" is wrong. I'll send a version 2.
With best regards,
Volker
[-- Attachment #2: Type: text/html, Size: 344 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-04-01 21:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-01 18:59 [PATCH 0/3] DirectSound fixes for 5.0 Volker Rümelin
2020-04-01 19:00 ` [PATCH 1/3] dsoundaudio: fix never-ending playback loop Volker Rümelin
2020-04-01 19:00 ` [PATCH 2/3] dsoundaudio: fix "Could not lock capture buffer" warning Volker Rümelin
2020-04-01 19:00 ` [PATCH 3/3] dsoundaudio: dsound_get_buffer_in should honor *size Volker Rümelin
2020-04-01 21:58 ` [PATCH 0/3] DirectSound fixes for 5.0 Volker Rümelin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).