修改判断Music是否正在播放的逻辑

This commit is contained in:
Nomango 2018-07-03 21:48:56 +08:00
parent a85026e02d
commit 59dd575e5b
3 changed files with 3 additions and 10 deletions

View File

@ -21,6 +21,7 @@ void e2d::VoiceCallback::OnLoopEnd(void * pBufferContext)
void e2d::VoiceCallback::OnStreamEnd()
{
_music->_playing = false;
if (_streamEndFunc)
{
_streamEndFunc();

View File

@ -268,7 +268,6 @@ bool e2d::Music::play(int nLoopCount)
if (SUCCEEDED(hr = _voice->Start(0)))
{
// 播放成功,保留这个对象
_playing = true;
}
@ -338,13 +337,6 @@ bool e2d::Music::isPlaying() const
{
if (_opened && _voice)
{
XAUDIO2_VOICE_STATE state;
_voice->GetState(&state);
if (state.BuffersQueued == 0)
{
_playing = false;
}
return _playing;
}
else

View File

@ -52,7 +52,7 @@ private:
class Music :
public Object
{
friend class Game;
friend class VoiceCallback;
public:
Music();
@ -135,7 +135,7 @@ protected:
protected:
bool _opened;
mutable bool _playing;
bool _playing;
DWORD _dwSize;
CHAR* _resBuffer;
BYTE* _waveData;