﻿id	summary	reporter	owner	description	type	status	component	version	resolution	keywords	cc	guest	host
13418	No sound output in guest due to bug in dsoundaudio.c	bogdan		"Windows XP SP3 guest, Windows 7 Ultimate 64-bit host

Depending on the particular combination of windows open on the host when the guest is started, there may be no sound output from the guest. This seems to happen because the DirectSound host audio driver fails to initialize.

VBox.log contains the following lines:
{{{
 Audio: Trying driver 'dsound'.
 DSound: Could not set cooperative level for window 0000000000000000
 Audio: Initialization of driver 'dsound' failed, trying 'dsound'.
 DSound: Could not set cooperative level for window 0000000000000000
 Audio: Initialization of driver 'dsound' failed, trying 'null'.
}}}

The problem seems to be caused by the following initialization code in {{{dsoundaudio.c}}}:
{{{
static int dsound_open (dsound *s)
{
    int err;
    HRESULT hr;
    WAVEFORMATEX wfx;
    DSBUFFERDESC dsbd;
    HWND hwnd;

    hwnd = GetForegroundWindow ();
    hr = IDirectSound_SetCooperativeLevel (
        s->dsound,
        hwnd,
        DSSCL_PRIORITY
        );
}}}

The {{{GetForegroundWindow()}}} call doesn't look like a good idea, as it will return whatever window happens to be in the foreground at the time. The subsequent call to {{{IDirectSound_SetCooperativeLevel()}}} may succeed or not, but even when it does, it may modify a window created by another process. 

This issue has been brought to light by another problem related to the VM window not being started in the foreground - see Ticket #[ticket:13417]."	defect	closed	audio	VirtualBox 4.3.16	fixed	sound		Windows	Windows
