summaryrefslogtreecommitdiff
path: root/src/drumkitloader.h
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2013-10-06 13:10:00 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2013-10-06 13:10:00 +0200
commit88a906395ba7d33ae563e70d8b94c855e3b5a573 (patch)
treeb0fa632b4c59d276b292407f79ee07aa9ef8dab8 /src/drumkitloader.h
parent5727436afe5a8b1b60d99863cfc939ee50d4c17e (diff)
Refactoring of AudioFile loading and message passing from engine to gui and vice versa.
Diffstat (limited to 'src/drumkitloader.h')
-rw-r--r--src/drumkitloader.h51
1 files changed, 38 insertions, 13 deletions
diff --git a/src/drumkitloader.h b/src/drumkitloader.h
index 9d14638..be24812 100644
--- a/src/drumkitloader.h
+++ b/src/drumkitloader.h
@@ -36,37 +36,62 @@
#include "drumkit.h"
-class DrumGizmo;
-
+/**
+ * This class is responsible for loading the drumkits in its own thread.
+ * All interaction calls are simply modifying queues and not doing any
+ * work in-sync with the caller.
+ * This means that if loadKit(...) is called, one cannot assume that the
+ * drumkit has actually been loaded when the call returns.
+ */
class DrumKitLoader : public Thread {
public:
- DrumKitLoader(DrumGizmo *drumgizmo);
+ /**
+ * The constrcutor starts the loader thread.
+ */
+ DrumKitLoader();
+
+ /**
+ * The destructor signals the thread to stop and waits to merge before
+ * returning (ie. deleting the object will garantuee that the thread has
+ * been stopped).
+ */
~DrumKitLoader();
+ /**
+ * Signal the loader to start loading all audio files contained in kit.
+ * All other AudioFiles in queue will be removed before the new ones are
+ * scheduled.
+ */
void loadKit(DrumKit *kit);
- void prepare(AudioFile* af);
- void reset(AudioFile* af);
+ // I have no idea what this does..
+ //void reset(AudioFile* af);
void thread_main();
+ /**
+ * Simply reports if the load queue is empty (i.e. all AudioFiles has been
+ * loaded).
+ */
bool isDone();
+ /**
+ * Signal the loader to stop and wait until it has.
+ */
void stop();
+
+ /**
+ * Skip all queued AudioFiles.
+ */
void skip();
private:
- DrumGizmo *drumgizmo;
Semaphore semaphore;
- Semaphore skip_semaphore;
- DrumKit *kit;
- bool is_done;
Mutex mutex;
- volatile bool quitit;
- volatile bool skipit;
+ volatile bool running;
std::list<AudioFile*> load_queue;
- std::list<AudioFile*> reset_queue;
- std::map<AudioFile*, int> ref_count;
+ size_t total_num_audiofiles;
+ size_t loaded;
};
#endif/*__DRUMGIZMO_DRUMKITLOADER_H__*/