Commits

Anonymous committed 1f48f06

TagaroAudio bugfix for mute sound after playing 256 times the same sound source

  • Participants
  • Parent commits 387b465

Comments (0)

Files changed (2)

granatier/src/TagaroAudio/openalruntime_p.h

 
 		//Is playback still running?
 		bool isRunning() const;
+		bool replay(const QPointF& pos) const;
 	private:
 		ALuint m_source;
 		bool m_valid;

granatier/src/TagaroAudio/sound.cpp

 
 void Tagaro::Sound::start()
 {
-	if (d->m_valid)
-	{
-		new Tagaro::PlaybackEvent(this, d->m_pos);
-	}
+	start(d->m_pos);
 }
 
 void Tagaro::Sound::start(const QPointF& pos)
 {
 	if (d->m_valid)
 	{
-		new Tagaro::PlaybackEvent(this, pos);
+		Tagaro::OpenALRuntime* runtime = Tagaro::OpenALRuntime::instance();
+		if(runtime->instance()->m_soundsEvents[this].count() > 0)
+		{
+			if(runtime->instance()->m_soundsEvents[this].last()->replay(pos) == false)
+			{
+					new Tagaro::PlaybackEvent(this, pos);
+			}
+		}
+		else
+		{   
+			new Tagaro::PlaybackEvent(this, pos);
+		}
 	}
 }
 
 
 Tagaro::PlaybackEvent::~PlaybackEvent()
 {
-	if (m_valid)
+	if(alIsSource(m_source) == AL_TRUE)
 	{
 		alSourceStop(m_source);
 		alDeleteSources(1, &m_source);
 	return state == AL_PLAYING;
 }
 
+bool Tagaro::PlaybackEvent::replay(const QPointF& pos) const
+{
+	if(alIsSource(m_source) == AL_TRUE)
+	{
+		alSourceStop(m_source);
+		alSourcePlay(m_source);
+	}
+	else
+	{
+		return false;
+	}
+	
+	return true;
+}
+
 //END Tagaro::PlaybackEvent
 
 #include "sound.moc"