- bool _peaks_built;
- mutable Glib::Mutex _lock;
- bool next_peak_clear_should_notify;
- string peakpath;
- 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, string path);
- void build_peaks_from_scratch ();
-
- int do_build_peak (jack_nframes_t, jack_nframes_t);
-
- virtual jack_nframes_t read_unlocked (Sample *dst, jack_nframes_t start, jack_nframes_t cnt) const = 0;
- virtual jack_nframes_t write_unlocked (Sample *dst, jack_nframes_t cnt) = 0;
- virtual string peak_path(string audio_path) = 0;
- virtual string old_peak_path(string audio_path) = 0;
-
- static pthread_t peak_thread;
- static bool have_peak_thread;
- static void* peak_thread_work(void*);
-
- static int peak_request_pipe[2];
-
- struct PeakRequest {
- enum Type {
- Build,
- Quit
- };
- };
-
- static vector<AudioSource*> pending_peak_sources;
- static Glib::Mutex* pending_peak_sources_lock;
-
- static void queue_for_peaks (AudioSource&);
- static void clear_queue_for_peaks ();
-
- struct PeakBuildRecord {
- jack_nframes_t frame;
- jack_nframes_t cnt;
-
- PeakBuildRecord (jack_nframes_t f, jack_nframes_t c)
- : frame (f), cnt (c) {}
- PeakBuildRecord (const PeakBuildRecord& other) {
- frame = other.frame;
- cnt = other.cnt;
- }
- };
-
- list<AudioSource::PeakBuildRecord *> pending_peak_builds;
+ 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;
+
+ 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,
+ bool force, bool intermediate_peaks_ready_signal);
+ void truncate_peakfile();
+
+ mutable off_t _peak_byte_max; // modified in compute_and_write_peak()
+
+ 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) { 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,
+ framecnt_t frames_per_peak);