From 59dd575e5b120fb9ebf7488a6ad9df6ae90ed198 Mon Sep 17 00:00:00 2001 From: Nomango <569629550@qq.com> Date: Tue, 3 Jul 2018 21:48:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=A4=E6=96=ADMusic?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E6=AD=A3=E5=9C=A8=E6=92=AD=E6=94=BE=E7=9A=84?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/Custom/VoiceCallback.cpp | 1 + core/Tool/Music.cpp | 8 -------- core/e2dtool.h | 4 ++-- 3 files changed, 3 insertions(+), 10 deletions(-) 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;