Skip to content

Commit

Permalink
AudioEngine[WIN32]:Fixed FinishCallback may not been invoked when t…
Browse files Browse the repository at this point in the history
…he sound play completes.
  • Loading branch information
WenhaiLin committed Nov 17, 2015
1 parent a0c7e10 commit 42fa33d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cocos/audio/win32/AudioEngine-win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ bool AudioEngineImpl::stop(int audioID)
_alSourceUsed[player._alSource] = false;
if (player._streamingSource)
{
player._ready = false;
player.notifyExitThread();
}
else
Expand All @@ -346,6 +347,7 @@ void AudioEngineImpl::stopAll()
auto& player = it->second;
if (player._streamingSource)
{
player._ready = false;
player.notifyExitThread();
++it;
}
Expand Down Expand Up @@ -457,7 +459,7 @@ void AudioEngineImpl::update(float dt)
auto& player = it->second;
alGetSourcei(player._alSource, AL_SOURCE_STATE, &sourceState);

if (player._readForRemove)
if (player._readForRemove && !player._ready)
{
it = _audioPlayers.erase(it);
}
Expand All @@ -472,6 +474,7 @@ void AudioEngineImpl::update(float dt)

if (player._streamingSource)
{
player._ready = false;
player.notifyExitThread();
++it;
}
Expand Down

0 comments on commit 42fa33d

Please sign in to comment.