[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 20/23] dsoundaudio: replace GetForegroundWindow()
From: |
Volker Rümelin |
Subject: |
[PATCH 20/23] dsoundaudio: replace GetForegroundWindow() |
Date: |
Sun, 10 Jan 2021 11:02:36 +0100 |
GetForegroundWindow() doesn't necessarily return the own window
handle. It just returns a handle to the currently active window
and can even return NULL. At the time dsound_open() gets called
the active window is most likely the shell window and not the
QEMU window.
Replace GetForegroundWindow() with GetDesktopWindow() which
always returns a valid window handle, and at the same time
replace the DirectSound buffer flag DSBCAPS_STICKYFOCUS with
DSBCAPS_GLOBALFOCUS where Windows only expects a valid window
handle for DirectSound function SetCooperativeLevel(). The
Microsoft online docs for IDirectSound::SetCooperativeLevel
recommend this in the remarks.
This fixes a bug where you can't hear sound from the guest.
To reproduce start qemu with -machine pcspk-audiodev=audio0
-device intel-hda -device hda-duplex,audiodev=audio0
-audiodev dsound,id=audio0,out.mixing-engine=off
from a shell and start audio playback with the hda device in the
guest. The guest will be silent. To hear guest audio you have to
activate the shell window once.
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
---
audio/dsound_template.h | 2 +-
audio/dsoundaudio.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/audio/dsound_template.h b/audio/dsound_template.h
index 9c5ce625ab..0678f2de38 100644
--- a/audio/dsound_template.h
+++ b/audio/dsound_template.h
@@ -205,7 +205,7 @@ static int dsound_init_out(HWVoiceOut *hw, struct
audsettings *as,
NULL
);
#else
- bd.dwFlags = DSBCAPS_STICKYFOCUS | DSBCAPS_GETCURRENTPOSITION2;
+ bd.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_GETCURRENTPOSITION2;
hr = IDirectSound_CreateSoundBuffer (
s->dsound,
&bd,
diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c
index 4cdf19ab67..0fbdf770ac 100644
--- a/audio/dsoundaudio.c
+++ b/audio/dsoundaudio.c
@@ -347,7 +347,7 @@ static int dsound_open (dsound *s)
HRESULT hr;
HWND hwnd;
- hwnd = GetForegroundWindow ();
+ hwnd = GetDesktopWindow();
hr = IDirectSound_SetCooperativeLevel (
s->dsound,
hwnd,
--
2.26.2
- [PATCH 10/23] audio: break generic buffer dependency on mixing-engine, (continued)
- [PATCH 10/23] audio: break generic buffer dependency on mixing-engine, Volker Rümelin, 2021/01/10
- [PATCH 08/23] audio: split pcm_ops function get_buffer_in, Volker Rümelin, 2021/01/10
- [PATCH 09/23] sdlaudio: add recording functions, Volker Rümelin, 2021/01/10
- [PATCH 11/23] sdlaudio: enable (in|out).mixing-engine=off, Volker Rümelin, 2021/01/10
- [PATCH 13/23] paaudio: avoid to clip samples multiple times, Volker Rümelin, 2021/01/10
- [PATCH 14/23] paaudio: wait for PA_STREAM_READY in qpa_write(), Volker Rümelin, 2021/01/10
- [PATCH 15/23] paaudio: wait until the playback stream is ready, Volker Rümelin, 2021/01/10
- [PATCH 12/23] audio: remove remaining unused plive code, Volker Rümelin, 2021/01/10
- [PATCH 16/23] paaudio: remove unneeded code, Volker Rümelin, 2021/01/10
- [PATCH 18/23] paaudio: limit minreq to 75% of audio timer_rate, Volker Rümelin, 2021/01/10
- [PATCH 20/23] dsoundaudio: replace GetForegroundWindow(),
Volker Rümelin <=
- [PATCH 17/23] paaudio: comment bugs in functions qpa_init_*, Volker Rümelin, 2021/01/10
- [PATCH 19/23] paaudio: send recorded data in smaller chunks, Volker Rümelin, 2021/01/10
- [PATCH 21/23] dsoundaudio: rename dsound_open(), Volker Rümelin, 2021/01/10
- [PATCH 22/23] dsoundaudio: enable f32 audio sample format, Volker Rümelin, 2021/01/10
- [PATCH 23/23] dsoundaudio: fix log message, Volker Rümelin, 2021/01/10
- Re: [PATCH 00/23] next round of audio patches, no-reply, 2021/01/10
- Re: [PATCH 00/23] next round of audio patches, Gerd Hoffmann, 2021/01/14