little hack for playing less sounds in frontend
authorkoda
Wed, 18 Jan 2012 01:10:35 +0100
changeset 6585 6225b838a630
parent 6584 5bb48450b978
child 6586 51d5dd5464aa
little hack for playing less sounds in frontend
QTfrontend/util/SDLInteraction.cpp
QTfrontend/util/SDLInteraction.h
--- a/QTfrontend/util/SDLInteraction.cpp	Wed Jan 18 01:07:07 2012 +0100
+++ b/QTfrontend/util/SDLInteraction.cpp	Wed Jan 18 01:10:35 2012 +0100
@@ -193,10 +193,11 @@
     if (!m_soundMap->contains(soundFile))
         m_soundMap->insert(soundFile, Mix_LoadWAV(soundFile.toLocal8Bit().constData()));
 
-    Mix_PlayChannel(-1, m_soundMap->value(soundFile), 0);
+    //FIXME: this is a hack, but works as long as we have few concurrent playing sounds
+    if (Mix_Playing(lastchannel) == false)
+        lastchannel = Mix_PlayChannel(-1, m_soundMap->value(soundFile), 0);
 }
 
-
 void SDLInteraction::setMusicTrack(const QString & musicFile)
 {
     bool wasPlayingMusic = m_isPlayingMusic;
--- a/QTfrontend/util/SDLInteraction.h	Wed Jan 18 01:07:07 2012 +0100
+++ b/QTfrontend/util/SDLInteraction.h	Wed Jan 18 01:10:35 2012 +0100
@@ -59,6 +59,8 @@
 
     QMap<QString,Mix_Chunk*> * m_soundMap; ///< maps sound file paths to channels
 
+    int lastchannel; ///< channel of the last music played
+
 public:
     /**
      * @brief Returns reference to the <i>singleton</i> instance of this class.