Prevent flooding of terminal with "music not playing" messages, added

debug error check.
This commit is contained in:
hiker 2015-02-12 07:57:25 +11:00
parent 2ba46cff9e
commit 33f87e28f7

View File

@ -45,7 +45,7 @@ MusicOggStream::MusicOggStream()
MusicOggStream::~MusicOggStream() MusicOggStream::~MusicOggStream()
{ {
if(stopMusic() == false) if(stopMusic() == false)
Log::warn("MusicOgg", "problems while stopping music.\n"); Log::warn("MusicOgg", "problems while stopping music.");
} // ~MusicOggStream } // ~MusicOggStream
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -307,13 +307,19 @@ void MusicOggStream::update()
if (active) if (active)
{ {
// For debugging
SFXManager::checkError("before source state");
// we have data, so we should be playing... // we have data, so we should be playing...
ALenum state; ALenum state;
alGetSourcei(m_soundSource, AL_SOURCE_STATE, &state); alGetSourcei(m_soundSource, AL_SOURCE_STATE, &state);
if (state != AL_PLAYING) if (state != AL_PLAYING)
{ {
Log::warn("MusicOgg", "Music not playing when it should be. " // Prevent flooding
"Source state: %d\n", state); static int count = 0;
count++;
if (count<10)
Log::warn("MusicOgg", "Music not playing when it should be. "
"Source state: %d", state);
alGetSourcei(m_soundSource, AL_BUFFERS_PROCESSED, &processed); alGetSourcei(m_soundSource, AL_BUFFERS_PROCESSED, &processed);
alSourcePlay(m_soundSource); alSourcePlay(m_soundSource);
} }
@ -321,7 +327,7 @@ void MusicOggStream::update()
else else
{ {
Log::warn("MusicOgg", "Attempt to stream music into buffer failed " Log::warn("MusicOgg", "Attempt to stream music into buffer failed "
"twice in a row.\n"); "twice in a row.");
} }
} // update } // update