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,
38 /* only one of each of these events can be queued at any one time */
53 nframes64_t action_frame;
54 nframes64_t target_frame;
60 nframes64_t target2_frame;
66 bool second_yes_or_no;
70 sigc::slot<void> rt_slot; /* what to call in RT context */
71 sigc::slot<void,SessionEvent*> rt_return; /* called after rt_slot, with this event as an argument */
73 std::list<AudioRange> audio_range;
74 std::list<MusicRange> music_range;
76 boost::shared_ptr<Region> region;
78 SessionEvent (Type t, Action a, nframes_t when, nframes_t where, double spd, bool yn = false, bool yn2 = false)
82 , target_frame (where)
85 , second_yes_or_no (yn2) {}
87 void set_ptr (void* p) {
91 bool before (const SessionEvent& other) const {
92 return action_frame < other.action_frame;
95 bool after (const SessionEvent& other) const {
96 return action_frame > other.action_frame;
99 static bool compare (const SessionEvent *e1, const SessionEvent *e2) {
100 return e1->before (*e2);
103 void* operator new (size_t);
104 void operator delete (void *ptr, size_t /*size*/);
106 static const nframes_t Immediate = 0;
108 static void create_per_thread_pool (const std::string& n, unsigned long nitems);
109 static void init_event_pool ();
112 static PerThreadPool* pool;
113 CrossThreadPool* own_pool;
116 class SessionEventManager {
118 SessionEventManager () : pending_events (2048){}
119 virtual ~SessionEventManager() {}
121 void add_event (nframes64_t action_frame, SessionEvent::Type type, nframes64_t target_frame = 0);
122 void remove_event (nframes64_t frame, SessionEvent::Type type);
123 void clear_events (SessionEvent::Type type);
127 RingBuffer<SessionEvent*> pending_events;
128 typedef std::list<SessionEvent *> Events;
130 Events immediate_events;
131 Events::iterator next_event;
133 /* there can only ever be one of each of these */
135 SessionEvent *auto_loop_event;
136 SessionEvent *punch_out_event;
137 SessionEvent *punch_in_event;
139 void dump_events () const;
140 void merge_event (SessionEvent*);
141 void replace_event (SessionEvent::Type, nframes64_t action_frame, nframes64_t target = 0);
142 bool _replace_event (SessionEvent*);
143 bool _remove_event (SessionEvent *);
144 void _clear_event_type (SessionEvent::Type);
146 virtual void process_event(SessionEvent*) = 0;
147 virtual void queue_event (SessionEvent *ev) = 0;
148 virtual void set_next_event () = 0;
153 #endif /* __ardour_session_event_h__ */