Skip to content

Commit

Permalink
Merge pull request cocos2d#14414 from WenhaiLin/v3-win32-audiofix
Browse files Browse the repository at this point in the history
AudioEngine[WIN32]:Fixed `FinishCallback` may not been invoked when the sound play completes.
  • Loading branch information
zilongshanren committed Nov 24, 2015
2 parents 2c87211 + 42fa33d commit 3cc3325
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 3cc3325

Please sign in to comment.