diff options
Diffstat (limited to 'src/event.cc')
-rw-r--r-- | src/event.cc | 28 |
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(); } |