diff --git a/apps/examples/tutorial/myjukebox/MyJukebox.cpp b/apps/examples/tutorial/myjukebox/MyJukebox.cpp index 3129f106..143d02ac 100644 --- a/apps/examples/tutorial/myjukebox/MyJukebox.cpp +++ b/apps/examples/tutorial/myjukebox/MyJukebox.cpp @@ -45,6 +45,10 @@ MyJukeboxDialog::~MyJukeboxDialog() { // clean playlist items playlist.close(false); + // clean used AmAudioFile objects + for (vector::iterator it= + used_audio_files.begin(); it != used_audio_files.end();it++) + delete *it; } void MyJukeboxDialog::onSessionStart(const AmSipRequest& req) @@ -67,6 +71,8 @@ void MyJukeboxDialog::onDtmf(int event, int duration) { } 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) diff --git a/apps/examples/tutorial/myjukebox/MyJukebox.h b/apps/examples/tutorial/myjukebox/MyJukebox.h index 0c233e14..ad6e99c2 100644 --- a/apps/examples/tutorial/myjukebox/MyJukebox.h +++ b/apps/examples/tutorial/myjukebox/MyJukebox.h @@ -3,10 +3,14 @@ #include "AmSession.h" #include "AmPlaylist.h" +#include "AmAudioFile.h" #include using std::string; +#include +using std::vector; + class MyJukeboxFactory: public AmSessionFactory { public: @@ -22,6 +26,8 @@ class MyJukeboxDialog : public AmSession { AmPlaylist playlist; + vector used_audio_files; + public: MyJukeboxDialog(); ~MyJukeboxDialog();