summaryrefslogtreecommitdiffstats
path: root/src/engine/EventSource.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-01-07 01:34:42 +0000
committerDavid Robillard <d@drobilla.net>2010-01-07 01:34:42 +0000
commit10a5b76a65fb7ca7bf8c1f5869aaf763854e05a3 (patch)
treef93824399e791f218545109304500fe71686f0a3 /src/engine/EventSource.hpp
parenta6045e5dc58f2dd2ab9e3d3d19fd3eaf6d84216f (diff)
downloadingen-10a5b76a65fb7ca7bf8c1f5869aaf763854e05a3.tar.gz
ingen-10a5b76a65fb7ca7bf8c1f5869aaf763854e05a3.tar.bz2
ingen-10a5b76a65fb7ca7bf8c1f5869aaf763854e05a3.zip
Merge QueuedEventSource and EventSource.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2352 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/EventSource.hpp')
-rw-r--r--src/engine/EventSource.hpp46
1 files changed, 32 insertions, 14 deletions
diff --git a/src/engine/EventSource.hpp b/src/engine/EventSource.hpp
index 0db5c879..58d26ea8 100644
--- a/src/engine/EventSource.hpp
+++ b/src/engine/EventSource.hpp
@@ -15,8 +15,12 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef EVENTSOURCE_H
-#define EVENTSOURCE_H
+#ifndef INGEN_EVENT_SOURCE_HPP
+#define INGEN_EVENT_SOURCE_HPP
+
+#include "raul/Semaphore.hpp"
+#include "raul/Slave.hpp"
+#include "raul/List.hpp"
namespace Ingen {
@@ -31,26 +35,40 @@ class ProcessContext;
* The Driver gets events from an EventSource in the process callback
* (realtime audio thread) and executes them, then they are sent to the
* PostProcessor and finalised (post-processing thread).
- *
- * There are two distinct classes of events - "queued" and "stamped". Queued
- * events are events that require non-realtime pre-processing before being
- * executed in the process thread. Stamped events are timestamped realtime
- * events that require no pre-processing and can be executed immediately
- * (with sample accuracy).
*/
-class EventSource
+class EventSource : protected Raul::Slave
{
public:
- virtual ~EventSource() {}
+ EventSource(size_t queue_size);
+ ~EventSource();
+
+ void activate_source() { Slave::start(); }
+ void deactivate_source() { Slave::stop(); }
+
+ void process(PostProcessor& dest, ProcessContext& context);
+
+ /** Signal that a blocking event is finished.
+ *
+ * This MUST be called by blocking events in their post_process() method
+ * to resume pre-processing of events.
+ */
+ inline void unblock() { _blocking_semaphore.post(); }
+
+protected:
+ void push_queued(QueuedEvent* const ev);
+
+ inline bool unprepared_events() { return (_prepared_back.get() != NULL); }
- virtual void activate_source() = 0;
- virtual void deactivate_source() = 0;
+ virtual void _whipped(); ///< Prepare 1 event
- virtual void process(PostProcessor& dest, ProcessContext& context) = 0;
+private:
+ Raul::List<Event*> _events;
+ Raul::AtomicPtr<Raul::List<Event*>::Node> _prepared_back;
+ Raul::Semaphore _blocking_semaphore;
};
} // namespace Ingen
-#endif // EVENTSOURCE_H
+#endif // INGEN_EVENT_SOURCE_HPP