more flexibily for modules:

* DSMDisposable + transferOwnership for garbage collection
 * addToPlaylist in DSMSession 



git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1304 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 18 years ago
parent 40dbf92611
commit fc42849791

@ -43,6 +43,10 @@ DSMDialog::DSMDialog(AmPromptCollection* prompts,
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 @@ void DSMDialog::closePlaylist(bool notify) {
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 @@ void DSMDialog::addSeparator(const string& name) {
audiofiles.push_back(sep);
SET_ERRNO(DSM_ERRNO_OK);
}
void DSMDialog::transferOwnership(DSMDisposable* d) {
gc_trash.insert(d);
}

@ -55,6 +55,9 @@ class DSMDialog : public AmSession,
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 @@ public:
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 @@ public:
void setPromptSet(const string& name);
void addSeparator(const string& name);
void connectMedia();
void transferOwnership(DSMDisposable* d);
};
#endif

@ -53,6 +53,9 @@ using std::map;
#define SET_ERRNO(new_errno) \
var["errno"] = new_errno
class DSMDisposable;
class AmPlaylistItem;
class DSMSession {
public:
@ -63,10 +66,15 @@ class DSMSession {
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 DSMSession {
class DSMDisposable {
public:
DSMDisposable() { }
virtual ~DSMDisposable() { }
};
#define DSM_EVENT_ID -10
/** generic event for passing events between DSM sessions */
struct DSMEvent : public AmEvent {

Loading…
Cancel
Save