Hey,
So we use SlimDX to provide audio playback capability for our product and are currently exploring an issue a customer is reporting. While playing around with XAudio2, we discovered an issue where, after disposing of the XAudio2 device, we would get an InvalidOperationException (handle is not initialized) in EngineCallbackShim::OnProcessingPassStart.
Since this happens after Dispose has been called on the SlimDX XAudio2 object, the object m_WrappedInterface (in EngineCallbackShim::OnProcessingPassStart) is no longer valid.
I did a bunch of digging around and believe I have discovered a fix. I've changed XAudio2's destructor code to...
XAudio2::~XAudio2()
{
if (callback != NULL)
{
IXAudio2* pointer = static_cast<IXAudio2*>(this->UnknownPointer);
if (pointer != NULL)
{
pointer->UnregisterForCallbacks(callback);
}
delete callback;
callback = NULL;
}
}
By calling UnregisterForCallbacks, it doesn't appear that the issue happens. I will run this over the weekend, and probably a few more times on Monday, to confirm, but I'm thinking this might resolve the issue.
Having said that, I've noticed that at SlimDX.org, the last release is the release I took when I first developed the audio engine... January 2012. Are the devs still active? Is there a way to confirm this functionality with the devs and perhaps have this included in an official build? We are able to build our own SlimDX binaries, but we would prefer to continue to use something official :)
Anyway, if anybody has any info, that would be awesome!
Thanks,
Gary