Fw: SDL issue with DirectSound

At 22:16 28/04/2002 +1000, Travis Howell wrote:>----- Original Message -----

From: “Travis Howell”
To:
Sent: Saturday, April 27, 2002 7:01 PM
Subject: Re: [SDL] SDL issue with DirectSound

From: “Sam Lantinga”

Are there any plans to fix the issue of DirectSound audio through
SDL using a primary
directsound buffer and not a secondary directsound buffer ?

What exactly is the problem? SDL is set up to use the primary sound
buffer

if possible, and if not, fall back to a secondary buffer. Do the Aureal
cards just not generate sound when the primary buffer is used?

I can’t check on the Vortex 2 based sound card anymore since the
problem only occured
under
Windows 9x/ME and I have moved onto Windows XP. Checking the logs at
the time shows the
sound card reported all streams were in use and there was a brief
repeated sound when
Exult
was left in the background.
The only case I can still test out is the one with the SoundMax drivers
on Analog Device
AD1881A chipset, where windows MIDI output only plays if program is in
the background if
SDL audio is been used at the same time (Since it occurs in Windows XP
too).

Out of curiousity, what kind of latency do you see with and without using
the primary sound buffer on those cards?

I notice no difference in sound delay when using waveout myself, but
the two main SDL
programs I use (Exult and scummvm) don’t seem to use that much CPU at
least on this
system.
I will ask Exult developer who worked around the problem to provide
more technical
details
about the problem so I can pass them along to you.

Ok, there were a number of issues with using the primary buffer that we found:

  1. using the primary buffer requires exclusive access to the sound device.
    This causes problems for some midi devices that use a Secondary DirectSound
    buffer when doing software synthesis. They just don’t work.

  2. A lesser problem is it prevents other programs from accessing the sound
    device. This is fairly minor, but some people may want to listen to music,
    or other things using another program and this can’t be done.

  3. Other issues are that when the app looses focus sound output stops. This
    is not too useful for an application that is meant to run in the background.

  4. Also it seems that some sound drivers may be broken and this is causing
    problem where SDL thinks that primary sound buffer creation has succeeded,
    when it actually failed. I myself can’t test this since I don’t have any
    cards that have problems.

  5. In Exult we noticed a problem where using 44 KHz mixing and using SDL
    with DirectSound (Primary) would cause a hang when Exult would quit.

  6. Testing things just now I was unable to get any output when using a 44
    KHz Primary Buffer in WinXP with a SB Live.

In Exult I force SDL to use waveout instead of DirectSound. Doing this as
far as I can tell cleared up all the problems. Also changing SDL to use a
secondary buffer also cleared up the problem.

In my opinion, using the primary buffer should not be the default setting.
It seems to have too many problems. By default a secondary buffer should be
used. I think that there should be an option when developers should be able
to choose to use it IF they need the extra low latency sound mixing. A
suggestion would be to add low latency versions of the SDL_AudioSpec format
types, and attempt to use the primary buffer if one of these was selected.

-Ryan Nunn

At 22:16 28/04/2002 +1000, Travis Howell wrote:

Are there any plans to fix the issue of DirectSound audio through
SDL using a primary
directsound buffer and not a secondary directsound buffer ?

What exactly is the problem? SDL is set up to use the primary sound
buffer

if possible, and if not, fall back to a secondary buffer. Do the Aureal
cards just not generate sound when the primary buffer is used?

I can’t check on the Vortex 2 based sound card anymore since the
problem only occured
under
Windows 9x/ME and I have moved onto Windows XP. Checking the logs at
the time shows the
sound card reported all streams were in use and there was a brief
repeated sound when
Exult
was left in the background.
The only case I can still test out is the one with the SoundMax drivers
on Analog Device
AD1881A chipset, where windows MIDI output only plays if program is in
the background if
SDL audio is been used at the same time (Since it occurs in Windows XP
too).

Out of curiousity, what kind of latency do you see with and without using
the primary sound buffer on those cards?

I notice no difference in sound delay when using waveout myself, but
the two main SDL
programs I use (Exult and scummvm) don’t seem to use that much CPU at
least on this
system.
I will ask Exult developer who worked around the problem to provide
more technical
details
about the problem so I can pass them along to you.

Ok, there were a number of issues with using the primary buffer that we found:

  1. using the primary buffer requires exclusive access to the sound device.
    This causes problems for some midi devices that use a Secondary DirectSound
    buffer when doing software synthesis. They just don’t work.

  2. A lesser problem is it prevents other programs from accessing the sound
    device. This is fairly minor, but some people may want to listen to music,
    or other things using another program and this can’t be done.

  3. Other issues are that when the app looses focus sound output stops. This
    is not too useful for an application that is meant to run in the background.

  4. Also it seems that some sound drivers may be broken and this is causing
    problem where SDL thinks that primary sound buffer creation has succeeded,
    when it actually failed. I myself can’t test this since I don’t have any
    cards that have problems.

  5. In Exult we noticed a problem where using 44 KHz mixing and using SDL
    with DirectSound (Primary) would cause a hang when Exult would quit.

  6. Testing things just now I was unable to get any output when using a 44
    KHz Primary Buffer in WinXP with a SB Live.

In Exult I force SDL to use waveout instead of DirectSound. Doing this as
far as I can tell cleared up all the problems. Also changing SDL to use a
secondary buffer also cleared up the problem.

In my opinion, using the primary buffer should not be the default setting.
It seems to have too many problems. By default a secondary buffer should be
used. I think that there should be an option when developers should be able
to choose to use it IF they need the extra low latency sound mixing. A
suggestion would be to add low latency versions of the SDL_AudioSpec format
types, and attempt to use the primary buffer if one of these was selected.

-Ryan Nunn
From: triforce@merlin.net.au (Ryan Nunn)

----- Original Message -----
From: “Travis Howell”
To:
Sent: Saturday, April 27, 2002 7:01 PM
Subject: Re: [SDL] SDL issue with DirectSound

From: “Sam Lantinga”

In my opinion, using the primary buffer should not be the default setting.
It seems to have too many problems.

Agreed. The code in CVS uses the secondary buffer by default.
Can you try it out and see if it fixes the issues that you’ve seen?

Thanks,
-Sam Lantinga, Software Engineer, Blizzard Entertainment