Author: sayer
Date: 2009-03-12 13:53:30 +0100 (Thu, 12 Mar 2009)
New Revision: 1313

Modified:
   trunk/apps/examples/tutorial/myjukebox/MyJukebox.cpp
   trunk/apps/examples/tutorial/myjukebox/MyJukebox.h
Log:
fixing memory leak in example

Modified: trunk/apps/examples/tutorial/myjukebox/MyJukebox.cpp
===================================================================
--- trunk/apps/examples/tutorial/myjukebox/MyJukebox.cpp        2009-03-11 
15:50:05 UTC (rev 1312)
+++ trunk/apps/examples/tutorial/myjukebox/MyJukebox.cpp        2009-03-12 
12:53:30 UTC (rev 1313)
@@ -45,6 +45,10 @@
 {
   // clean playlist items
   playlist.close(false);
+  // clean used AmAudioFile objects
+  for (vector<AmAudioFile*>::iterator it=
+        used_audio_files.begin(); it != used_audio_files.end();it++)
+    delete *it;
 }
 
 void MyJukeboxDialog::onSessionStart(const AmSipRequest& req)
@@ -67,6 +71,8 @@
   }
   AmPlaylistItem*  item = new AmPlaylistItem(wav_file, NULL);
   playlist.addToPlaylist(item);
+  // for garbage collection later
+  used_audio_files.push_back(wav_file);
 }
 
 void MyJukeboxDialog::process(AmEvent* ev)

Modified: trunk/apps/examples/tutorial/myjukebox/MyJukebox.h
===================================================================
--- trunk/apps/examples/tutorial/myjukebox/MyJukebox.h  2009-03-11 15:50:05 UTC 
(rev 1312)
+++ trunk/apps/examples/tutorial/myjukebox/MyJukebox.h  2009-03-12 12:53:30 UTC 
(rev 1313)
@@ -3,10 +3,14 @@
 
 #include "AmSession.h"
 #include "AmPlaylist.h"
+#include "AmAudioFile.h"
 
 #include <string>
 using std::string;
 
+#include <vector>
+using std::vector;
+
 class MyJukeboxFactory: public AmSessionFactory
 {
 public:
@@ -22,6 +26,8 @@
 {
     AmPlaylist playlist;
 
+    vector<AmAudioFile*> used_audio_files;
+
  public:
     MyJukeboxDialog();
     ~MyJukeboxDialog();

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to