Sign in to follow this  

XAudio2 fails, please help!

Recommended Posts

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; 
	if(FAILED(hr = m_IXAudio2->CreateSourceVoice(&m_SourceSound, &m_WaveFormFormat)))
		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]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this