修改判断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() void e2d::VoiceCallback::OnStreamEnd()
{ {
_music->_playing = false;
if (_streamEndFunc) if (_streamEndFunc)
{ {
_streamEndFunc(); _streamEndFunc();

View File

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

View File

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