summaryrefslogtreecommitdiff
path: root/src/event.cc
diff options
context:
space:
mode:
authordeva <deva>2011-03-01 19:19:02 +0000
committerdeva <deva>2011-03-01 19:19:02 +0000
commite190d38057892b69246391841b234a368bc2b4ad (patch)
tree34f946bc1c3b86997d4cd45e63c433ef07b36486 /src/event.cc
parentc393edc920f8ee126d1bced3500b6bc1ecf86f83 (diff)
MAJOR rewrite of the internals. New input/output 'plugin' system. Still a lot missing.
Diffstat (limited to 'src/event.cc')
-rw-r--r--src/event.cc28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/event.cc b/src/event.cc
index 5a78746..717fa12 100644
--- a/src/event.cc
+++ b/src/event.cc
@@ -2,8 +2,8 @@
/***************************************************************************
* event.cc
*
- * Mon Jul 21 10:56:02 CEST 2008
- * Copyright 2008 Bent Bisballe Nyeng
+ * Sat Sep 18 22:02:16 CEST 2010
+ * Copyright 2010 Bent Bisballe Nyeng
* deva@aasimon.org
****************************************************************************/
@@ -26,21 +26,25 @@
*/
#include "event.h"
-Event::Event(jack_port_t *port, AudioFile *sample, size_t time, size_t duration)
+void EventQueue::post(Event *event, timepos_t time)
{
- this->port = port;
- this->sample = sample;
- sample->load();
- this->time = time;
- this->duration = duration;
+ MutexAutolock lock(mutex);
+ event->offset = time;
+ queue.insert(std::pair<timepos_t, Event*>(time, event));
}
-Event::~Event()
+Event *EventQueue::take(timepos_t time)
{
+ MutexAutolock lock(mutex);
+ std::multimap<timepos_t, Event*>::iterator i = queue.find(time);
+ if(i == queue.end()) return NULL;
+ Event *event = i->second;
+ queue.erase(i);
+ return event;
}
-bool Event::operator<(const Event& event) const
+bool EventQueue::hasEvent(timepos_t time)
{
- if(time == event.time) return this < &event;
- return time < event.time;
+ MutexAutolock lock(mutex);
+ return queue.find(time) != queue.end();
}