Don't rely on OpenAL to know if a music is playing or not, it will say 'no' when the music is playing but couldn't be updated recently because of lagging

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5516 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-06-13 18:39:07 +00:00
parent 041c528a9f
commit b2ce57c840
2 changed files with 16 additions and 3 deletions

View File

@ -38,6 +38,7 @@ MusicOggStream::MusicOggStream()
m_soundBuffers[0] = m_soundBuffers[1]= 0;
m_soundSource = -1;
m_pausedMusic = true;
m_playing = false;
} // MusicOggStream
//-----------------------------------------------------------------------------
@ -136,6 +137,7 @@ bool MusicOggStream::release()
if(!m_error) ov_clear(&m_oggStream);
m_soundSource = -1;
m_playing = false;
return true;
} // release
@ -156,6 +158,7 @@ bool MusicOggStream::playMusic()
alSourcePlay(m_soundSource);
m_pausedMusic = false;
m_playing = true;
return true;
} // playMusic
@ -163,23 +166,29 @@ bool MusicOggStream::playMusic()
//-----------------------------------------------------------------------------
bool MusicOggStream::isPlaying()
{
return m_playing;
/*
if (m_soundSource == -1) return false;
ALenum state;
alGetSourcei(m_soundSource, AL_SOURCE_STATE, &state);
return (state == AL_PLAYING);
*/
} // isPlaying
//-----------------------------------------------------------------------------
bool MusicOggStream::stopMusic()
{
m_playing = false;
return (release());
} // stopMusic
//-----------------------------------------------------------------------------
bool MusicOggStream::pauseMusic()
{
m_playing = false;
if (m_fileName == "")
{
// nothing is loaded
@ -194,6 +203,8 @@ bool MusicOggStream::pauseMusic()
//-----------------------------------------------------------------------------
bool MusicOggStream::resumeMusic()
{
m_playing = true;
if (m_fileName == "")
{
// nothing is loaded

View File

@ -77,6 +77,8 @@ private:
vorbis_info* m_vorbisInfo;
bool m_error;
bool m_playing;
ALuint m_soundBuffers[2];
ALuint m_soundSource;
ALenum nb_channels;