Hello Julian.
Please, consider the following information and make the following changes to your code.
- Please, avoid an obsolete code and change the cooperative level of an output buffer from DSSCL_EXCLUSIVE (3) to DSSCL_PRIORITY (2). That’s because Microsoft does not support the DSSCL_EXCLUSVE cooperative level any more. Consider the following note from MSDN:
Note The DSSCL_EXCLUSIVE cooperative level is obsolete. It is no longer possible for a DirectX application to mute other applications. Applications that request the exclusive level are granted the priority level instead.
- Please, insert the following code to the ‘DSoundInternalOutChannel::service’ function (possibly to other functions too) to avoid sound glitches when another sound application tries to gain the priority level. I’ve tested it and it solved my problem at last:
...
if (bytesEmpty >= bytesPerBuffer)
{
LPBYTE lpbuf1 = 0;
LPBYTE lpbuf2 = 0;
DWORD dwSize1 = 0;
DWORD dwSize2 = 0;
HRESULT hr = pOutputBuffer->Lock (writeOffset,
bytesPerBuffer,
(void**) &lpbuf1, &dwSize1,
(void**) &lpbuf2, &dwSize2, 0);
/////////////////////////////////////////////////// this code restores the lost buffer
if (hr == MAKE_HRESULT(1, 0x878, 150)) ///// DSERR_BUFFERLOST == MAKE_HRESULT(1, 0x878, 150)
{
pOutputBuffer->Restore();
hr = pOutputBuffer->Lock (writeOffset,
bytesPerBuffer,
(void**) &lpbuf1, &dwSize1,
(void**) &lpbuf2, &dwSize2, 0);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
if (hr == S_OK)
{
if (bitDepth == 16)
{
const float gainL = 32767.0f;
const float gainR = 32767.0f;
...
P.S. Please, add ‘fadeInComponent’ code provided by kraken 2 years ago to JUCE at last. It is a matter of 2 minutes to accomplish. The code is 100% functional.
and
you can change the Windows code like this:
#ifndef JUCE_GCC //xxx should add this fn for gcc..
_fpreset(); // because some graphics cards can unmask FP exceptions
#endif
to the direct function call because MinGW (GCC) supports the _fpreset() function.