update VoiceCallback
This commit is contained in:
parent
cc2dff2afd
commit
c40ac00ed9
|
|
@ -2,8 +2,7 @@
|
||||||
#include "..\e2dbase.h"
|
#include "..\e2dbase.h"
|
||||||
#include "..\e2dtool.h"
|
#include "..\e2dtool.h"
|
||||||
|
|
||||||
e2d::VoiceCallback::VoiceCallback(Music * music)
|
e2d::VoiceCallback::VoiceCallback()
|
||||||
: _music(music)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -21,11 +20,6 @@ void e2d::VoiceCallback::OnLoopEnd(void * pBufferContext)
|
||||||
|
|
||||||
void e2d::VoiceCallback::OnStreamEnd()
|
void e2d::VoiceCallback::OnStreamEnd()
|
||||||
{
|
{
|
||||||
if (_music)
|
|
||||||
{
|
|
||||||
_music->_playing = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_streamEndFunc)
|
if (_streamEndFunc)
|
||||||
{
|
{
|
||||||
_streamEndFunc();
|
_streamEndFunc();
|
||||||
|
|
@ -38,31 +32,6 @@ void e2d::VoiceCallback::OnBufferEnd(void * pBufferContext)
|
||||||
{
|
{
|
||||||
_loopEndFunc();
|
_loopEndFunc();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_music)
|
|
||||||
{
|
|
||||||
_music->release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void e2d::VoiceCallback::OnBufferStart(void * pBufferContext)
|
|
||||||
{
|
|
||||||
if (_music)
|
|
||||||
{
|
|
||||||
_music->retain();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void e2d::VoiceCallback::OnVoiceProcessingPassEnd()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void e2d::VoiceCallback::OnVoiceProcessingPassStart(UINT32 SamplesRequired)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void e2d::VoiceCallback::OnVoiceError(void * pBufferContext, HRESULT Error)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::VoiceCallback::SetFuncOnStreamEnd(const Function & func)
|
void e2d::VoiceCallback::SetFuncOnStreamEnd(const Function & func)
|
||||||
|
|
@ -73,4 +42,4 @@ void e2d::VoiceCallback::SetFuncOnStreamEnd(const Function & func)
|
||||||
void e2d::VoiceCallback::SetFuncOnLoopEnd(const Function & func)
|
void e2d::VoiceCallback::SetFuncOnLoopEnd(const Function & func)
|
||||||
{
|
{
|
||||||
_loopEndFunc = func;
|
_loopEndFunc = func;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ e2d::Music::Music()
|
||||||
, _waveData(nullptr)
|
, _waveData(nullptr)
|
||||||
, _dwSize(0)
|
, _dwSize(0)
|
||||||
, _voice(nullptr)
|
, _voice(nullptr)
|
||||||
, _voiceCallback(this)
|
, _voiceCallback()
|
||||||
{
|
{
|
||||||
auto xAudio2 = XAudio2Tool::getInstance()->getXAudio2();
|
auto xAudio2 = XAudio2Tool::getInstance()->getXAudio2();
|
||||||
xAudio2->AddRef();
|
xAudio2->AddRef();
|
||||||
|
|
@ -84,7 +84,7 @@ e2d::Music::Music(const e2d::String & filePath)
|
||||||
, _waveData(nullptr)
|
, _waveData(nullptr)
|
||||||
, _dwSize(0)
|
, _dwSize(0)
|
||||||
, _voice(nullptr)
|
, _voice(nullptr)
|
||||||
, _voiceCallback(this)
|
, _voiceCallback()
|
||||||
{
|
{
|
||||||
auto xAudio2 = XAudio2Tool::getInstance()->getXAudio2();
|
auto xAudio2 = XAudio2Tool::getInstance()->getXAudio2();
|
||||||
xAudio2->AddRef();
|
xAudio2->AddRef();
|
||||||
|
|
@ -101,7 +101,7 @@ e2d::Music::Music(const Resource& res)
|
||||||
, _waveData(nullptr)
|
, _waveData(nullptr)
|
||||||
, _dwSize(0)
|
, _dwSize(0)
|
||||||
, _voice(nullptr)
|
, _voice(nullptr)
|
||||||
, _voiceCallback(this)
|
, _voiceCallback()
|
||||||
{
|
{
|
||||||
auto xAudio2 = XAudio2Tool::getInstance()->getXAudio2();
|
auto xAudio2 = XAudio2Tool::getInstance()->getXAudio2();
|
||||||
xAudio2->AddRef();
|
xAudio2->AddRef();
|
||||||
|
|
|
||||||
|
|
@ -13,36 +13,23 @@ class VoiceCallback
|
||||||
: public IXAudio2VoiceCallback
|
: public IXAudio2VoiceCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit VoiceCallback(
|
VoiceCallback();
|
||||||
Music * music
|
|
||||||
);
|
|
||||||
|
|
||||||
~VoiceCallback();
|
~VoiceCallback();
|
||||||
|
|
||||||
void __stdcall OnStreamEnd();
|
STDMETHOD_(void, OnVoiceProcessingPassStart) (THIS_ UINT32 BytesRequired) {}
|
||||||
|
|
||||||
void __stdcall OnBufferEnd(
|
STDMETHOD_(void, OnVoiceProcessingPassEnd) (THIS) {}
|
||||||
void * pBufferContext
|
|
||||||
);
|
|
||||||
|
|
||||||
void __stdcall OnBufferStart(
|
STDMETHOD_(void, OnStreamEnd) (THIS);
|
||||||
void * pBufferContext
|
|
||||||
);
|
|
||||||
|
|
||||||
void __stdcall OnLoopEnd(
|
STDMETHOD_(void, OnBufferStart) (THIS_ void* pBufferContext) {}
|
||||||
void * pBufferContext
|
|
||||||
);
|
|
||||||
|
|
||||||
void __stdcall OnVoiceProcessingPassEnd();
|
STDMETHOD_(void, OnBufferEnd) (THIS_ void* pBufferContext);
|
||||||
|
|
||||||
void __stdcall OnVoiceProcessingPassStart(
|
STDMETHOD_(void, OnLoopEnd) (THIS_ void* pBufferContext);
|
||||||
UINT32 SamplesRequired
|
|
||||||
);
|
|
||||||
|
|
||||||
void __stdcall OnVoiceError(
|
STDMETHOD_(void, OnVoiceError) (THIS_ void* pBufferContext, HRESULT Error) {}
|
||||||
void * pBufferContext,
|
|
||||||
HRESULT Error
|
|
||||||
);
|
|
||||||
|
|
||||||
void SetFuncOnStreamEnd(
|
void SetFuncOnStreamEnd(
|
||||||
const Function& func
|
const Function& func
|
||||||
|
|
@ -53,7 +40,6 @@ public:
|
||||||
);
|
);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Music * _music;
|
|
||||||
Function _loopEndFunc;
|
Function _loopEndFunc;
|
||||||
Function _streamEndFunc;
|
Function _streamEndFunc;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue