From 900309993c485527145be4265247bd521073ee61 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 16 Feb 2009 18:08:22 +0000 Subject: 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 --- libs/ardour/ardour/audiofilesource.h | 81 +++++++++++++----------------------- libs/ardour/ardour/audiosource.h | 27 ++++++------ libs/ardour/ardour/midi_source.h | 2 +- libs/ardour/ardour/smf_source.h | 13 +----- libs/ardour/ardour/sndfilesource.h | 2 +- libs/ardour/ardour/source.h | 18 +++++++- libs/ardour/ardour/source_factory.h | 20 +++++---- 7 files changed, 74 insertions(+), 89 deletions(-) (limited to 'libs/ardour/ardour') 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 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 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, sigc::connection&) const; @@ -126,7 +126,8 @@ class AudioSource : public Source, public boost::enable_shared_from_this 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); @@ -95,9 +106,12 @@ class Source : public SessionObject, public ARDOUR::Readable virtual const Evoral::TimeConverter& time_converter() const { return Evoral::IdentityConverter(); } + + 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 #include -#include class XMLNode; namespace ARDOUR { class Session; +class AudioSource; class SourceFactory { public: @@ -41,16 +41,18 @@ class SourceFactory { static sigc::signal > SourceCreated; static boost::shared_ptr create (Session&, const XMLNode& node, bool async = false); - static boost::shared_ptr createSilent (Session&, const XMLNode& node, nframes_t nframes, float sample_rate); + static boost::shared_ptr createSilent (Session&, const XMLNode& node, + nframes_t nframes, float sample_rate); - static boost::shared_ptr createReadable (DataType type, Session&, std::string path, int chn, AudioFileSource::Flag flags, - bool announce = true, bool async = false); - static boost::shared_ptr createWritable (DataType type, Session&, std::string name, bool destructive, nframes_t rate, - bool announce = true, bool async = false); + static boost::shared_ptr 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 > files_with_peaks; + static boost::shared_ptr 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 > files_with_peaks; static int setup_peakfile (boost::shared_ptr, bool async); }; -- cgit v1.2.3