Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix some issues in OpenAL implementation of CocosDenshion for qnx pla…

…tform
  • Loading branch information...
commit 92ec54e3ed9a13f7cd0eaa98e62565cce628ace2 1 parent 886e5db
@moadib moadib authored
Showing with 28 additions and 11 deletions.
  1. +28 −11 CocosDenshion/qnx/SimpleAudioEngine.cpp
View
39 CocosDenshion/qnx/SimpleAudioEngine.cpp
@@ -313,13 +313,19 @@ namespace CocosDenshion
void SimpleAudioEngine::pauseBackgroundMusic()
{
- alSourcePause(s_backgroundSource);
+ ALint state;
+ alGetSourcei(s_backgroundSource, AL_SOURCE_STATE, &state);
+ if (state == AL_PLAYING)
+ alSourcePause(s_backgroundSource);
checkALError("pauseBackgroundMusic");
}
void SimpleAudioEngine::resumeBackgroundMusic()
{
- alSourcePlay(s_backgroundSource);
+ ALint state;
+ alGetSourcei(s_backgroundSource, AL_SOURCE_STATE, &state);
+ if (state == AL_PAUSED)
+ alSourcePlay(s_backgroundSource);
checkALError("resumeBackgroundMusic");
}
@@ -485,36 +491,47 @@ namespace CocosDenshion
void SimpleAudioEngine::pauseEffect(unsigned int nSoundId)
{
- alSourcePause(nSoundId);
+ ALint state;
+ alGetSourcei(nSoundId, AL_SOURCE_STATE, &state);
+ if (state == AL_PLAYING)
+ alSourcePause(nSoundId);
checkALError("pauseEffect");
}
void SimpleAudioEngine::pauseAllEffects()
{
EffectsMap::iterator iter = s_effects.begin();
-
- if (iter != s_effects.end())
+ ALint state;
+ while (iter != s_effects.end())
{
- alSourcePause(iter->second->source);
+ alGetSourcei(iter->second->source, AL_SOURCE_STATE, &state);
+ if (state == AL_PLAYING)
+ alSourcePause(iter->second->source);
checkALError("pauseAllEffects");
+ ++iter;
}
}
void SimpleAudioEngine::resumeEffect(unsigned int nSoundId)
{
- alSourcePlay(nSoundId);
+ ALint state;
+ alGetSourcei(nSoundId, AL_SOURCE_STATE, &state);
+ if (state == AL_PAUSED)
+ alSourcePlay(nSoundId);
checkALError("resumeEffect");
}
void SimpleAudioEngine::resumeAllEffects()
{
EffectsMap::iterator iter = s_effects.begin();
-
- if (iter != s_effects.end())
+ ALint state;
+ while (iter != s_effects.end())
{
+ alGetSourcei(iter->second->source, AL_SOURCE_STATE, &state);
+ if (state == AL_PAUSED)
+ alSourcePlay(iter->second->source);
checkALError("resumeAllEffects");
- alSourcePlay(iter->second->source);
- checkALError("resumeAllEffects");
+ ++iter;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.