When we rename a track, only rename its playlist if it
[ardour.git] / libs / ardour / ardour / audiosource.h
index 22d5d1a7249c7881b22919a7a3ea8a15540257f9..c6ec2a56ada30e0a905c2817b595a6943115022e 100644 (file)
@@ -47,11 +47,11 @@ class AudioSource : virtual public Source,
        virtual ~AudioSource ();
 
        framecnt_t readable_length() const { return _length; }
-       uint32_t   n_channels()      const { return 1; }
+       virtual uint32_t n_channels()      const { return 1; }
 
-        bool       empty() const;
+       virtual bool       empty() const;
        framecnt_t length (framepos_t pos) const;
-       void      update_length (framepos_t pos, framecnt_t cnt);
+       void       update_length (framecnt_t cnt);
 
        virtual framecnt_t available_peaks (double zoom) const;
 
@@ -67,10 +67,6 @@ class AudioSource : virtual public Source,
        void set_captured_for (std::string str) { _captured_for = str; }
        std::string captured_for() const { return _captured_for; }
 
-       uint32_t read_data_count() const { return _read_data_count; }
-       uint32_t write_data_count() const { return _write_data_count; }
-       void dec_read_data_count (framecnt_t);
-
        int read_peaks (PeakData *peaks, framecnt_t npeaks,
                        framepos_t start, framecnt_t cnt, double samples_per_visual_peak) const;
 
@@ -106,17 +102,31 @@ class AudioSource : virtual public Source,
        /** @return true if the each source sample s must be clamped to -1 < s < 1 */
        virtual bool clamped_at_unity () const = 0;
 
+       static void allocate_working_buffers (framecnt_t framerate);
+
   protected:
        static bool _build_missing_peakfiles;
        static bool _build_peakfiles;
 
+       static size_t _working_buffers_size;
+
+       /* these collections of working buffers for supporting
+          playlist's reading from potentially nested/recursive
+          sources assume SINGLE THREADED reads by the butler
+          thread, or a lock around calls that use them.
+       */
+
+       static std::vector<boost::shared_ptr<Sample> > _mixdown_buffers;
+       static std::vector<boost::shared_ptr<gain_t> > _gain_buffers;
+       static Glib::StaticMutex    _level_buffer_lock;
+
+       static void ensure_buffers_for_level (uint32_t, framecnt_t);
+       static void ensure_buffers_for_level_locked (uint32_t, framecnt_t);
+
        framecnt_t           _length;
        std::string         peakpath;
        std::string        _captured_for;
 
-       mutable uint32_t _read_data_count;  // modified in read()
-       mutable uint32_t _write_data_count; // modified in write()
-
        int initialize_peakfile (bool newfile, std::string path);
        int build_peaks_from_scratch ();
        int compute_and_write_peaks (Sample* buf, framecnt_t first_frame, framecnt_t cnt,
@@ -128,15 +138,15 @@ class AudioSource : virtual public Source,
        virtual framecnt_t read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) const = 0;
        virtual framecnt_t write_unlocked (Sample *dst, framecnt_t cnt) = 0;
        virtual std::string peak_path(std::string audio_path) = 0;
-       virtual std::string find_broken_peakfile (std::string missing_peak_path,
-                                                  std::string audio_path) = 0;
+       virtual std::string find_broken_peakfile (std::string /* missing_peak_path */,
+                                                 std::string audio_path) { return peak_path (audio_path); }
 
        virtual int read_peaks_with_fpp (PeakData *peaks,
                                         framecnt_t npeaks, framepos_t start, framecnt_t cnt,
                                         double samples_per_visual_peak, framecnt_t fpp) const;
-       
+
        int compute_and_write_peaks (Sample* buf, framecnt_t first_frame, framecnt_t cnt,
-                                    bool force, bool intermediate_peaks_ready_signal, 
+                                    bool force, bool intermediate_peaks_ready_signal,
                                     framecnt_t frames_per_peak);
 
   private:
@@ -148,7 +158,7 @@ class AudioSource : virtual public Source,
         *  during the handling of the signal.
         */
        mutable Glib::Mutex _peaks_ready_lock;
-       
+
        PBD::FdFileDescriptor* _peakfile_descriptor;
        int        _peakfile_fd;
        framecnt_t peak_leftover_cnt;