summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour/session_event.h
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-12-04 02:15:12 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-12-04 02:15:12 +0000
commit9ad2875905c611b33fc9114101da224c878ca9cd (patch)
tree8e37e2a765ea68eea29c42a6f0cdc13b05180bbe /libs/ardour/ardour/session_event.h
parent1ef43ec89c1073a370450b9756fca361b1c0f69d (diff)
move Session::Event into SessionEvent class; add SessionEventManager (Session IS-A SessionEventManager); make session ops to toggle all track rec-enable be atomic with respect to process()
git-svn-id: svn://localhost/ardour2/branches/3.0@6273 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour/session_event.h')
-rw-r--r--libs/ardour/ardour/session_event.h152
1 files changed, 152 insertions, 0 deletions
diff --git a/libs/ardour/ardour/session_event.h b/libs/ardour/ardour/session_event.h
new file mode 100644
index 0000000000..767c374988
--- /dev/null
+++ b/libs/ardour/ardour/session_event.h
@@ -0,0 +1,152 @@
+#ifndef __ardour_session_event_h__
+#define __ardour_session_event_h__
+
+#include <list>
+#include <boost/shared_ptr.hpp>
+#include <sigc++/signal.h>
+
+#include "pbd/pool.h"
+#include "pbd/ringbuffer.h"
+
+#include "ardour/types.h"
+
+namespace ARDOUR {
+
+class Slave;
+class Region;
+
+struct SessionEvent {
+ enum Type {
+ SetTransportSpeed,
+ SetDiskstreamSpeed,
+ Locate,
+ LocateRoll,
+ LocateRollLocate,
+ SetLoop,
+ PunchIn,
+ PunchOut,
+ RangeStop,
+ RangeLocate,
+ Overwrite,
+ SetSyncSource,
+ Audition,
+ InputConfigurationChange,
+ SetPlayAudioRange,
+ SetRecordEnable,
+
+ /* only one of each of these events can be queued at any one time */
+
+ StopOnce,
+ AutoLoop
+ };
+
+ enum Action {
+ Add,
+ Remove,
+ Replace,
+ Clear
+ };
+
+ Type type;
+ Action action;
+ nframes64_t action_frame;
+ nframes64_t target_frame;
+ double speed;
+
+ union {
+ void* ptr;
+ bool yes_or_no;
+ nframes64_t target2_frame;
+ Slave* slave;
+ Route* route;
+ };
+
+ union {
+ bool second_yes_or_no;
+ RouteList* routes;
+ };
+
+ std::list<AudioRange> audio_range;
+ std::list<MusicRange> music_range;
+
+ boost::shared_ptr<Region> region;
+
+ sigc::signal<void,SessionEvent*,int> Complete;
+
+ SessionEvent (Type t, Action a, nframes_t when, nframes_t where, double spd, bool yn = false, bool yn2 = false)
+ : type (t)
+ , action (a)
+ , action_frame (when)
+ , target_frame (where)
+ , speed (spd)
+ , yes_or_no (yn)
+ , second_yes_or_no (yn2) {}
+
+ void set_ptr (void* p) {
+ ptr = p;
+ }
+
+ bool before (const SessionEvent& other) const {
+ return action_frame < other.action_frame;
+ }
+
+ bool after (const SessionEvent& other) const {
+ return action_frame > other.action_frame;
+ }
+
+ static bool compare (const SessionEvent *e1, const SessionEvent *e2) {
+ return e1->before (*e2);
+ }
+
+ void *operator new (size_t) {
+ return pool.alloc ();
+ }
+
+ void operator delete (void *ptr, size_t /*size*/) {
+ pool.release (ptr);
+ }
+
+ static const nframes_t Immediate = 0;
+
+private:
+ static MultiAllocSingleReleasePool pool;
+};
+
+class SessionEventManager {
+ public:
+ SessionEventManager () : pending_events (2048){}
+ virtual ~SessionEventManager() {}
+
+ void add_event (nframes64_t action_frame, SessionEvent::Type type, nframes64_t target_frame = 0);
+ void remove_event (nframes64_t frame, SessionEvent::Type type);
+ void clear_events (SessionEvent::Type type);
+
+
+ protected:
+ RingBuffer<SessionEvent*> pending_events;
+ typedef std::list<SessionEvent *> Events;
+ Events events;
+ Events immediate_events;
+ Events::iterator next_event;
+
+ /* there can only ever be one of each of these */
+
+ SessionEvent *auto_loop_event;
+ SessionEvent *punch_out_event;
+ SessionEvent *punch_in_event;
+
+ void dump_events () const;
+ void merge_event (SessionEvent*);
+ void replace_event (SessionEvent::Type, nframes64_t action_frame, nframes64_t target = 0);
+ bool _replace_event (SessionEvent*);
+ bool _remove_event (SessionEvent *);
+ void _clear_event_type (SessionEvent::Type);
+
+ virtual void process_event(SessionEvent*) = 0;
+ virtual void queue_event (SessionEvent *ev) = 0;
+ virtual void set_next_event () = 0;
+};
+
+} /* namespace */
+
+#endif /* __ardour_session_event_h__ */