2 Copyright (C) 2009-2016 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __ardour_disk_io_h__
21 #define __ardour_disk_io_h__
27 #include "ardour/processor.h"
35 class LIBARDOUR_API DiskIOProcessor : public Processor
45 static const std::string state_node_name;
47 DiskIOProcessor (Session&, const std::string& name, Flag f);
49 static void set_buffering_parameters (BufferingPreset bp);
51 /** @return A number between 0 and 1, where 0 indicates that the playback buffer
52 * is dry (ie the disk subsystem could not keep up) and 1 indicates that the
55 virtual float playback_buffer_load() const = 0;
56 virtual float capture_buffer_load() const = 0;
58 void set_flag (Flag f) { _flags = Flag (_flags | f); }
59 void unset_flag (Flag f) { _flags = Flag (_flags & ~f); }
61 bool hidden() const { return _flags & Hidden; }
62 bool recordable() const { return _flags & Recordable; }
63 bool non_layered() const { return _flags & NonLayered; }
64 bool reversed() const { return _actual_speed < 0.0f; }
65 double speed() const { return _visible_speed; }
67 ChanCount n_channels() { return _n_channels; }
69 void non_realtime_set_speed ();
70 bool realtime_set_speed (double sp, bool global);
72 virtual void punch_in() {}
73 virtual void punch_out() {}
75 virtual float buffer_load() const = 0;
77 bool slaved() const { return _slaved; }
78 void set_slaved(bool yn) { _slaved = yn; }
80 int set_loop (Location *loc);
82 PBD::Signal1<void,Location *> LoopSet;
83 PBD::Signal0<void> SpeedChanged;
84 PBD::Signal0<void> ReverseChanged;
86 int set_state (const XMLNode&, int version);
89 friend class Auditioner;
90 virtual int seek (framepos_t which_sample, bool complete_refill = false) = 0;
94 uint32_t i_am_the_modifier;
95 ChanCount _n_channels;
96 double _visible_speed;
100 /* items needed for speed change logic */
101 bool _buffer_reallocation_required;
104 Location* loop_location;
106 framecnt_t wrap_buffer_size;
107 framecnt_t speed_buffer_size;
109 Glib::Threads::Mutex state_lock;
111 static bool get_buffering_presets (BufferingPreset bp,
112 framecnt_t& read_chunk_size,
113 framecnt_t& read_buffer_size,
114 framecnt_t& write_chunk_size,
115 framecnt_t& write_buffer_size);
117 virtual void allocate_temporary_buffers () = 0;
120 } // namespace ARDOUR
122 #endif /* __ardour_disk_io_h__ */