diff options
author | David Robillard <d@drobilla.net> | 2009-02-16 18:08:22 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-02-16 18:08:22 +0000 |
commit | 900309993c485527145be4265247bd521073ee61 (patch) | |
tree | 29360e453ffe3f7b4c099a199cb2d5d587d14580 /libs/ardour/ardour | |
parent | 80e3845982659b796315a501268478c63ae2f21a (diff) |
Move duplicated AudioFileSource::Flags and SMFSource::Flags into Source.
Clean up source stuff.
git-svn-id: svn://localhost/ardour2/branches/3.0@4605 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r-- | libs/ardour/ardour/audiofilesource.h | 81 | ||||
-rw-r--r-- | libs/ardour/ardour/audiosource.h | 27 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_source.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/smf_source.h | 13 | ||||
-rw-r--r-- | libs/ardour/ardour/sndfilesource.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/source.h | 18 | ||||
-rw-r--r-- | libs/ardour/ardour/source_factory.h | 20 |
7 files changed, 74 insertions, 89 deletions
diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h index de388a06fc..249651c3cf 100644 --- a/libs/ardour/ardour/audiofilesource.h +++ b/libs/ardour/ardour/audiofilesource.h @@ -43,20 +43,11 @@ struct SoundFileInfo { class AudioFileSource : public AudioSource { public: - enum Flag { - Writable = 0x1, - CanRename = 0x2, - Broadcast = 0x4, - Removable = 0x8, - RemovableIfEmpty = 0x10, - RemoveAtDestroy = 0x20, - NoPeakFile = 0x40, - Destructive = 0x80 - }; - virtual ~AudioFileSource (); - bool set_name (const std::string& newname) { return (set_source_name(newname, destructive()) == 0); } + bool set_name (const std::string& newname) { + return (set_source_name(newname, destructive()) == 0); + } int set_source_name (Glib::ustring newname, bool destructive); Glib::ustring path() const { return _path; } @@ -78,7 +69,6 @@ class AudioFileSource : public AudioSource { /* this block of methods do nothing for regular file sources, but are significant for files used in destructive recording. */ - virtual nframes_t last_capture_start_frame() const { return 0; } virtual void mark_capture_start (nframes_t) {} virtual void mark_capture_end () {} @@ -93,7 +83,7 @@ class AudioFileSource : public AudioSource { static bool is_empty (Session&, Glib::ustring path); void mark_streaming_write_completed (); - void mark_take (Glib::ustring); + void mark_take (Glib::ustring); Glib::ustring take_id() const { return _take_id; } bool is_embedded() const { return _is_embedded; } @@ -105,54 +95,50 @@ class AudioFileSource : public AudioSource { int setup_peakfile (); - static sigc::signal<void> HeaderPositionOffsetChanged; - XMLNode& get_state (); int set_state (const XMLNode&); - bool destructive() const { return (_flags & Destructive); } - virtual bool set_destructive (bool yn) { return false; } - bool can_truncate_peaks() const { return !destructive(); } - - Flag flags() const { return _flags; } + bool destructive() const { return (_flags & Destructive); } + virtual bool set_destructive (bool yn) { return false; } + bool can_truncate_peaks() const { return !destructive(); } + bool can_be_analysed() const { return _length > 0; } void mark_immutable (); - - /* this should really be protected, but C++ is getting stricter - and creating slots from protected member functions is starting - to cause issues. - */ - - virtual void handle_header_position_change () {} - - bool can_be_analysed() const { return _length > 0; } + + static sigc::signal<void> HeaderPositionOffsetChanged; protected: - /* constructor to be called for existing external-to-session files */ - - AudioFileSource (Session&, Glib::ustring path, Flag flags); - - /* constructor to be called for new in-session files */ + /** Constructor to be called for existing external-to-session files */ + AudioFileSource (Session&, Glib::ustring path, Source::Flag flags); - AudioFileSource (Session&, Glib::ustring path, Flag flags, + /** Constructor to be called for new in-session files */ + AudioFileSource (Session&, Glib::ustring path, Source::Flag flags, SampleFormat samp_format, HeaderFormat hdr_format); - /* constructor to be called for existing in-session files */ - + /** Constructor to be called for existing in-session files */ AudioFileSource (Session&, const XMLNode&, bool must_exit = true); int init (Glib::ustring idstr, bool must_exist); + + static bool determine_embeddedness (Glib::ustring path); + + virtual void set_timeline_position (int64_t pos); + virtual void set_header_timeline_position () = 0; + virtual void handle_header_position_change () {} + + bool find (Glib::ustring& path, bool must_exist, bool& is_new, uint16_t& chan); + bool removable() const; + bool writable() const { return _flags & Writable; } + + static Sample* get_interleave_buffer (nframes_t size); Glib::ustring _path; - Flag _flags; Glib::ustring _take_id; - int64_t timeline_position; - bool file_is_new; + int64_t _timeline_position; + bool _file_is_new; uint16_t _channel; - bool _is_embedded; - static bool determine_embeddedness(Glib::ustring path); static Glib::ustring peak_dir; static Glib::ustring search_path; @@ -163,15 +149,6 @@ class AudioFileSource : public AudioSource { static uint64_t header_position_offset; - virtual void set_timeline_position (int64_t pos); - virtual void set_header_timeline_position () = 0; - - bool find (Glib::ustring& path, bool must_exist, bool& is_new, uint16_t& chan); - bool removable() const; - bool writable() const { return _flags & Writable; } - - static Sample* get_interleave_buffer (nframes_t size); - private: Glib::ustring old_peak_path (Glib::ustring audio_path); Glib::ustring broken_peak_path (Glib::ustring audio_path); diff --git a/libs/ardour/ardour/audiosource.h b/libs/ardour/ardour/audiosource.h index d11b829694..43273301b1 100644 --- a/libs/ardour/ardour/audiosource.h +++ b/libs/ardour/ardour/audiosource.h @@ -51,12 +51,11 @@ class AudioSource : public Source, public boost::enable_shared_from_this<ARDOUR: virtual ~AudioSource (); nframes64_t readable_length() const { return _length; } - uint32_t n_channels() const { return 1; } + uint32_t n_channels() const { return 1; } virtual nframes_t available_peaks (double zoom) const; - /* stopgap until nframes_t becomes nframes64_t. this function is needed by the Readable interface */ - + /** Stopgap for Readable until nframes_t becomes nframes64_t. */ virtual nframes64_t read (Sample *dst, nframes64_t start, nframes64_t cnt, int channel) const { /* XXX currently ignores channel, assuming that source is always mono, which historically has been true. @@ -80,7 +79,8 @@ class AudioSource : public Source, public boost::enable_shared_from_this<ARDOUR: uint32_t read_data_count() const { return _read_data_count; } uint32_t write_data_count() const { return _write_data_count; } - int read_peaks (PeakData *peaks, nframes_t npeaks, nframes_t start, nframes_t cnt, double samples_per_visual_peak) const; + int read_peaks (PeakData *peaks, nframes_t npeaks, + nframes_t start, nframes_t cnt, double samples_per_visual_peak) const; int build_peaks (); bool peaks_ready (sigc::slot<void>, sigc::connection&) const; @@ -126,7 +126,8 @@ class AudioSource : public Source, public boost::enable_shared_from_this<ARDOUR: int initialize_peakfile (bool newfile, Glib::ustring path); int build_peaks_from_scratch (); - int compute_and_write_peaks (Sample* buf, nframes_t first_frame, nframes_t cnt, bool force, bool intermediate_peaks_ready_signal); + int compute_and_write_peaks (Sample* buf, nframes_t first_frame, nframes_t cnt, + bool force, bool intermediate_peaks_ready_signal); void truncate_peakfile(); mutable off_t _peak_byte_max; // modified in compute_and_write_peak() @@ -134,21 +135,23 @@ class AudioSource : public Source, public boost::enable_shared_from_this<ARDOUR: virtual nframes_t read_unlocked (Sample *dst, nframes_t start, nframes_t cnt) const = 0; virtual nframes_t write_unlocked (Sample *dst, nframes_t cnt) = 0; virtual Glib::ustring peak_path(Glib::ustring audio_path) = 0; - virtual Glib::ustring find_broken_peakfile (Glib::ustring missing_peak_path, Glib::ustring audio_path) = 0; + virtual Glib::ustring find_broken_peakfile (Glib::ustring missing_peak_path, + Glib::ustring audio_path) = 0; void update_length (nframes_t pos, nframes_t cnt); - virtual int read_peaks_with_fpp (PeakData *peaks, nframes_t npeaks, nframes_t start, nframes_t cnt, - double samples_per_visual_peak, nframes_t fpp) const; + virtual int read_peaks_with_fpp (PeakData *peaks, + nframes_t npeaks, nframes_t start, nframes_t cnt, + double samples_per_visual_peak, nframes_t fpp) const; - int compute_and_write_peaks (Sample* buf, nframes_t first_frame, nframes_t cnt, bool force, - bool intermediate_peaks_ready_signal, nframes_t frames_per_peak); + int compute_and_write_peaks (Sample* buf, nframes_t first_frame, nframes_t cnt, + bool force, bool intermediate_peaks_ready_signal, nframes_t frames_per_peak); private: - int peakfile; + int peakfile; nframes_t peak_leftover_cnt; nframes_t peak_leftover_size; - Sample* peak_leftovers; + Sample* peak_leftovers; nframes_t peak_leftover_frame; bool file_changed (Glib::ustring path); diff --git a/libs/ardour/ardour/midi_source.h b/libs/ardour/ardour/midi_source.h index e19956ad7a..0dedb3282d 100644 --- a/libs/ardour/ardour/midi_source.h +++ b/libs/ardour/ardour/midi_source.h @@ -43,7 +43,7 @@ class MidiSource : public Source public: typedef double TimeType; - MidiSource (Session& session, std::string name); + MidiSource (Session& session, std::string name, Source::Flag flags = Source::Flag(0)); MidiSource (Session& session, const XMLNode&); virtual ~MidiSource (); diff --git a/libs/ardour/ardour/smf_source.h b/libs/ardour/ardour/smf_source.h index 6cbb449633..4855cb6e31 100644 --- a/libs/ardour/ardour/smf_source.h +++ b/libs/ardour/ardour/smf_source.h @@ -36,18 +36,8 @@ template<typename T> class MidiRingBuffer; /** Standard Midi File (Type 0) Source */ class SMFSource : public MidiSource, public Evoral::SMF { public: - enum Flag { - Writable = 0x1, - CanRename = 0x2, - Broadcast = 0x4, - Removable = 0x8, - RemovableIfEmpty = 0x10, - RemoveAtDestroy = 0x20, - BuildPeaks = 0x40 - }; - /** Constructor for existing external-to-session files */ - SMFSource (Session& session, std::string path, Flag flags = Flag(0)); + SMFSource (Session& session, std::string path, Source::Flag flags = Source::Flag(0)); /* Constructor for existing in-session files */ SMFSource (Session& session, const XMLNode&); @@ -107,7 +97,6 @@ class SMFSource : public MidiSource, public Evoral::SMF { void set_default_controls_interpolation(); Glib::ustring _path; - Flag _flags; string _take_id; bool _allow_remove_if_empty; double _last_ev_time_beats; diff --git a/libs/ardour/ardour/sndfilesource.h b/libs/ardour/ardour/sndfilesource.h index b7c7a9daf1..acb03391a4 100644 --- a/libs/ardour/ardour/sndfilesource.h +++ b/libs/ardour/ardour/sndfilesource.h @@ -60,7 +60,7 @@ class SndFileSource : public AudioFileSource { bool one_of_several_channels () const; static void setup_standard_crossfades (nframes_t sample_rate); - static const AudioFileSource::Flag default_writable_flags; + static const Source::Flag default_writable_flags; static int get_soundfile_info (const Glib::ustring& path, SoundFileInfo& _info, string& error_msg); diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h index b585509c51..137aad5fbe 100644 --- a/libs/ardour/ardour/source.h +++ b/libs/ardour/ardour/source.h @@ -40,7 +40,18 @@ class Playlist; class Source : public SessionObject, public ARDOUR::Readable { public: - Source (Session&, const std::string& name, DataType type); + enum Flag { + Writable = 0x1, + CanRename = 0x2, + Broadcast = 0x4, + Removable = 0x8, + RemovableIfEmpty = 0x10, + RemoveAtDestroy = 0x20, + NoPeakFile = 0x40, + Destructive = 0x80 + }; + + Source (Session&, const std::string& name, DataType type, Flag flags=Flag(0)); Source (Session&, const XMLNode&); virtual ~Source (); @@ -68,7 +79,7 @@ class Source : public SessionObject, public ARDOUR::Readable virtual bool destructive() const { return false; } virtual bool length_mutable() const { return false; } - void use () { _in_use++; } + void use () { _in_use++; } void disuse () { if (_in_use) { _in_use--; } } void add_playlist (boost::shared_ptr<ARDOUR::Playlist>); @@ -95,9 +106,12 @@ class Source : public SessionObject, public ARDOUR::Readable virtual const Evoral::TimeConverter<double, nframes_t>& time_converter() const { return Evoral::IdentityConverter<double, nframes_t>(); } + + Flag flags() const { return _flags; } protected: DataType _type; + Flag _flags; time_t _timestamp; nframes_t _length; bool _analysed; diff --git a/libs/ardour/ardour/source_factory.h b/libs/ardour/ardour/source_factory.h index 7e9be451e8..5370ad845d 100644 --- a/libs/ardour/ardour/source_factory.h +++ b/libs/ardour/ardour/source_factory.h @@ -26,13 +26,13 @@ #include <boost/shared_ptr.hpp> #include <ardour/source.h> -#include <ardour/audiofilesource.h> class XMLNode; namespace ARDOUR { class Session; +class AudioSource; class SourceFactory { public: @@ -41,16 +41,18 @@ class SourceFactory { static sigc::signal<void,boost::shared_ptr<Source> > SourceCreated; static boost::shared_ptr<Source> create (Session&, const XMLNode& node, bool async = false); - static boost::shared_ptr<Source> createSilent (Session&, const XMLNode& node, nframes_t nframes, float sample_rate); + static boost::shared_ptr<Source> createSilent (Session&, const XMLNode& node, + nframes_t nframes, float sample_rate); - static boost::shared_ptr<Source> createReadable (DataType type, Session&, std::string path, int chn, AudioFileSource::Flag flags, - bool announce = true, bool async = false); - static boost::shared_ptr<Source> createWritable (DataType type, Session&, std::string name, bool destructive, nframes_t rate, - bool announce = true, bool async = false); + static boost::shared_ptr<Source> createReadable (DataType type, Session&, std::string path, + int chn, Source::Flag flags, bool announce = true, bool async = false); - static Glib::Cond* PeaksToBuild; - static Glib::StaticMutex peak_building_lock; - static std::list<boost::weak_ptr<AudioSource> > files_with_peaks; + static boost::shared_ptr<Source> createWritable (DataType type, Session&, std::string name, + bool destructive, nframes_t rate, bool announce = true, bool async = false); + + static Glib::Cond* PeaksToBuild; + static Glib::StaticMutex peak_building_lock; + static std::list< boost::weak_ptr<AudioSource> > files_with_peaks; static int setup_peakfile (boost::shared_ptr<Source>, bool async); }; |