1 #ifndef __ardour_session_event_h__
2 #define __ardour_session_event_h__
5 #include <boost/shared_ptr.hpp>
6 #include <sigc++/signal.h>
9 #include "pbd/ringbuffer.h"
11 #include "ardour/types.h"
33 InputConfigurationChange,
37 /* only one of each of these events can be queued at any one time */
52 nframes64_t action_frame;
53 nframes64_t target_frame;
59 nframes64_t target2_frame;
65 bool second_yes_or_no;
68 boost::shared_ptr<RouteList> routes;
69 sigc::slot<void> rt_slot; /* what to call in RT context */
70 sigc::slot<void,SessionEvent*> rt_return; /* called after rt_slot, with this event as an argument */
72 std::list<AudioRange> audio_range;
73 std::list<MusicRange> music_range;
75 boost::shared_ptr<Region> region;
77 SessionEvent (Type t, Action a, nframes_t when, nframes_t where, double spd, bool yn = false, bool yn2 = false)
81 , target_frame (where)
84 , second_yes_or_no (yn2) {}
86 void set_ptr (void* p) {
90 bool before (const SessionEvent& other) const {
91 return action_frame < other.action_frame;
94 bool after (const SessionEvent& other) const {
95 return action_frame > other.action_frame;
98 static bool compare (const SessionEvent *e1, const SessionEvent *e2) {
99 return e1->before (*e2);
102 void* operator new (size_t);
103 void operator delete (void *ptr, size_t /*size*/);
105 static const nframes_t Immediate = 0;
107 static void create_per_thread_pool (const std::string& n, unsigned long nitems);
108 static void init_event_pool ();
111 static PerThreadPool* pool;
112 CrossThreadPool* own_pool;
115 class SessionEventManager {
117 SessionEventManager () : pending_events (2048){}
118 virtual ~SessionEventManager() {}
120 virtual void queue_event (SessionEvent *ev) = 0;
121 void clear_events (SessionEvent::Type type);
124 RingBuffer<SessionEvent*> pending_events;
125 typedef std::list<SessionEvent *> Events;
127 Events immediate_events;
128 Events::iterator next_event;
130 /* there can only ever be one of each of these */
132 SessionEvent *auto_loop_event;
133 SessionEvent *punch_out_event;
134 SessionEvent *punch_in_event;
136 void dump_events () const;
137 void merge_event (SessionEvent*);
138 void replace_event (SessionEvent::Type, nframes64_t action_frame, nframes64_t target = 0);
139 bool _replace_event (SessionEvent*);
140 bool _remove_event (SessionEvent *);
141 void _clear_event_type (SessionEvent::Type);
143 void add_event (nframes64_t action_frame, SessionEvent::Type type, nframes64_t target_frame = 0);
144 void remove_event (nframes64_t frame, SessionEvent::Type type);
146 virtual void process_event(SessionEvent*) = 0;
147 virtual void set_next_event () = 0;
152 #endif /* __ardour_session_event_h__ */