1 #ifndef __ardour_session_event_h__
2 #define __ardour_session_event_h__
5 #include <boost/function.hpp>
6 #include <boost/shared_ptr.hpp>
9 #include "pbd/ringbuffer.h"
10 #include "pbd/event_loop.h"
12 #include "ardour/types.h"
35 InputConfigurationChange,
38 AdjustPlaybackBuffering,
39 AdjustCaptureBuffering,
40 SetTimecodeTransmission,
42 /* only one of each of these events can be queued at any one time */
58 framepos_t action_frame;
59 framepos_t target_frame;
65 framepos_t target2_frame;
71 bool second_yes_or_no;
74 /* 4 members to handle a multi-group event handled in RT context */
76 typedef boost::function<void (SessionEvent*)> RTeventCallback;
78 boost::shared_ptr<RouteList> routes; /* apply to */
79 boost::function<void (void)> rt_slot; /* what to call in RT context */
80 RTeventCallback rt_return; /* called after rt_slot, with this event as an argument */
81 PBD::EventLoop* event_loop;
83 std::list<AudioRange> audio_range;
84 std::list<MusicRange> music_range;
86 boost::shared_ptr<Region> region;
88 SessionEvent (Type t, Action a, framepos_t when, framepos_t where, double spd, bool yn = false, bool yn2 = false)
92 , target_frame (where)
95 , second_yes_or_no (yn2)
98 void set_ptr (void* p) {
102 bool before (const SessionEvent& other) const {
103 return action_frame < other.action_frame;
106 bool after (const SessionEvent& other) const {
107 return action_frame > other.action_frame;
110 static bool compare (const SessionEvent *e1, const SessionEvent *e2) {
111 return e1->before (*e2);
114 void* operator new (size_t);
115 void operator delete (void *ptr, size_t /*size*/);
117 static const framepos_t Immediate = 0;
119 static void create_per_thread_pool (const std::string& n, uint32_t nitems);
120 static void init_event_pool ();
123 static PerThreadPool* pool;
124 CrossThreadPool* own_pool;
129 class SessionEventManager {
131 SessionEventManager () : pending_events (2048),
132 auto_loop_event(0), punch_out_event(0), punch_in_event(0) {}
133 virtual ~SessionEventManager() {}
135 virtual void queue_event (SessionEvent *ev) = 0;
136 void clear_events (SessionEvent::Type type);
139 RingBuffer<SessionEvent*> pending_events;
140 typedef std::list<SessionEvent *> Events;
142 Events immediate_events;
143 Events::iterator next_event;
145 /* there can only ever be one of each of these */
147 SessionEvent *auto_loop_event;
148 SessionEvent *punch_out_event;
149 SessionEvent *punch_in_event;
151 void dump_events () const;
152 void merge_event (SessionEvent*);
153 void replace_event (SessionEvent::Type, framepos_t action_frame, framepos_t target = 0);
154 bool _replace_event (SessionEvent*);
155 bool _remove_event (SessionEvent *);
156 void _clear_event_type (SessionEvent::Type);
158 void add_event (framepos_t action_frame, SessionEvent::Type type, framepos_t target_frame = 0);
159 void remove_event (framepos_t frame, SessionEvent::Type type);
161 virtual void process_event(SessionEvent*) = 0;
162 virtual void set_next_event () = 0;
167 #endif /* __ardour_session_event_h__ */