Optimize plugin-processing for non-automated params
[ardour.git] / libs / ardour / ardour / disk_reader.h
index dabdff67a065d57ddb066afdb403f8757a9fb854..47139efd5b69d696c5bcff5243500d1bf6649566 100644 (file)
@@ -35,34 +35,30 @@ template<typename T> class MidiRingBuffer;
 
 class LIBARDOUR_API DiskReader : public DiskIOProcessor
 {
-  public:
+public:
        DiskReader (Session&, std::string const & name, DiskIOProcessor::Flag f = DiskIOProcessor::Flag (0));
        ~DiskReader ();
 
        bool set_name (std::string const & str);
-       std::string display_name() const { return std::string (_("reader")); }
+       std::string display_name() const { return std::string (_("player")); }
 
-       static framecnt_t chunk_frames() { return _chunk_frames; }
-       static framecnt_t default_chunk_frames ();
-       static void set_chunk_frames (framecnt_t n) { _chunk_frames = n; }
+       static samplecnt_t chunk_samples() { return _chunk_samples; }
+       static samplecnt_t default_chunk_samples ();
+       static void set_chunk_samples (samplecnt_t n) { _chunk_samples = n; }
 
-       void run (BufferSet& /*bufs*/, framepos_t /*start_frame*/, framepos_t /*end_frame*/, double speed, pframes_t /*nframes*/, bool /*result_required*/);
+       void run (BufferSet& /*bufs*/, samplepos_t /*start_sample*/, samplepos_t /*end_sample*/, double speed, pframes_t /*nframes*/, bool /*result_required*/);
        void realtime_handle_transport_stopped ();
        void realtime_locate ();
        int overwrite_existing_buffers ();
        void set_pending_overwrite (bool yn);
 
-       framecnt_t roll_delay() const { return _roll_delay; }
-       void set_roll_delay (framecnt_t);
-
-       virtual XMLNode& state (bool full);
        int set_state (const XMLNode&, int version);
 
        PBD::Signal0<void>            AlignmentStyleChanged;
 
        float buffer_load() const;
 
-       void move_processor_automation (boost::weak_ptr<Processor>, std::list<Evoral::RangeMove<framepos_t> > const &);
+       void move_processor_automation (boost::weak_ptr<Processor>, std::list<Evoral::RangeMove<samplepos_t> > const &);
 
        /* called by the Butler in a non-realtime context */
 
@@ -88,69 +84,81 @@ class LIBARDOUR_API DiskReader : public DiskIOProcessor
 
        void adjust_buffering ();
 
-       int can_internal_playback_seek (framecnt_t distance);
-       int internal_playback_seek (framecnt_t distance);
-       int seek (framepos_t frame, bool complete_refill = false);
+       int can_internal_playback_seek (samplecnt_t distance);
+       int internal_playback_seek (samplecnt_t distance);
+       int seek (samplepos_t sample, bool complete_refill = false);
 
        static PBD::Signal0<void> Underrun;
 
        void playlist_modified ();
        void reset_tracker ();
 
-       static void set_midi_readahead_frames (framecnt_t frames_ahead) { midi_readahead = frames_ahead; }
+       bool declick_in_progress () const {
+               return _declick_gain != 0; // declick-out
+       }
+
+       static void set_midi_readahead_samples (samplecnt_t samples_ahead) { midi_readahead = samples_ahead; }
 
-  protected:
+       static void set_no_disk_output (bool yn);
+       static bool no_disk_output() { return _no_disk_output; }
+
+protected:
        friend class Track;
        friend class MidiTrack;
 
-       void resolve_tracker (Evoral::EventSink<framepos_t>& buffer, framepos_t time);
-       boost::shared_ptr<MidiBuffer> get_gui_feed_buffer () const;
+       struct ReaderChannelInfo : public DiskIOProcessor::ChannelInfo {
+               ReaderChannelInfo (samplecnt_t buffer_size)
+                       : DiskIOProcessor::ChannelInfo (buffer_size)
+               {
+                       resize (buffer_size);
+               }
+               void resize (samplecnt_t);
+       };
+
+       XMLNode& state ();
+
+       void resolve_tracker (Evoral::EventSink<samplepos_t>& buffer, samplepos_t time);
 
        void playlist_changed (const PBD::PropertyChange&);
        int use_playlist (DataType, boost::shared_ptr<Playlist>);
-       void playlist_ranges_moved (std::list< Evoral::RangeMove<framepos_t> > const &, bool);
+       void playlist_ranges_moved (std::list< Evoral::RangeMove<samplepos_t> > const &, bool);
 
-  private:
-       /** The number of frames by which this diskstream's output should be delayed
-           with respect to the transport frame.  This is used for latency compensation.
+       int add_channel_to (boost::shared_ptr<ChannelList>, uint32_t how_many);
+
+private:
+       /** The number of samples by which this diskstream's output should be delayed
+           with respect to the transport sample.  This is used for latency compensation.
        */
-       framecnt_t   _roll_delay;
-       framepos_t    overwrite_frame;
+       samplepos_t   overwrite_sample;
        off_t         overwrite_offset;
        bool          _pending_overwrite;
        bool          overwrite_queued;
        IOChange      input_change_pending;
-       framecnt_t    wrap_buffer_size;
-
-       int _do_refill_with_alloc (bool partial_fill);
+       samplepos_t   file_sample[DataType::num_types];
 
-       static framecnt_t _chunk_frames;
-       static framecnt_t midi_readahead;
+       gain_t        _declick_gain;
 
-       /* The MIDI stuff */
+       int _do_refill_with_alloc (bool partial_fill);
 
-       /** A buffer that we use to put newly-arrived MIDI data in for
-           the GUI to read (so that it can update itself).
-       */
-       MidiBuffer                   _gui_feed_buffer;
-       mutable Glib::Threads::Mutex _gui_feed_buffer_mutex;
+       static samplecnt_t _chunk_samples;
+       static samplecnt_t midi_readahead;
+       static bool       _no_disk_output;
 
        int audio_read (Sample* buf, Sample* mixdown_buffer, float* gain_buffer,
-                       framepos_t& start, framecnt_t cnt,
+                       samplepos_t& start, samplecnt_t cnt,
                        int channel, bool reversed);
-       int midi_read (framepos_t& start, framecnt_t cnt, bool reversed);
+       int midi_read (samplepos_t& start, samplecnt_t cnt, bool reversed);
 
        static Sample* _mixdown_buffer;
        static gain_t* _gain_buffer;
 
-       int refill (Sample* mixdown_buffer, float* gain_buffer, framecnt_t fill_level);
-       int refill_audio (Sample *mixdown_buffer, float *gain_buffer, framecnt_t fill_level);
+       int refill (Sample* mixdown_buffer, float* gain_buffer, samplecnt_t fill_level);
+       int refill_audio (Sample *mixdown_buffer, float *gain_buffer, samplecnt_t fill_level);
        int refill_midi ();
 
-       frameoffset_t calculate_playback_distance (pframes_t);
+       sampleoffset_t calculate_playback_distance (pframes_t);
 
-       void get_playback (MidiBuffer& dst, framecnt_t nframes);
-       void flush_playback (framepos_t start, framepos_t end);
+       void get_midi_playback (MidiBuffer& dst, samplepos_t start_sample, samplepos_t end_sample, MonitorState, BufferSet&, double speed, samplecnt_t distance);
 };
 
 } // namespace