Ticket #5578 (closed defect: fixed)
Sound shuts off when VM out of focus
Reported by: | AlanK | Owned by: | |
---|---|---|---|
Component: | audio | Version: | VirtualBox 3.2.8 |
Keywords: | Cc: | ||
Guest type: | Windows | Host type: | Windows |
Description
When playing a video or something in the VM, then click on a window outside the VM, sound shuts off in the VM. Sometimes clicking on the VM will restore the sound but sometimes not.
Change History
comment:1 in reply to: ↑ description Changed 13 years ago by pgeek
comment:2 Changed 13 years ago by pgeek
Some of these issues could probably be solved by changing the flags used to create the sound buffer in the DirectSound audio driver code.
Adding the DSBCAPS_GLOBALFOCUS flag should be enough:
--- src/VBox/Devices/Audio/dsoundaudio.c.orig 2009-12-17 14:27:41.000000000 +0000 +++ src/VBox/Devices/Audio/dsoundaudio.c 2009-12-24 13:07:20.431769153 +0000 @@ -568,7 +568,7 @@ memset (&dsbd, 0, sizeof (dsbd)); dsbd.dwSize = sizeof (dsbd); - dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER; + dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_GLOBALFOCUS; dsbd.dwBufferBytes = 0; dsbd.lpwfxFormat = NULL;
comment:3 Changed 12 years ago by frank
- priority changed from critical to major
- Component changed from other to audio
The question is if this behavior is a bug or a feature ... Surely this isn't critical.
comment:4 Changed 12 years ago by michaln
This is not so much a bug as the default DirectSound behavior. It is not true that switching focus to another window automatically stops the VM sound. It is true that switching to another application which uses DirectSound will stop the VM sound; that is because VirtualBox currently uses the DSBCAPS_STICKYFOCUS setting for its sound buffer. For example on my system, switching focus to a command prompt or to Acrobat Reader does not stop the VM from playing, but switching to Firefox does.
Giving focus to the VM again does restore the audio, unless of course there is another application using the write-primary DirectSound cooperative level.
comment:5 Changed 12 years ago by pgeek
As for being either a feature or bug, the fact that the issue has been reported could be an indication of a reasonable expectation - from some users at least - that if you are using the VM to play sound it should not depend on it having focus or on the applications running on the host. Hence the suggestion to depart from the default DirectSound behaviour.
comment:6 Changed 12 years ago by frank
- Version changed from VirtualBox 3.0.8 to VirtualBox 3.2.8
Sure but the experience shows that changing such behavior is appreciated by some users and heavily disliked by others. Though we will change this behavior in the next major release as this is the standard behavior on other hosts (Linux, Mac OS X) as well.
This behaviour also occurs for Linux guests running under a Windows 7 host with 3.1.2.
Only some focus changes halt the VM sound, though: games, foobar2000, Steam. As soon as the offending application is shut, the VM sound returns without further action needed.