add finite state machine to control/manage transport state
[ardour.git] / libs / ardour / ardour / session_event.h
index 2780924c276ad12138bc9ed713103047206ec5ff..98fe6838f5e675a76796519389c63887ecafbc12 100644 (file)
@@ -1,21 +1,23 @@
 /*
-    Copyright (C) 2012 Paul Davis
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
+ * Copyright (C) 2009-2018 Paul Davis <paul@linuxaudiosystems.com>
+ * Copyright (C) 2010-2012 Carl Hetherington <carl@carlh.net>
+ * Copyright (C) 2010-2012 David Robillard <d@drobilla.net>
+ * Copyright (C) 2015-2018 Robin Gareus <robin@gareus.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
 
 #ifndef __ardour_session_event_h__
 #define __ardour_session_event_h__
@@ -33,7 +35,7 @@
 
 namespace ARDOUR {
 
-class Slave;
+class TransportMaster;
 class Region;
 
 class LIBARDOUR_API SessionEvent {
@@ -46,13 +48,10 @@ public:
                SetLoop,
                PunchIn,
                PunchOut,
-               RecordStart,
                RangeStop,
                RangeLocate,
                Overwrite,
-               SetSyncSource,
                Audition,
-               InputConfigurationChange,
                SetPlayAudioRange,
                CancelPlayAudioRange,
                RealTimeOperation,
@@ -60,12 +59,11 @@ public:
                AdjustCaptureBuffering,
                SetTimecodeTransmission,
                Skip,
+               SetTransportMaster,
 
                /* only one of each of these events can be queued at any one time */
 
-               StopOnce,
                AutoLoop,
-               AutoLoopDeclick,
        };
 
        enum Action {
@@ -77,16 +75,15 @@ public:
 
        Type       type;
        Action     action;
-       framepos_t action_frame;
-       framepos_t target_frame;
+       samplepos_t action_sample;
+       samplepos_t target_sample;
        double     speed;
 
        union {
-               void*        ptr;
-               bool         yes_or_no;
-               framepos_t   target2_frame;
-               Slave*       slave;
-               Route*       route;
+               void*            ptr;
+               bool             yes_or_no;
+               samplepos_t      target2_sample;
+               Route*           route;
        };
 
        union {
@@ -112,19 +109,20 @@ public:
        std::list<MusicRange> music_range;
 
        boost::shared_ptr<Region> region;
+       boost::shared_ptr<TransportMaster> transport_master;
 
-       SessionEvent (Type t, Action a, framepos_t when, framepos_t where, double spd, bool yn = false, bool yn2 = false, bool yn3 = false);
+       SessionEvent (Type t, Action a, samplepos_t when, samplepos_t where, double spd, bool yn = false, bool yn2 = false, bool yn3 = false);
 
        void set_ptr (void* p) {
                ptr = p;
        }
 
        bool before (const SessionEvent& other) const {
-               return action_frame < other.action_frame;
+               return action_sample < other.action_sample;
        }
 
        bool after (const SessionEvent& other) const {
-               return action_frame > other.action_frame;
+               return action_sample > other.action_sample;
        }
 
        static bool compare (const SessionEvent *e1, const SessionEvent *e2) {
@@ -134,7 +132,7 @@ public:
        void* operator new (size_t);
        void  operator delete (void *ptr, size_t /*size*/);
 
-       static const framepos_t Immediate = -1;
+       static const samplepos_t Immediate = -1;
 
        static bool has_per_thread_pool ();
        static void create_per_thread_pool (const std::string& n, uint32_t nitems);
@@ -176,13 +174,13 @@ protected:
 
        void dump_events () const;
        void merge_event (SessionEvent*);
-       void replace_event (SessionEvent::Type, framepos_t action_frame, framepos_t target = 0);
+       void replace_event (SessionEvent::Type, samplepos_t action_sample, samplepos_t target = 0);
        bool _replace_event (SessionEvent*);
        bool _remove_event (SessionEvent *);
        void _clear_event_type (SessionEvent::Type);
 
-       void add_event (framepos_t action_frame, SessionEvent::Type type, framepos_t target_frame = 0);
-       void remove_event (framepos_t frame, SessionEvent::Type type);
+       void add_event (samplepos_t action_sample, SessionEvent::Type type, samplepos_t target_sample = 0);
+       void remove_event (samplepos_t sample, SessionEvent::Type type);
 
        virtual void process_event(SessionEvent*) = 0;
        virtual void set_next_event () = 0;