8
\$\begingroup\$

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:

vupgraderacer.wav SlimDX.DirectSound.DirectSoundException:

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.

\$\endgroup\$
2
  • 3
    \$\begingroup\$ 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. \$\endgroup\$
    – House
    Dec 20, 2013 at 16:16
  • 1
    \$\begingroup\$ What's the result of SetCooperativeLevel()? It returns a HRESULT so any value other than DS_OK may indicate a problem. \$\endgroup\$ Dec 24, 2013 at 11:02

1 Answer 1

1
\$\begingroup\$

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."

Docs: http://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.idirectsound8.idirectsound8.setcooperativelevel%28v=vs.85%29.aspx

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .