Hello,

I was reading sound/jukebox.cpp when I saw there were not any call for 
Mix_FreeChunk()...

I made a patch to erase this problem, but I think jukebox.cpp is really badly 
programmed, and someone might remake this.

Regards,

Progs

Index: jukebox.cpp
===================================================================
--- jukebox.cpp (révision 936)
+++ jukebox.cpp (copie de travail)
@@ -80,6 +80,8 @@
     std::cout << "Opened audio at " << m_config.frequency <<" Hz "<< 
(audio_format&0xFF)
              <<" bit " << std::endl;
   }
+  Mix_ChannelFinished(JukeBox::EndChunk); /* JukeBox::EndChunk() will be 
called when any sound is finished */
+
   m_init = true;

   LoadXML("share");
@@ -235,9 +237,20 @@

   int channel = Mix_PlayChannel(-1, sample, loop);

+  chunks[channel] = sample;
+
   if (channel == -1) {
        MSG_DEBUG("jukebox", "Error: Jukebox::PlaySample: %s", Mix_GetError());
   }
   return channel;
 }

+void JukeBox::EndChunk(int channel)
+{
+       Mix_Chunk* chk = jukebox.chunks[channel];
+
+       if(!chk) return;
+
+       Mix_FreeChunk(chk);
+       jukebox.chunks[channel] = 0;
+}
Index: jukebox.h
===================================================================
--- jukebox.h   (révision 936)
+++ jukebox.h   (copie de travail)
@@ -42,6 +42,8 @@

   std::multimap<std::string, std::string> m_soundsamples;

+  std::map<int, Mix_Chunk*> chunks;
+
   struct s_m_config{
     bool music;
     bool effects;
@@ -53,6 +55,8 @@

   std::set<std::string> m_profiles_loaded;

+  static void EndChunk(int channel);
+
 public:
   JukeBox();
   void Init();

_______________________________________________
Wormux-dev mailing list
[email protected]
https://mail.gna.org/listinfo/wormux-dev

Répondre à