This is probably the worst kind of question one could ask but I am a kind of stuck. I am experimenting with XAudio2 in an attempt to understand the API as I need to integrate some Steam Voice chat code into our game. It is just a simple application that loads and plays some sounds.
The application creates two XAudio2 objects and then loads 2 and "attaches" two sounds to the first one and two to the second one. Dll sounds are played in a loop "simultaneously", sometimes some sounds are "missing" and half of the time on creating the second Source Voice the app crashes.
IXAudio2SourceVoice* XAudio2Engine::GetSourceVoice(WAVEFORMATEX const* format) { assert(nullptr != m_XAudio2Engine); IXAudio2SourceVoice* sourceVoice = nullptr; auto hresult = m_XAudio2Engine->CreateSourceVoice(&sourceVoice, format); if (FAILED(hresult)) { return nullptr; } m_SourceVoices.push_back(sourceVoice); return sourceVoice; }
WAVEFORMATEX appears to be intact all the time.
Here is a copy of the call stack. Do you see any clues what might be wrong?
msvcrt.dll!memcpy() Unknown XAudio2_9.dll!XAudio2WaveHelp::AllocateWaveFormatCopy(struct tWAVEFORMATEX const *) Unknown XAudio2_9.dll!LEAPCORE::CSWVoice::Initialize(struct tWAVEFORMATEX const *,struct IUnknown *,struct IUnknown *,__int64) Unknown XAudio2_9.dll!LEAPCORE::CLeapSystem::CreateVoice(struct tWAVEFORMATEX const *,unsigned int,struct IUnknown *,struct IUnknown *,struct ILeapFilter *,__int64,struct ILeapVoiceCallback *,unsigned int,struct ILeapVoice * *) Unknown XAudio2_9.dll!XAUDIO2::CX2SourceVoice::Initialize(unsigned int,float,struct tWAVEFORMATEX const *,struct XAUDIO2_VOICE_SENDS const *,struct XAUDIO2_EFFECT_CHAIN const *) Unknown XAudio2_9.dll!XAUDIO2::CX2Engine::CreateSourceVoice(struct IXAudio2SourceVoice * *,struct tWAVEFORMATEX const *,unsigned int,float,struct IXAudio2VoiceCallback *,struct XAUDIO2_VOICE_SENDS const *,struct XAUDIO2_EFFECT_CHAIN const *) Unknown > XAudio2_DualEngine.exe!XAudio2Engine::GetSourceVoice(const tWAVEFORMATEX * format) Line 140 C++ XAudio2_DualEngine.exe!PcmSound::Attach(XAudio2Engine & xAudio2Engine) Line 192 C++ XAudio2_DualEngine.exe!main(int args, char * * argc) Line 42 C++
I can post a link to the source code but I doubt anyone would be interested.
EDIT: I created a new simpler test sample. I just load the wave file, create, submit and play the sound then I just "chained" several sounds and there is no crash whatsoever. So the crash might be my fault after all.
EDIT: I created a new simpler test sample. I just load the wave file, create, submit and play the sound then I just "chained" several sounds and there is no crash whatsoever. So the crash might be my fault after all.