summaryrefslogtreecommitdiff
path: root/src/drumgizmo.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2013-03-22 22:42:05 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2013-03-22 22:42:05 +0100
commit47e1f28f1fe9fecf969d63f059b8ec8c0184605e (patch)
tree47ac2c6a2256b75601fa7077c994cdbfbeadc62a /src/drumgizmo.cc
parent70cc80a11a44c73c3cf548c7cedf2a520a025fb6 (diff)
Added Engine->Messageing system. Implemented LoadStatus Message. Added ProgressBar widget. Made FileBrowser chdir to old value (needs further fixing). More printf->hugin ports.
Diffstat (limited to 'src/drumgizmo.cc')
-rw-r--r--src/drumgizmo.cc23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc
index 93426de..e8ced6a 100644
--- a/src/drumgizmo.cc
+++ b/src/drumgizmo.cc
@@ -39,7 +39,7 @@
#include "drumkitparser.h"
DrumGizmo::DrumGizmo(AudioOutputEngine *o, AudioInputEngine *i)
- : oe(o), ie(i)
+ : loader(this), oe(o), ie(i)
{
loader.run(); // Start drumkit loader thread.
}
@@ -57,13 +57,12 @@ DrumGizmo::~DrumGizmo()
}
/*
- * Send a message to the engine. The engine takes over the memory.
+ * Add a message to the GUI message queue.
*/
void DrumGizmo::sendMessage(Message *msg)
{
- message_mutex.lock();
+ MutexAutolock l(message_mutex);
message_queue.push_back(msg);
- message_mutex.unlock();
}
/*
@@ -71,13 +70,25 @@ void DrumGizmo::sendMessage(Message *msg)
*/
Message *DrumGizmo::receiveMessage()
{
+ MutexAutolock l(message_mutex);
Message *msg = NULL;
- message_mutex.lock();
if(message_queue.size()) {
msg = message_queue.front();
message_queue.pop_front();
}
- message_mutex.unlock();
+ return msg;
+}
+
+/*
+ * Receive message from the engine without removing it from the queue.
+ */
+Message *DrumGizmo::peekMessage()
+{
+ MutexAutolock l(message_mutex);
+ Message *msg = NULL;
+ if(message_queue.size()) {
+ msg = message_queue.front();
+ }
return msg;
}