Author: sayer
Date: 2009-03-11 02:25:32 +0100 (Wed, 11 Mar 2009)
New Revision: 1304
Modified:
trunk/apps/dsm/DSMDialog.cpp
trunk/apps/dsm/DSMDialog.h
trunk/apps/dsm/DSMSession.h
Log:
more flexibily for modules:
* DSMDisposable + transferOwnership for garbage collection
* addToPlaylist in DSMSession
Modified: trunk/apps/dsm/DSMDialog.cpp
===================================================================
--- trunk/apps/dsm/DSMDialog.cpp 2009-03-10 17:23:03 UTC (rev 1303)
+++ trunk/apps/dsm/DSMDialog.cpp 2009-03-11 01:25:32 UTC (rev 1304)
@@ -43,6 +43,10 @@
DSMDialog::~DSMDialog()
{
+ for (std::set<DSMDisposable*>::iterator it=
+ gc_trash.begin(); it != gc_trash.end(); it++)
+ delete *it;
+
for (vector<AmAudio*>::iterator it=
audiofiles.begin();it!=audiofiles.end();it++)
delete *it;
@@ -196,6 +200,11 @@
playlist.close(notify);
}
+void DSMDialog::addToPlaylist(AmPlaylistItem* item) {
+ DBG("add item to playlist\n");
+ playlist.addToPlaylist(item);
+}
+
void DSMDialog::playFile(const string& name, bool loop) {
AmAudioFile* af = new AmAudioFile();
if(af->open(name,AmAudioFile::Read)) {
@@ -290,3 +299,7 @@
audiofiles.push_back(sep);
SET_ERRNO(DSM_ERRNO_OK);
}
+
+void DSMDialog::transferOwnership(DSMDisposable* d) {
+ gc_trash.insert(d);
+}
Modified: trunk/apps/dsm/DSMDialog.h
===================================================================
--- trunk/apps/dsm/DSMDialog.h 2009-03-10 17:23:03 UTC (rev 1303)
+++ trunk/apps/dsm/DSMDialog.h 2009-03-11 01:25:32 UTC (rev 1304)
@@ -55,6 +55,9 @@
map<string, AmPromptCollection*> prompt_sets;
std::set<AmPromptCollection*> used_prompt_sets;
+ // owned by this instance
+ std::set<DSMDisposable*> gc_trash;
+
bool checkVar(const string& var_name, const string& var_val);
public:
DSMDialog(AmPromptCollection* prompts,
@@ -81,6 +84,7 @@
void playPrompt(const string& name, bool loop = false);
void closePlaylist(bool notify);
+ void addToPlaylist(AmPlaylistItem* item);
void playFile(const string& name, bool loop);
void recordFile(const string& name);
void stopRecord();
@@ -88,6 +92,8 @@
void setPromptSet(const string& name);
void addSeparator(const string& name);
void connectMedia();
+
+ void transferOwnership(DSMDisposable* d);
};
#endif
Modified: trunk/apps/dsm/DSMSession.h
===================================================================
--- trunk/apps/dsm/DSMSession.h 2009-03-10 17:23:03 UTC (rev 1303)
+++ trunk/apps/dsm/DSMSession.h 2009-03-11 01:25:32 UTC (rev 1304)
@@ -53,6 +53,9 @@
#define SET_ERRNO(new_errno) \
var["errno"] = new_errno
+class DSMDisposable;
+class AmPlaylistItem;
+
class DSMSession {
public:
@@ -63,10 +66,15 @@
virtual void playFile(const string& name, bool loop) = 0;
virtual void recordFile(const string& name) = 0;
virtual void stopRecord() = 0;
+ virtual void addToPlaylist(AmPlaylistItem* item) = 0;
virtual void closePlaylist(bool notify) = 0;
virtual void setPromptSet(const string& name) = 0;
virtual void addSeparator(const string& name) = 0;
virtual void connectMedia() = 0;
+
+ /** transfer ownership of object to this session instance */
+ virtual void transferOwnership(DSMDisposable* d) = 0;
+
/* holds variables which are accessed by $varname */
map<string, string> var;
@@ -79,6 +87,12 @@
+class DSMDisposable {
+ public:
+ DSMDisposable() { }
+ virtual ~DSMDisposable() { }
+};
+
#define DSM_EVENT_ID -10
/** generic event for passing events between DSM sessions */
struct DSMEvent : public AmEvent {
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev