diff --git a/core/Custom/VoiceCallback.cpp b/core/Custom/VoiceCallback.cpp index c4eb7da7..7f098683 100644 --- a/core/Custom/VoiceCallback.cpp +++ b/core/Custom/VoiceCallback.cpp @@ -21,6 +21,7 @@ void e2d::VoiceCallback::OnLoopEnd(void * pBufferContext) void e2d::VoiceCallback::OnStreamEnd() { + _music->_playing = false; if (_streamEndFunc) { _streamEndFunc(); diff --git a/core/Tool/Music.cpp b/core/Tool/Music.cpp index b341e62d..781162f7 100644 --- a/core/Tool/Music.cpp +++ b/core/Tool/Music.cpp @@ -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 diff --git a/core/e2dtool.h b/core/e2dtool.h index 6e60f7cd..676d053c 100644 --- a/core/e2dtool.h +++ b/core/e2dtool.h @@ -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;