XAudio2 fails, please help!

Started by
-1 comments, last by VanillaSnake21 15 years, 9 months ago
Hi, I ran into a very frustrating error recently. My app crashes right after I make a call to "CreateSourceVoice(...)". This is some of my code:


	m_WaveFormFormat.wFormatTag = m_Wave->GetFormatTag(); 
	m_WaveFormFormat.nChannels = m_Wave->GetChannels();
	m_WaveFormFormat.nSamplesPerSec = m_Wave->GetSampleRate();
	m_WaveFormFormat.nAvgBytesPerSec = m_Wave->GetBytesPerSec();
	m_WaveFormFormat.nBlockAlign = m_Wave->GetBlockAlign();
	m_WaveFormFormat.wBitsPerSample = m_Wave->GetBitsPerSapmple();
	m_WaveFormFormat.cbSize = 0; 
	
	HRESULT hr;
	if(FAILED(hr = m_IXAudio2->CreateSourceVoice(&m_SourceSound, &m_WaveFormFormat)))
	{
		switch(hr)
		{
		case XAUDIO2_E_INVALID_CALL: MessageBox(NULL, "1", 0, 0); break;
		case XAUDIO2_E_XMA_DECODER_ERROR: MessageBox(NULL, "2", 0, 0); break;
		case XAUDIO2_E_XAPO_CREATION_FAILED: MessageBox(NULL, "3", 0, 0); break;
		case XAUDIO2_E_DEVICE_INVALIDATED: MessageBox(NULL, "4", 0, 0); break;
		case S_OK: MessageBox(NULL, "6", 0, 0); break;
		default: MessageBox(NULL, "5", 0, 0);
		}
			DWORD Error = GetLastError();
		delete pbWaveData;
		pbWaveData = NULL;
		return 0;
	}

The weird thing is, is that the HRESULT comes back with something like -20600000 and I have no idea what's causing it. Please help, I tried everything but nothing works [sad]

You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts

This topic is closed to new replies.

Advertisement