diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2017-03-06 12:47:46 +0100 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2017-09-18 11:40:52 -0400 |
commit | c05cfe332868c1aca477aedcecdfb78948e6d559 (patch) | |
tree | 7e758eced492acb32dd40004c41dfb48909afa55 /libs/ardour/ardour/disk_io.h | |
parent | 46366541b1aea2c6441b4273734307ab4c55ce13 (diff) |
merge AudioDiskstream playback code into DiskReader
Diffstat (limited to 'libs/ardour/ardour/disk_io.h')
-rw-r--r-- | libs/ardour/ardour/disk_io.h | 150 |
1 files changed, 56 insertions, 94 deletions
diff --git a/libs/ardour/ardour/disk_io.h b/libs/ardour/ardour/disk_io.h index 4819b63293..87a761a7b7 100644 --- a/libs/ardour/ardour/disk_io.h +++ b/libs/ardour/ardour/disk_io.h @@ -30,131 +30,93 @@ namespace ARDOUR { class Session; class Route; +class Location; class LIBARDOUR_API DiskIOProcessor : public Processor { public: - static const std::string state_node_name; - - DiskIOProcessor(Session&, const std::string& name); - - void run (BufferSet& /*bufs*/, framepos_t /*start_frame*/, framepos_t /*end_frame*/, double speed, pframes_t /*nframes*/, bool /*result_required*/) {} - void silence (framecnt_t /*nframes*/, framepos_t /*start_frame*/) {} - - bool configure_io (ChanCount in, ChanCount out); - bool can_support_io_configuration (const ChanCount& in, ChanCount& out) = 0; - ChanCount input_streams () const { return _configured_input; } - ChanCount output_streams() const { return _configured_output; } - - virtual void realtime_handle_transport_stopped () {} - virtual void realtime_locate () {} + enum Flag { + Recordable = 0x1, + Hidden = 0x2, + Destructive = 0x4, + NonLayered = 0x8 + }; - /* note: derived classes should implement state(), NOT get_state(), to allow - us to merge C++ inheritance and XML lack-of-inheritance reasonably - smoothly. - */ - - virtual XMLNode& state (bool full); - XMLNode& get_state (void); - int set_state (const XMLNode&, int version); + static const std::string state_node_name; - static framecnt_t disk_read_frames() { return disk_read_chunk_frames; } - static framecnt_t disk_write_frames() { return disk_write_chunk_frames; } - static void set_disk_read_chunk_frames (framecnt_t n) { disk_read_chunk_frames = n; } - static void set_disk_write_chunk_frames (framecnt_t n) { disk_write_chunk_frames = n; } - static framecnt_t default_disk_read_chunk_frames (); - static framecnt_t default_disk_write_chunk_frames (); + DiskIOProcessor (Session&, const std::string& name, Flag f); static void set_buffering_parameters (BufferingPreset bp); -protected: - static framecnt_t disk_read_chunk_frames; - static framecnt_t disk_write_chunk_frames; - - uint32_t i_am_the_modifier; + /** @return A number between 0 and 1, where 0 indicates that the playback buffer + * is dry (ie the disk subsystem could not keep up) and 1 indicates that the + * buffer is full. + */ + virtual float playback_buffer_load() const = 0; + virtual float capture_buffer_load() const = 0; - Track* _track; - ChanCount _n_channels; + void set_flag (Flag f) { _flags = Flag (_flags | f); } + void unset_flag (Flag f) { _flags = Flag (_flags & ~f); } - double _visible_speed; - double _actual_speed; - /* items needed for speed change logic */ - bool _buffer_reallocation_required; - bool _seek_required; - bool _slaved; - Location* loop_location; - double _speed; - double _target_speed; - bool in_set_state; + bool hidden() const { return _flags & Hidden; } + bool recordable() const { return _flags & Recordable; } + bool non_layered() const { return _flags & NonLayered; } + bool reversed() const { return _actual_speed < 0.0f; } + double speed() const { return _visible_speed; } - Glib::Threads::Mutex state_lock; - Flag _flags; -}; + ChanCount n_channels() { return _n_channels; } -class LIBARDOUR_API DiskReader : public DiskIOProcessor -{ - public: - DiskReader (Session&, std::string const & name); - ~DiskReader (); + void non_realtime_set_speed (); + bool realtime_set_speed (double sp, bool global); - private: - boost::shared_ptr<Playlist> _playlist; + virtual void punch_in() {} + virtual void punch_out() {} - framepos_t overwrite_frame; - off_t overwrite_offset; - bool _pending_overwrite; - bool overwrite_queued; - IOChange input_change_pending; - framecnt_t wrap_buffer_size; - framecnt_t speed_buffer_size; + virtual float buffer_load() const = 0; - double _speed; - double _target_speed; + bool slaved() const { return _slaved; } + void set_slaved(bool yn) { _slaved = yn; } - /** The next frame position that we should be reading from in our playlist */ - framepos_t file_frame; - framepos_t playback_sample; + int set_loop (Location *loc); - PBD::ScopedConnectionList playlist_connections; - PBD::ScopedConnection ic_connection; -}; + PBD::Signal1<void,Location *> LoopSet; + PBD::Signal0<void> SpeedChanged; + PBD::Signal0<void> ReverseChanged; -class LIBARDOUR_API DiskWriter : public DiskIOProcessor -{ - public: - DiskWriter (Session&, std::string const & name); - ~DiskWriter (); + int set_state (const XMLNode&, int version); - private: - std::vector<CaptureInfo*> capture_info; - mutable Glib::Threads::Mutex capture_info_lock; + protected: + friend class Auditioner; + virtual int seek (framepos_t which_sample, bool complete_refill = false) = 0; + protected: + Flag _flags; + uint32_t i_am_the_modifier; + ChanCount _n_channels; double _visible_speed; double _actual_speed; + double _speed; + double _target_speed; /* items needed for speed change logic */ bool _buffer_reallocation_required; bool _seek_required; - - /** Start of currently running capture in session frames */ - framepos_t capture_start_frame; - framecnt_t capture_captured; - bool was_recording; - framecnt_t adjust_capture_position; - framecnt_t _capture_offset; - framepos_t first_recordable_frame; - framepos_t last_recordable_frame; - int last_possibly_recording; - AlignStyle _alignment_style; - AlignChoice _alignment_choice; + bool _slaved; + Location* loop_location; + bool in_set_state; framecnt_t wrap_buffer_size; framecnt_t speed_buffer_size; - std::string _write_source_name; + Glib::Threads::Mutex state_lock; - PBD::ScopedConnection ic_connection; -}; + static bool get_buffering_presets (BufferingPreset bp, + framecnt_t& read_chunk_size, + framecnt_t& read_buffer_size, + framecnt_t& write_chunk_size, + framecnt_t& write_buffer_size); + virtual void allocate_temporary_buffers () = 0; +}; } // namespace ARDOUR -#endif /* __ardour_processor_h__ */ +#endif /* __ardour_disk_io_h__ */ |