X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fardour%2Fsession_event.h;h=37e229acfb35a815fe75cdf347be386d248fd7f9;hb=e4d3ebfb666e2c4e9cf134d8f3ed42152da343bf;hp=1283f320040eb2ba3c58929bd69e86df51c1f7f7;hpb=2ba58dfe65bb0c5ba7d5eb18a1566fa79eeb6993;p=ardour.git diff --git a/libs/ardour/ardour/session_event.h b/libs/ardour/ardour/session_event.h index 1283f32004..37e229acfb 100644 --- a/libs/ardour/ardour/session_event.h +++ b/libs/ardour/ardour/session_event.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Paul Davis + 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 @@ -33,14 +33,13 @@ namespace ARDOUR { -class Slave; +class TransportMaster; class Region; class LIBARDOUR_API SessionEvent { public: enum Type { SetTransportSpeed, - SetTrackSpeed, Locate, LocateRoll, LocateRollLocate, @@ -50,20 +49,20 @@ public: RangeStop, RangeLocate, Overwrite, - SetSyncSource, Audition, - InputConfigurationChange, SetPlayAudioRange, + CancelPlayAudioRange, RealTimeOperation, AdjustPlaybackBuffering, AdjustCaptureBuffering, SetTimecodeTransmission, + Skip, + SetTransportMaster, /* only one of each of these events can be queued at any one time */ StopOnce, AutoLoop, - AutoLoopDeclick, }; enum Action { @@ -75,61 +74,54 @@ 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 { bool second_yes_or_no; + double control_value; }; union { bool third_yes_or_no; }; - /* 4 members to handle a multi-group event handled in RT context */ + /* 5 members to handle a multi-group event handled in RT context */ typedef boost::function RTeventCallback; - boost::shared_ptr routes; /* apply to */ - boost::function rt_slot; /* what to call in RT context */ - RTeventCallback rt_return; /* called after rt_slot, with this event as an argument */ + boost::shared_ptr controls; /* apply to */ + boost::shared_ptr routes; /* apply to */ + boost::function rt_slot; /* what to call in RT context */ + RTeventCallback rt_return; /* called after rt_slot, with this event as an argument */ PBD::EventLoop* event_loop; std::list audio_range; std::list music_range; boost::shared_ptr region; + boost::shared_ptr transport_master; - SessionEvent (Type t, Action a, framepos_t when, framepos_t where, double spd, bool yn = false, bool yn2 = false, bool yn3 = false) - : type (t) - , action (a) - , action_frame (when) - , target_frame (where) - , speed (spd) - , yes_or_no (yn) - , second_yes_or_no (yn2) - , third_yes_or_no (yn3) - , event_loop (0) {} + 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) { @@ -139,11 +131,14 @@ public: void* operator new (size_t); void operator delete (void *ptr, size_t /*size*/); - static const framepos_t Immediate = 0; + 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); static void init_event_pool (); + CrossThreadPool* event_pool() const { return own_pool; } + private: static PerThreadPool* pool; CrossThreadPool* own_pool; @@ -159,14 +154,17 @@ public: virtual void queue_event (SessionEvent *ev) = 0; void clear_events (SessionEvent::Type type); + void clear_events (SessionEvent::Type type, boost::function after); protected: - RingBuffer pending_events; + PBD::RingBuffer pending_events; typedef std::list Events; Events events; Events immediate_events; Events::iterator next_event; + Glib::Threads::Mutex rb_write_lock; + /* there can only ever be one of each of these */ SessionEvent *auto_loop_event; @@ -175,13 +173,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;