Is deleting memory from IXAudio2SourceVoice possible?

Started by
3 comments, last by savail 12 years, 9 months ago
Hey,
So I have an array of IXAudio2SourceVoice: IXAudioSourceVoice * pSourceVoice[100]; and I'm loading sounds into it every one key push. When I push another key I would like to delete whole memory from this array so that declared memory in Windows task menager decrease to its state before loading sounds. When I push the first key again I want to be able to load sounds again into same array and after second key push delete whole memory and so on...
I tried deleting the memory by this way, but the declared memory in windows task menager doesn't decrease:
for(int j = 0; j < 100; j++)
{
ZeroMemory(&pSourceVoice[j], sizeof(pSourceVoice[j]));
}

I tried also doing this way, but it seems that after deleting the memory by delete I can't use the same array next time to load sounds:
delete [] pSourceVoice;
Does anyone have idea how to completely remove the declared memory from such array but to be later able to use this array again?
Advertisement
pSourceVoide[j]->DestroyVoice(); will release resources taken by IXAudio2Source object. You can and must call this method on any voice source object you don't need anymore.

You can use delete [] pSourceVoice only if you have allocated pSourceVoice with array form of new operator.
Unfortunately I can't create an array of IXAudio2SourceVoice with new operator. The error occurs: error C2259: 'IXAudio2SourceVoice' : cannot instantiate abstract class
1> due to following members:
1> 'void IXAudio2SourceVoice::GetVoiceDetails(XAUDIO2_VOICE_DETAILS *)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(823) : see declaration of 'IXAudio2SourceVoice::GetVoiceDetails'
1> 'HRESULT IXAudio2SourceVoice::SetOutputVoices(const XAUDIO2_VOICE_SENDS *)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(823) : see declaration of 'IXAudio2SourceVoice::SetOutputVoices'
1> 'HRESULT IXAudio2SourceVoice::SetEffectChain(const XAUDIO2_EFFECT_CHAIN *)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(823) : see declaration of 'IXAudio2SourceVoice::SetEffectChain'
1> 'HRESULT IXAudio2SourceVoice::EnableEffect(UINT32,UINT32)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(823) : see declaration of 'IXAudio2SourceVoice::EnableEffect'
1> 'HRESULT IXAudio2SourceVoice::DisableEffect(UINT32,UINT32)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(823) : see declaration of 'IXAudio2SourceVoice::DisableEffect'
1> 'void IXAudio2SourceVoice::GetEffectState(UINT32,BOOL *)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(823) : see declaration of 'IXAudio2SourceVoice::GetEffectState'
1> 'HRESULT IXAudio2SourceVoice::SetEffectParameters(UINT32,const void *,UINT32,UINT32)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(823) : see declaration of 'IXAudio2SourceVoice::SetEffectParameters'
1> 'HRESULT IXAudio2SourceVoice::GetEffectParameters(UINT32,void *,UINT32)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(823) : see declaration of 'IXAudio2SourceVoice::GetEffectParameters'
1> 'HRESULT IXAudio2SourceVoice::SetFilterParameters(const XAUDIO2_FILTER_PARAMETERS *,UINT32)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(823) : see declaration of 'IXAudio2SourceVoice::SetFilterParameters'
1> 'void IXAudio2SourceVoice::GetFilterParameters(XAUDIO2_FILTER_PARAMETERS *)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(823) : see declaration of 'IXAudio2SourceVoice::GetFilterParameters'
1> 'HRESULT IXAudio2SourceVoice::SetOutputFilterParameters(IXAudio2Voice *,const XAUDIO2_FILTER_PARAMETERS *,UINT32)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(823) : see declaration of 'IXAudio2SourceVoice::SetOutputFilterParameters'
1> 'void IXAudio2SourceVoice::GetOutputFilterParameters(IXAudio2Voice *,XAUDIO2_FILTER_PARAMETERS *)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(823) : see declaration of 'IXAudio2SourceVoice::GetOutputFilterParameters'
1> 'HRESULT IXAudio2SourceVoice::SetVolume(float,UINT32)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(823) : see declaration of 'IXAudio2SourceVoice::SetVolume'
1> 'void IXAudio2SourceVoice::GetVolume(float *)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(823) : see declaration of 'IXAudio2SourceVoice::GetVolume'
1> 'HRESULT IXAudio2SourceVoice::SetChannelVolumes(UINT32,const float *,UINT32)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(823) : see declaration of 'IXAudio2SourceVoice::SetChannelVolumes'
1> 'void IXAudio2SourceVoice::GetChannelVolumes(UINT32,float *)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(823) : see declaration of 'IXAudio2SourceVoice::GetChannelVolumes'
1> 'HRESULT IXAudio2SourceVoice::SetOutputMatrix(IXAudio2Voice *,UINT32,UINT32,const float *,UINT32)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(823) : see declaration of 'IXAudio2SourceVoice::SetOutputMatrix'
1> 'void IXAudio2SourceVoice::GetOutputMatrix(IXAudio2Voice *,UINT32,UINT32,float *)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(823) : see declaration of 'IXAudio2SourceVoice::GetOutputMatrix'
1> 'void IXAudio2SourceVoice::DestroyVoice(void)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(823) : see declaration of 'IXAudio2SourceVoice::DestroyVoice'
1> 'HRESULT IXAudio2SourceVoice::Start(UINT32,UINT32)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(832) : see declaration of 'IXAudio2SourceVoice::Start'
1> 'HRESULT IXAudio2SourceVoice::Stop(UINT32,UINT32)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(841) : see declaration of 'IXAudio2SourceVoice::Stop'
1> 'HRESULT IXAudio2SourceVoice::SubmitSourceBuffer(const XAUDIO2_BUFFER *,const XAUDIO2_BUFFER_WMA *)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(850) : see declaration of 'IXAudio2SourceVoice::SubmitSourceBuffer'
1> 'HRESULT IXAudio2SourceVoice::FlushSourceBuffers(void)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(855) : see declaration of 'IXAudio2SourceVoice::FlushSourceBuffers'
1> 'HRESULT IXAudio2SourceVoice::Discontinuity(void)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(862) : see declaration of 'IXAudio2SourceVoice::Discontinuity'
1> 'HRESULT IXAudio2SourceVoice::ExitLoop(UINT32)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(870) : see declaration of 'IXAudio2SourceVoice::ExitLoop'
1> 'void IXAudio2SourceVoice::GetState(XAUDIO2_VOICE_STATE *)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(880) : see declaration of 'IXAudio2SourceVoice::GetState'
1> 'HRESULT IXAudio2SourceVoice::SetFrequencyRatio(float,UINT32)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(889) : see declaration of 'IXAudio2SourceVoice::SetFrequencyRatio'
1> 'void IXAudio2SourceVoice::GetFrequencyRatio(float *)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(898) : see declaration of 'IXAudio2SourceVoice::GetFrequencyRatio'
1> 'HRESULT IXAudio2SourceVoice::SetSourceSampleRate(UINT32)' : is abstract
1> C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h(908) : see declaration of 'IXAudio2SourceVoice::SetSourceSampleRate'

Maybe there is any way to eliminate this error? or not rly?
You don't need to create IXAudio2SourceVoice array with new. I just said above that you are not allowed to delete array with delete [] if you have not created with new [].

Just call pSourceVoide[j]->DestroyVoice() on each element you have created from XAudio2 object.
thanks for your reply.I think I just tried to destroy all SourceVoices but the memory declared doesn't decrease even after using DestroyVoice() :/

This topic is closed to new replies.

Advertisement