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"
34 class LIBARDOUR_API DiskIOProcessor : public Processor
37 static const std::string state_node_name;
39 DiskIOProcessor(Session&, const std::string& name);
41 void run (BufferSet& /*bufs*/, framepos_t /*start_frame*/, framepos_t /*end_frame*/, double speed, pframes_t /*nframes*/, bool /*result_required*/) {}
42 void silence (framecnt_t /*nframes*/, framepos_t /*start_frame*/) {}
44 bool configure_io (ChanCount in, ChanCount out);
45 bool can_support_io_configuration (const ChanCount& in, ChanCount& out) = 0;
46 ChanCount input_streams () const { return _configured_input; }
47 ChanCount output_streams() const { return _configured_output; }
49 virtual void realtime_handle_transport_stopped () {}
50 virtual void realtime_locate () {}
52 /* note: derived classes should implement state(), NOT get_state(), to allow
53 us to merge C++ inheritance and XML lack-of-inheritance reasonably
57 virtual XMLNode& state (bool full);
58 XMLNode& get_state (void);
59 int set_state (const XMLNode&, int version);
61 static framecnt_t disk_read_frames() { return disk_read_chunk_frames; }
62 static framecnt_t disk_write_frames() { return disk_write_chunk_frames; }
63 static void set_disk_read_chunk_frames (framecnt_t n) { disk_read_chunk_frames = n; }
64 static void set_disk_write_chunk_frames (framecnt_t n) { disk_write_chunk_frames = n; }
65 static framecnt_t default_disk_read_chunk_frames ();
66 static framecnt_t default_disk_write_chunk_frames ();
68 static void set_buffering_parameters (BufferingPreset bp);
71 static framecnt_t disk_read_chunk_frames;
72 static framecnt_t disk_write_chunk_frames;
74 uint32_t i_am_the_modifier;
77 ChanCount _n_channels;
79 double _visible_speed;
81 /* items needed for speed change logic */
82 bool _buffer_reallocation_required;
85 Location* loop_location;
90 Glib::Threads::Mutex state_lock;
94 class LIBARDOUR_API DiskReader : public DiskIOProcessor
97 DiskReader (Session&, std::string const & name);
101 boost::shared_ptr<Playlist> _playlist;
103 framepos_t overwrite_frame;
104 off_t overwrite_offset;
105 bool _pending_overwrite;
106 bool overwrite_queued;
107 IOChange input_change_pending;
108 framecnt_t wrap_buffer_size;
109 framecnt_t speed_buffer_size;
112 double _target_speed;
114 /** The next frame position that we should be reading from in our playlist */
115 framepos_t file_frame;
116 framepos_t playback_sample;
118 PBD::ScopedConnectionList playlist_connections;
119 PBD::ScopedConnection ic_connection;
122 class LIBARDOUR_API DiskWriter : public DiskIOProcessor
125 DiskWriter (Session&, std::string const & name);
129 std::vector<CaptureInfo*> capture_info;
130 mutable Glib::Threads::Mutex capture_info_lock;
132 double _visible_speed;
133 double _actual_speed;
134 /* items needed for speed change logic */
135 bool _buffer_reallocation_required;
138 /** Start of currently running capture in session frames */
139 framepos_t capture_start_frame;
140 framecnt_t capture_captured;
142 framecnt_t adjust_capture_position;
143 framecnt_t _capture_offset;
144 framepos_t first_recordable_frame;
145 framepos_t last_recordable_frame;
146 int last_possibly_recording;
147 AlignStyle _alignment_style;
148 AlignChoice _alignment_choice;
149 framecnt_t wrap_buffer_size;
150 framecnt_t speed_buffer_size;
152 std::string _write_source_name;
154 PBD::ScopedConnection ic_connection;
158 } // namespace ARDOUR
160 #endif /* __ardour_processor_h__ */