summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-02-16 18:08:22 +0000
committerDavid Robillard <d@drobilla.net>2009-02-16 18:08:22 +0000
commit900309993c485527145be4265247bd521073ee61 (patch)
tree29360e453ffe3f7b4c099a199cb2d5d587d14580
parent80e3845982659b796315a501268478c63ae2f21a (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
-rw-r--r--gtk2_ardour/editor_audio_import.cc12
-rw-r--r--gtk2_ardour/editor_ops.cc1
-rw-r--r--gtk2_ardour/editor_region_list.cc1
-rw-r--r--gtk2_ardour/sfdb_ui.cc5
-rw-r--r--libs/ardour/ardour/audiofilesource.h81
-rw-r--r--libs/ardour/ardour/audiosource.h27
-rw-r--r--libs/ardour/ardour/midi_source.h2
-rw-r--r--libs/ardour/ardour/smf_source.h13
-rw-r--r--libs/ardour/ardour/sndfilesource.h2
-rw-r--r--libs/ardour/ardour/source.h18
-rw-r--r--libs/ardour/ardour/source_factory.h20
-rw-r--r--libs/ardour/audiofilesource.cc33
-rw-r--r--libs/ardour/coreaudiosource.cc3
-rw-r--r--libs/ardour/enums.cc20
-rw-r--r--libs/ardour/midi_source.cc4
-rw-r--r--libs/ardour/smf_source.cc4
-rw-r--r--libs/ardour/sndfilesource.cc29
-rw-r--r--libs/ardour/source.cc19
-rw-r--r--libs/ardour/source_factory.cc16
19 files changed, 146 insertions, 164 deletions
diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc
index d6246f15fc..b36d1a314e 100644
--- a/gtk2_ardour/editor_audio_import.cc
+++ b/gtk2_ardour/editor_audio_import.cc
@@ -671,12 +671,12 @@ Editor::embed_sndfiles (vector<Glib::ustring> paths, bool multifile,
if ((s = session->source_by_path_and_channel (path, n)) == 0) {
- source = boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createReadable
- (DataType::AUDIO, *session, path, n,
- (mode == ImportAsTapeTrack ?
- AudioFileSource::Destructive :
- AudioFileSource::Flag (0)),
- true, true));
+ source = boost::dynamic_pointer_cast<AudioFileSource> (
+ SourceFactory::createReadable (DataType::AUDIO, *session, path, n,
+ (mode == ImportAsTapeTrack
+ ? Source::Destructive
+ : Source::Flag (0)),
+ true, true));
} else {
source = boost::dynamic_pointer_cast<AudioFileSource> (s);
}
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index bf1e74706d..2ccfcd40b1 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -47,7 +47,6 @@
#include <ardour/location.h>
#include <ardour/named_selection.h>
#include <ardour/audio_track.h>
-#include <ardour/audiofilesource.h>
#include <ardour/audioplaylist.h>
#include <ardour/region_factory.h>
#include <ardour/playlist_factory.h>
diff --git a/gtk2_ardour/editor_region_list.cc b/gtk2_ardour/editor_region_list.cc
index 93457e68a2..694d9033dc 100644
--- a/gtk2_ardour/editor_region_list.cc
+++ b/gtk2_ardour/editor_region_list.cc
@@ -31,7 +31,6 @@
#include <ardour/session_region.h>
#include <ardour/profile.h>
-
#include <gtkmm2ext/stop_signal.h>
#include "editor.h"
diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc
index a3b3a52925..141ce51a9c 100644
--- a/gtk2_ardour/sfdb_ui.cc
+++ b/gtk2_ardour/sfdb_ui.cc
@@ -331,8 +331,9 @@ SoundFileBox::audition ()
for (int n = 0; n < sf_info.channels; ++n) {
try {
- afs = boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createReadable (DataType::AUDIO, *_session, path,
- n, AudioFileSource::Flag (0), false));
+ afs = boost::dynamic_pointer_cast<AudioFileSource> (
+ SourceFactory::createReadable (DataType::AUDIO, *_session, path,
+ n, Source::Flag (0), false));
srclist.push_back(afs);
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);
};
diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc
index 9ac63c21fb..434b64e88d 100644
--- a/libs/ardour/audiofilesource.cc
+++ b/libs/ardour/audiofilesource.cc
@@ -87,9 +87,9 @@ struct SizedSampleBuffer {
Glib::StaticPrivate<SizedSampleBuffer> thread_interleave_buffer = GLIBMM_STATIC_PRIVATE_INIT;
/** Constructor used for existing internal-to-session files. File must exist. */
-AudioFileSource::AudioFileSource (Session& s, ustring path, Flag flags)
- : AudioSource (s, path), _flags (flags),
- _channel (0)
+AudioFileSource::AudioFileSource (Session& s, ustring path, Source::Flag flags)
+ : AudioSource (s, path)
+ , _channel (0)
{
_is_embedded = AudioFileSource::determine_embeddedness (path);
@@ -100,9 +100,10 @@ AudioFileSource::AudioFileSource (Session& s, ustring path, Flag flags)
}
/** Constructor used for new internal-to-session files. File cannot exist. */
-AudioFileSource::AudioFileSource (Session& s, ustring path, Flag flags, SampleFormat samp_format, HeaderFormat hdr_format)
- : AudioSource (s, path), _flags (flags),
- _channel (0)
+AudioFileSource::AudioFileSource (Session& s, ustring path, Source::Flag flags,
+ SampleFormat samp_format, HeaderFormat hdr_format)
+ : AudioSource (s, path)
+ , _channel (0)
{
_is_embedded = false;
@@ -113,7 +114,7 @@ AudioFileSource::AudioFileSource (Session& s, ustring path, Flag flags, SampleFo
/** Constructor used for existing internal-to-session files. File must exist. */
AudioFileSource::AudioFileSource (Session& s, const XMLNode& node, bool must_exist)
- : AudioSource (s, node), _flags (Flag (Writable|CanRename))
+ : AudioSource (s, node)
/* _channel is set in set_state() or init() */
{
if (set_state (node)) {
@@ -151,14 +152,14 @@ int
AudioFileSource::init (ustring pathstr, bool must_exist)
{
_length = 0;
- timeline_position = 0;
+ _timeline_position = 0;
_peaks_built = false;
- if (!find (pathstr, must_exist, file_is_new, _channel)) {
+ if (!find (pathstr, must_exist, _file_is_new, _channel)) {
throw non_existent_source ();
}
- if (file_is_new && must_exist) {
+ if (_file_is_new && must_exist) {
return -1;
}
@@ -273,7 +274,6 @@ AudioFileSource::get_state ()
{
XMLNode& root (AudioSource::get_state());
char buf[32];
- root.add_property (X_("flags"), enum_2_string (_flags));
snprintf (buf, sizeof (buf), "%u", _channel);
root.add_property (X_("channel"), buf);
return root;
@@ -288,13 +288,6 @@ AudioFileSource::set_state (const XMLNode& node)
return -1;
}
- if ((prop = node.property (X_("flags"))) != 0) {
- _flags = Flag (string_2_enum (prop->value(), _flags));
- } else {
- _flags = Flag (0);
-
- }
-
if ((prop = node.property (X_("channel"))) != 0) {
_channel = atoi (prop->value());
} else {
@@ -614,7 +607,7 @@ AudioFileSource::set_header_position_offset (nframes_t offset)
void
AudioFileSource::set_timeline_position (int64_t pos)
{
- timeline_position = pos;
+ _timeline_position = pos;
}
void
@@ -678,7 +671,7 @@ int
AudioFileSource::setup_peakfile ()
{
if (!(_flags & NoPeakFile)) {
- return initialize_peakfile (file_is_new, _path);
+ return initialize_peakfile (_file_is_new, _path);
} else {
return 0;
}
diff --git a/libs/ardour/coreaudiosource.cc b/libs/ardour/coreaudiosource.cc
index a6aceb7842..18b9a82ec6 100644
--- a/libs/ardour/coreaudiosource.cc
+++ b/libs/ardour/coreaudiosource.cc
@@ -45,7 +45,8 @@ CoreAudioSource::CoreAudioSource (Session& s, const XMLNode& node)
CoreAudioSource::CoreAudioSource (Session& s, const string& path, int chn, Flag flags)
/* files created this way are never writable or removable */
- : AudioFileSource (s, path, Flag (flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy)))
+ : AudioFileSource (s, path,
+ Source::Flag (flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy)))
{
_channel = chn;
init ();
diff --git a/libs/ardour/enums.cc b/libs/ardour/enums.cc
index 0c307d0605..48a78fe508 100644
--- a/libs/ardour/enums.cc
+++ b/libs/ardour/enums.cc
@@ -83,7 +83,7 @@ setup_enum_writer ()
AutoConnectOption _AutoConnectOption;
Session::StateOfTheState _Session_StateOfTheState;
Route::Flag _Route_Flag;
- AudioFileSource::Flag _AudioFileSource_Flag;
+ Source::Flag _Source_Flag;
Diskstream::Flag _Diskstream_Flag;
Location::Flags _Location_Flags;
RouteGroup::Flag _RouteGroup_Flag;
@@ -336,15 +336,15 @@ setup_enum_writer ()
REGISTER_CLASS_ENUM (Route, ControlOut);
REGISTER_BITS (_Route_Flag);
- REGISTER_CLASS_ENUM (AudioFileSource, Writable);
- REGISTER_CLASS_ENUM (AudioFileSource, CanRename);
- REGISTER_CLASS_ENUM (AudioFileSource, Broadcast);
- REGISTER_CLASS_ENUM (AudioFileSource, Removable);
- REGISTER_CLASS_ENUM (AudioFileSource, RemovableIfEmpty);
- REGISTER_CLASS_ENUM (AudioFileSource, RemoveAtDestroy);
- REGISTER_CLASS_ENUM (AudioFileSource, NoPeakFile);
- REGISTER_CLASS_ENUM (AudioFileSource, Destructive);
- REGISTER_BITS (_AudioFileSource_Flag);
+ REGISTER_CLASS_ENUM (Source, Writable);
+ REGISTER_CLASS_ENUM (Source, CanRename);
+ REGISTER_CLASS_ENUM (Source, Broadcast);
+ REGISTER_CLASS_ENUM (Source, Removable);
+ REGISTER_CLASS_ENUM (Source, RemovableIfEmpty);
+ REGISTER_CLASS_ENUM (Source, RemoveAtDestroy);
+ REGISTER_CLASS_ENUM (Source, NoPeakFile);
+ REGISTER_CLASS_ENUM (Source, Destructive);
+ REGISTER_BITS (_Source_Flag);
REGISTER_CLASS_ENUM (AudioRegion, Linear);
REGISTER_CLASS_ENUM (AudioRegion, Fast);
diff --git a/libs/ardour/midi_source.cc b/libs/ardour/midi_source.cc
index ece0d9b104..03208eda02 100644
--- a/libs/ardour/midi_source.cc
+++ b/libs/ardour/midi_source.cc
@@ -49,8 +49,8 @@ using namespace PBD;
sigc::signal<void,MidiSource *> MidiSource::MidiSourceCreated;
-MidiSource::MidiSource (Session& s, string name)
- : Source (s, name, DataType::MIDI)
+MidiSource::MidiSource (Session& s, string name, Source::Flag flags)
+ : Source (s, name, DataType::MIDI, flags)
, _timeline_position(0)
, _read_data_count(0)
, _write_data_count(0)
diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc
index ab0c290191..d87293faed 100644
--- a/libs/ardour/smf_source.cc
+++ b/libs/ardour/smf_source.cc
@@ -49,10 +49,9 @@ using namespace ARDOUR;
string SMFSource::_search_path;
/** Constructor used for new internal-to-session files. File cannot exist. */
-SMFSource::SMFSource(Session& s, std::string path, Flag flags)
+SMFSource::SMFSource(Session& s, std::string path, Source::Flag flags)
: MidiSource(s, region_name_from_path(path, false))
, Evoral::SMF()
- , _flags(flags)
, _allow_remove_if_empty(true)
, _last_ev_time_beats(0.0)
, _last_ev_time_frames(0)
@@ -71,7 +70,6 @@ SMFSource::SMFSource(Session& s, std::string path, Flag flags)
/** Constructor used for existing internal-to-session files. File must exist. */
SMFSource::SMFSource(Session& s, const XMLNode& node)
: MidiSource(s, node)
- , _flags(Flag(Writable|CanRename))
, _allow_remove_if_empty(true)
, _last_ev_time_beats(0.0)
, _last_ev_time_frames(0)
diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc
index b35d36a713..8d89f2aa92 100644
--- a/libs/ardour/sndfilesource.cc
+++ b/libs/ardour/sndfilesource.cc
@@ -43,10 +43,11 @@ using Glib::ustring;
gain_t* SndFileSource::out_coefficient = 0;
gain_t* SndFileSource::in_coefficient = 0;
nframes_t SndFileSource::xfade_frames = 64;
-const AudioFileSource::Flag SndFileSource::default_writable_flags = AudioFileSource::Flag (AudioFileSource::Writable|
- AudioFileSource::Removable|
- AudioFileSource::RemovableIfEmpty|
- AudioFileSource::CanRename);
+const Source::Flag SndFileSource::default_writable_flags = Source::Flag (
+ Source::Writable |
+ Source::Removable |
+ Source::RemovableIfEmpty |
+ Source::CanRename );
SndFileSource::SndFileSource (Session& s, const XMLNode& node)
: AudioFileSource (s, node)
@@ -82,7 +83,7 @@ SndFileSource::SndFileSource (Session& s, ustring path, SampleFormat sfmt, Heade
existing ones.
*/
- file_is_new = true;
+ _file_is_new = true;
switch (hf) {
case CAF:
@@ -187,7 +188,7 @@ SndFileSource::init ()
if (destructive()) {
xfade_buf = new Sample[xfade_frames];
- timeline_position = header_position_offset;
+ _timeline_position = header_position_offset;
}
AudioFileSource::HeaderPositionOffsetChanged.connect (mem_fun (*this, &SndFileSource::handle_header_position_change));
@@ -405,7 +406,7 @@ SndFileSource::destructive_write_unlocked (Sample* data, nframes_t cnt)
_capture_end = false;
/* move to the correct location place */
- file_pos = capture_start_frame - timeline_position;
+ file_pos = capture_start_frame - _timeline_position;
// split cnt in half
nframes_t subcnt = cnt / 2;
@@ -437,7 +438,7 @@ SndFileSource::destructive_write_unlocked (Sample* data, nframes_t cnt)
_capture_end = false;
/* move to the correct location place */
- file_pos = capture_start_frame - timeline_position;
+ file_pos = capture_start_frame - _timeline_position;
if (crossfade (data, cnt, 1) != cnt) {
return 0;
@@ -539,7 +540,7 @@ SndFileSource::set_header_timeline_position ()
return;
}
- _broadcast_info->set_time_reference (timeline_position);
+ _broadcast_info->set_time_reference (_timeline_position);
if (!_broadcast_info->write_to_file (sf)) {
error << string_compose (_("cannot set broadcast info for audio file %1 (%2); dropping broadcast info for this file"),
@@ -571,7 +572,7 @@ SndFileSource::write_float (Sample* data, nframes_t frame_pos, nframes_t cnt)
nframes_t
SndFileSource::natural_position() const
{
- return timeline_position;
+ return _timeline_position;
}
bool
@@ -583,10 +584,10 @@ SndFileSource::set_destructive (bool yn)
xfade_buf = new Sample[xfade_frames];
}
clear_capture_marks ();
- timeline_position = header_position_offset;
+ _timeline_position = header_position_offset;
} else {
_flags = Flag (_flags & ~Destructive);
- timeline_position = 0;
+ _timeline_position = 0;
/* leave xfade buf alone in case we need it again later */
}
@@ -604,7 +605,7 @@ void
SndFileSource::mark_capture_start (nframes_t pos)
{
if (destructive()) {
- if (pos < timeline_position) {
+ if (pos < _timeline_position) {
_capture_start = false;
} else {
_capture_start = true;
@@ -762,7 +763,7 @@ SndFileSource::handle_header_position_change ()
error << string_compose(_("Filesource: start time is already set for existing file (%1): Cannot change start time."), _path ) << endmsg;
//in the future, pop up a dialog here that allows user to regenerate file with new start offset
} else if (writable()) {
- timeline_position = header_position_offset;
+ _timeline_position = header_position_offset;
set_header_timeline_position (); //this will get flushed if/when the file is recorded to
}
}
diff --git a/libs/ardour/source.cc b/libs/ardour/source.cc
index f08d08b86e..aaae432570 100644
--- a/libs/ardour/source.cc
+++ b/libs/ardour/source.cc
@@ -34,10 +34,11 @@
#include <glibmm/fileutils.h>
#include <pbd/xml++.h>
#include <pbd/pthread_utils.h>
+#include <pbd/enumwriter.h>
-#include <ardour/source.h>
#include <ardour/playlist.h>
#include <ardour/session.h>
+#include <ardour/source.h>
#include <ardour/transient_detector.h>
#include "i18n.h"
@@ -45,13 +46,11 @@
using namespace std;
using namespace ARDOUR;
-Source::Source (Session& s, const string& name, DataType type)
+Source::Source (Session& s, const string& name, DataType type, Flag flags)
: SessionObject(s, name)
, _type(type)
+ , _flags(flags)
{
- // not true.. is this supposed to be an assertion?
- //assert(_name.find("/") == string::npos);
-
_analysed = false;
_timestamp = 0;
_length = 0;
@@ -61,6 +60,7 @@ Source::Source (Session& s, const string& name, DataType type)
Source::Source (Session& s, const XMLNode& node)
: SessionObject(s, "unnamed source")
, _type(DataType::AUDIO)
+ , _flags (Flag (Writable|CanRename))
{
_timestamp = 0;
_length = 0;
@@ -85,6 +85,7 @@ Source::get_state ()
node->add_property ("name", _name);
node->add_property ("type", _type.to_string());
+ node->add_property (X_("flags"), enum_2_string (_flags));
_id.print (buf, sizeof (buf));
node->add_property ("id", buf);
@@ -121,8 +122,12 @@ Source::set_state (const XMLNode& node)
sscanf (prop->value().c_str(), "%ld", &_timestamp);
}
- // Don't think this is valid, absolute paths fail
- //assert(_name.find("/") == string::npos);
+ if ((prop = node.property (X_("flags"))) != 0) {
+ _flags = Flag (string_2_enum (prop->value(), _flags));
+ } else {
+ _flags = Flag (0);
+
+ }
return 0;
}
diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc
index 4ada6b766c..2d2d6917bd 100644
--- a/libs/ardour/source_factory.cc
+++ b/libs/ardour/source_factory.cc
@@ -179,7 +179,7 @@ SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks)
}
boost::shared_ptr<Source>
-SourceFactory::createReadable (DataType type, Session& s, string path, int chn, AudioFileSource::Flag flags, bool announce, bool defer_peaks)
+SourceFactory::createReadable (DataType type, Session& s, string path, int chn, Source::Flag flags, bool announce, bool defer_peaks)
{
if (type == DataType::AUDIO) {
@@ -244,13 +244,13 @@ SourceFactory::createWritable (DataType type, Session& s, std::string path, bool
/* this might throw failed_constructor(), which is OK */
if (type == DataType::AUDIO) {
- boost::shared_ptr<Source> ret (new SndFileSource
- (s, path,
- Config->get_native_file_data_format(),
- Config->get_native_file_header_format(),
- rate,
- (destructive ? AudioFileSource::Flag (SndFileSource::default_writable_flags | AudioFileSource::Destructive) :
- SndFileSource::default_writable_flags)));
+ boost::shared_ptr<Source> ret (new SndFileSource (s, path,
+ Config->get_native_file_data_format(),
+ Config->get_native_file_header_format(),
+ rate,
+ (destructive
+ ? Source::Flag (SndFileSource::default_writable_flags | Source::Destructive)
+ : SndFileSource::default_writable_flags)));
if (setup_peakfile (ret, defer_peaks)) {
return boost::shared_ptr<Source>();