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:
parent
041c528a9f
commit
b2ce57c840
@ -36,8 +36,9 @@ MusicOggStream::MusicOggStream()
|
|||||||
{
|
{
|
||||||
//m_oggStream= NULL;
|
//m_oggStream= NULL;
|
||||||
m_soundBuffers[0] = m_soundBuffers[1]= 0;
|
m_soundBuffers[0] = m_soundBuffers[1]= 0;
|
||||||
m_soundSource= -1;
|
m_soundSource = -1;
|
||||||
m_pausedMusic= true;
|
m_pausedMusic = true;
|
||||||
|
m_playing = false;
|
||||||
} // MusicOggStream
|
} // MusicOggStream
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -136,6 +137,7 @@ bool MusicOggStream::release()
|
|||||||
if(!m_error) ov_clear(&m_oggStream);
|
if(!m_error) ov_clear(&m_oggStream);
|
||||||
|
|
||||||
m_soundSource = -1;
|
m_soundSource = -1;
|
||||||
|
m_playing = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} // release
|
} // release
|
||||||
@ -155,7 +157,8 @@ bool MusicOggStream::playMusic()
|
|||||||
alSourceQueueBuffers(m_soundSource, 2, m_soundBuffers);
|
alSourceQueueBuffers(m_soundSource, 2, m_soundBuffers);
|
||||||
|
|
||||||
alSourcePlay(m_soundSource);
|
alSourcePlay(m_soundSource);
|
||||||
m_pausedMusic= false;
|
m_pausedMusic = false;
|
||||||
|
m_playing = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} // playMusic
|
} // playMusic
|
||||||
@ -163,23 +166,29 @@ bool MusicOggStream::playMusic()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool MusicOggStream::isPlaying()
|
bool MusicOggStream::isPlaying()
|
||||||
{
|
{
|
||||||
|
return m_playing;
|
||||||
|
|
||||||
|
/*
|
||||||
if (m_soundSource == -1) return false;
|
if (m_soundSource == -1) return false;
|
||||||
|
|
||||||
ALenum state;
|
ALenum state;
|
||||||
alGetSourcei(m_soundSource, AL_SOURCE_STATE, &state);
|
alGetSourcei(m_soundSource, AL_SOURCE_STATE, &state);
|
||||||
|
|
||||||
return (state == AL_PLAYING);
|
return (state == AL_PLAYING);
|
||||||
|
*/
|
||||||
} // isPlaying
|
} // isPlaying
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool MusicOggStream::stopMusic()
|
bool MusicOggStream::stopMusic()
|
||||||
{
|
{
|
||||||
|
m_playing = false;
|
||||||
return (release());
|
return (release());
|
||||||
} // stopMusic
|
} // stopMusic
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool MusicOggStream::pauseMusic()
|
bool MusicOggStream::pauseMusic()
|
||||||
{
|
{
|
||||||
|
m_playing = false;
|
||||||
if (m_fileName == "")
|
if (m_fileName == "")
|
||||||
{
|
{
|
||||||
// nothing is loaded
|
// nothing is loaded
|
||||||
@ -194,6 +203,8 @@ bool MusicOggStream::pauseMusic()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool MusicOggStream::resumeMusic()
|
bool MusicOggStream::resumeMusic()
|
||||||
{
|
{
|
||||||
|
m_playing = true;
|
||||||
|
|
||||||
if (m_fileName == "")
|
if (m_fileName == "")
|
||||||
{
|
{
|
||||||
// nothing is loaded
|
// nothing is loaded
|
||||||
|
@ -77,6 +77,8 @@ private:
|
|||||||
vorbis_info* m_vorbisInfo;
|
vorbis_info* m_vorbisInfo;
|
||||||
bool m_error;
|
bool m_error;
|
||||||
|
|
||||||
|
bool m_playing;
|
||||||
|
|
||||||
ALuint m_soundBuffers[2];
|
ALuint m_soundBuffers[2];
|
||||||
ALuint m_soundSource;
|
ALuint m_soundSource;
|
||||||
ALenum nb_channels;
|
ALenum nb_channels;
|
||||||
|
Loading…
Reference in New Issue
Block a user