What reasons might IXAudio2::CreateMasteringVoice return XAUDIO2_E_INVALID_CALL?

Started by
0 comments, last by markypooch 7 years ago

I have written a game that uses XAudio2 (via the SharpDX wrapper for C#). For myself and 99% of my players, everything is working fine. But occasionally I get automated error reports from players which indicate that my call to IXAudio2::CreateMasteringVoice is returning XAUDIO2_E_INVALID_CALL.

Here's my C#/SharpDX code:


Device = new XAudio2(XAudio2Flags.None, ProcessorSpecifier.DefaultProcessor);
Logger.Log("XAudio2 Device NativePointer: " + Device.NativePointer.ToString("X"));
MasteringVoice = new MasteringVoice(Device);

(If you're unfamiliar with SharpDX, the important thing to point out is that SharpDX automatically checks for error codes returned from DX functions and throws an exception if an error is returned. My application then catches that exception at a higher level (not shown) and reports it to me.)

I think it's pretty unlikely that SharpDX is to blame here, because it's a very thin wrapper around the native DirectX APIs and I couldn't find any obvious issues in its source code.

The logging statement above has also verified that the XAudio2 device is being created successfully. (XAudio2Create is returning success and outputting a non-NULL pointer.)

The docs for CreateMasteringVoice mention two reasons why it might return XAUDIO2_E_INVALID_CALL:

XAudio2 only allows one mastering voice to exist at once. If you attempt to create more than one voice, XAUDIO2_E_INVALID_CALL is returned.

and

It is invalid to call CreateMasteringVoice from within a callback (that is, IXAudio2EngineCallback or IXAudio2VoiceCallback). If you call CreateMasteringVoice within a callback, it returns XAUDIO2_E_INVALID_CALL.

I am definitely *not* doing either of these things, and so I'm at a loss as to why it would be returning XAUDIO2_E_INVALID_CALL.

I did find an old thread from someone who has the same issue, but there was no resolution to that. In that thread, someone asks,

Are you sure those machines have the same DirectX version installed?

To which my own answer would be "no". My game's installer should automatically install the required DirectX components, but it's possible that has failed for some of my players, or that they are running the executable without running the installer. Is there any way to verify, within my application itself, that XAudio2 is installed on their machine? (Besides, if XAudio2 wasn't installed, wouldn't creating the XAudio2 device fail before it even gets to creating the mastering voice?)

If anyone has any clues on why this might be happening, or how to debug it, I'd greatly appreciate it. Thanks!

FWIW, I've never gotten an error report from players on Windows 10 computers; only Windows 7, 8, and 8.1. That's the only commonality I could find in the error reports.

Advertisement

Have you verified the sound solutions the end-user is using that the problem reports are coming from? Maybe they're using some crazy dedicated sound card with an iffy driver, or they're rocking an integrated solution that for whatever reason is running a bleeding edge driver.

I'd start there if your unable to turn anything up through the documentation.

This topic is closed to new replies.

Advertisement