# DirectX error with older XP systems

I am a blind programmer, working on an audio game for the blind. I am using SlimDX, and it has been tested on dozens of systems from XP to Win 8.1. My code works on most systems just fine, but I am getting the following error at runtime on a handful of older XP systems:

DSERR_INVALIDCALL: This call is not valid for the current state of this object (-2005401550)

at SlimDX.Result.Throw[T](Object dataKey, Object dataValue)
at SlimDX.Result.Record[T](Int32 hr, Boolean failed, Object dataKey, Object dataValue)
at SlimDX.DirectSound.SecondarySoundBuffer..ctor(DirectSound device, SoundBufferDescription description)
at RR.Sound..ctor(String fileName)


The same error is repeated for each sound it is trying to use. Here is the code I am using to setup the DS device:

dsDevice = New SlimDX.DirectSound.DirectSound

dsDevice.SetCooperativeLevel(OGw.Handle, SlimDX.DirectSound.CooperativeLevel.Normal)

I realize there are other flags that can be set, but this basic setup has worked well thus far, minus the older XP systems. This is my first post, so hope I am entering it properly, if not, please let me know, it is sometimes difficult to tell where you are or should be with a screenreader on forums.

• Welcome to the site! I edited your question a bit to change the formatting. If you do come across any difficulty using the site, please let us know on meta.
– House
Dec 20, 2013 at 16:16
• What's the result of SetCooperativeLevel()? It returns a HRESULT  so any value other than DS_OK may indicate a problem. Dec 24, 2013 at 11:02

You should check the result of SetCooperativeLevel().

According to the documentation of the DirectSound8 version, these are the possible return values:

• DS_OK DSERR_ALLOCATED
• DSERR_INVALIDPARAM
• DSERR_UNINITIALIZED
• DSERR_UNSUPPORTED

Find out which one you get first. Maybe you just forgot to initialize the sound device?

Also, in the remarks section it says: "Do not call this method if any buffers are locked."