Optimize automation-event process splitting
[ardour.git] / libs / ardour / ardour / disk_io.h
index 2224978c3633e94d7a33f3c667d9d35069caf49a..0f79930654d25ac7c552b10a65d5fa16b1e58235 100644 (file)
@@ -45,17 +45,18 @@ template<typename T> class MidiRingBuffer;
 
 class LIBARDOUR_API DiskIOProcessor : public Processor
 {
-  public:
+public:
        enum Flag {
                Recordable  = 0x1,
                Hidden      = 0x2,
                Destructive = 0x4,
-               NonLayered   = 0x8
+               NonLayered  = 0x8 // deprecated (kept only for enum compat)
        };
 
        static const std::string state_node_name;
 
        DiskIOProcessor (Session&, const std::string& name, Flag f);
+       virtual ~DiskIOProcessor ();
 
        void set_route (boost::shared_ptr<Route>);
        void drop_route ();
@@ -77,12 +78,8 @@ class LIBARDOUR_API DiskIOProcessor : public Processor
 
        bool           hidden()      const { return _flags & Hidden; }
        bool           recordable()  const { return _flags & Recordable; }
-       bool           non_layered()  const { return _flags & NonLayered; }
 
-       virtual void non_realtime_locate (framepos_t);
-
-       void non_realtime_speed_change ();
-       bool realtime_speed_change ();
+       virtual void non_realtime_locate (samplepos_t);
 
        virtual void punch_in()  {}
        virtual void punch_out() {}
@@ -90,9 +87,6 @@ class LIBARDOUR_API DiskIOProcessor : public Processor
        bool slaved() const      { return _slaved; }
        void set_slaved(bool yn) { _slaved = yn; }
 
-       int set_loop (Location *loc);
-
-       PBD::Signal1<void,Location *> LoopSet;
        PBD::Signal0<void>            SpeedChanged;
        PBD::Signal0<void>            ReverseChanged;
 
@@ -110,29 +104,20 @@ class LIBARDOUR_API DiskIOProcessor : public Processor
        virtual void playlist_modified () {}
        virtual int use_playlist (DataType, boost::shared_ptr<Playlist>);
 
-       PBD::Signal1<void,DataType>   PlaylistChanged;
-
        virtual void adjust_buffering() = 0;
 
-  protected:
+protected:
        friend class Auditioner;
-       virtual int  seek (framepos_t which_sample, bool complete_refill = false) = 0;
+       virtual int  seek (samplepos_t which_sample, bool complete_refill = false) = 0;
 
-  protected:
+protected:
        Flag         _flags;
        uint32_t      i_am_the_modifier;
        double       _actual_speed;
        double       _target_speed;
-       /* items needed for speed change logic */
-       bool         _buffer_reallocation_required;
-       bool         _seek_required;
        bool         _slaved;
-       Location*     loop_location;
        bool          in_set_state;
-       framepos_t     file_frame;
-       framepos_t     playback_sample;
-       framecnt_t    wrap_buffer_size;
-       framecnt_t    speed_buffer_size;
+       samplepos_t   playback_sample;
        bool         _need_butler;
        boost::shared_ptr<Route> _route;
 
@@ -141,10 +126,10 @@ class LIBARDOUR_API DiskIOProcessor : public Processor
        Glib::Threads::Mutex state_lock;
 
        static bool get_buffering_presets (BufferingPreset bp,
-                                          framecnt_t& read_chunk_size,
-                                          framecnt_t& read_buffer_size,
-                                          framecnt_t& write_chunk_size,
-                                          framecnt_t& write_buffer_size);
+                                          samplecnt_t& read_chunk_size,
+                                          samplecnt_t& read_buffer_size,
+                                          samplecnt_t& write_chunk_size,
+                                          samplecnt_t& write_buffer_size);
 
        enum TransitionType {
                CaptureStart = 0,
@@ -153,7 +138,7 @@ class LIBARDOUR_API DiskIOProcessor : public Processor
 
        struct CaptureTransition {
                TransitionType   type;
-               framepos_t       capture_val; ///< The start or end file frame position
+               samplepos_t       capture_val; ///< The start or end file sample position
        };
 
        /** Information about one audio channel, playback or capture
@@ -161,52 +146,50 @@ class LIBARDOUR_API DiskIOProcessor : public Processor
         */
        struct ChannelInfo : public boost::noncopyable {
 
-               ChannelInfo (framecnt_t buffer_size);
-               ~ChannelInfo ();
+               ChannelInfo (samplecnt_t buffer_size);
+               virtual ~ChannelInfo ();
 
-               /** A ringbuffer for data to be played back, written to in the
-                   butler thread, read from in the process thread.
-               */
-               PBD::RingBufferNPT<Sample>* buf;
-
-               Sample* scrub_buffer;
-               Sample* scrub_forward_buffer;
-               Sample* scrub_reverse_buffer;
+               /** Ringbuffer for data to be played back.
+                * written to in the butler thread, read from in the process thread.
+                */
+               PBD::RingBufferNPT<Sample>* rbuf;
 
+               /** A ringbuffer for data to be recorded back, written to in the
+                * process thread, read from in the butler thread.
+                */
+               PBD::RingBufferNPT<Sample>* wbuf;
                PBD::RingBufferNPT<Sample>::rw_vector rw_vector;
 
                /* used only by capture */
                boost::shared_ptr<AudioFileSource> write_source;
-               PBD::RingBufferNPT<CaptureTransition> * capture_transition_buf;
-               // the following are used in the butler thread only
-               framecnt_t                     curr_capture_cnt;
+               PBD::RingBufferNPT<CaptureTransition>* capture_transition_buf;
+
+               /* used in the butler thread only */
+               samplecnt_t curr_capture_cnt;
 
-               void resize (framecnt_t);
+               virtual void resize (samplecnt_t) = 0;
        };
 
        typedef std::vector<ChannelInfo*> ChannelList;
        SerializedRCUManager<ChannelList> channels;
 
-       int add_channel_to (boost::shared_ptr<ChannelList>, uint32_t how_many);
+       virtual int add_channel_to (boost::shared_ptr<ChannelList>, uint32_t how_many) = 0;
        int remove_channel_from (boost::shared_ptr<ChannelList>, uint32_t how_many);
 
-       CubicInterpolation interpolation;
-
        boost::shared_ptr<Playlist> _playlists[DataType::num_types];
        PBD::ScopedConnectionList playlist_connections;
 
        virtual void playlist_changed (const PBD::PropertyChange&) {}
        virtual void playlist_deleted (boost::weak_ptr<Playlist>);
-       virtual void playlist_ranges_moved (std::list< Evoral::RangeMove<framepos_t> > const &, bool) {}
+       virtual void playlist_ranges_moved (std::list< Evoral::RangeMove<samplepos_t> > const &, bool) {}
 
        /* The MIDI stuff */
 
-       MidiRingBuffer<framepos_t>*  _midi_buf;
-       gint                         _frames_written_to_ringbuffer;
-       gint                         _frames_read_from_ringbuffer;
-       CubicMidiInterpolation        midi_interpolation;
+       MidiRingBuffer<samplepos_t>*  _midi_buf;
+       gint                         _samples_written_to_ringbuffer;
+       gint                         _samples_read_from_ringbuffer;
 
-       static void get_location_times (const Location* location, framepos_t* start, framepos_t* end, framepos_t* length);
+       static void get_location_times (const Location* location, samplepos_t* start, samplepos_t* end, samplepos_t* length);
 };
 
 } // namespace ARDOUR