diff options
author | Ben Loftis <ben@harrisonconsoles.com> | 2018-11-15 09:21:31 -0600 |
---|---|---|
committer | Ben Loftis <ben@harrisonconsoles.com> | 2019-08-01 12:11:31 -0500 |
commit | ca3c191d7cf01712b961eec1aa7b0e979995e2a5 (patch) | |
tree | a2186e8f0fcf2db66203b73a00fd29700966c632 /libs | |
parent | 949450bbb5a3185c51d7e2f9114c4e20fc3e1f10 (diff) |
(Source List) Source property signals (libardour part)
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/audiosource.h | 3 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_source.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 12 | ||||
-rw-r--r-- | libs/ardour/ardour/source.h | 42 | ||||
-rw-r--r-- | libs/ardour/disk_writer.cc | 2 | ||||
-rw-r--r-- | libs/ardour/region.cc | 1 | ||||
-rw-r--r-- | libs/ardour/session.cc | 4 | ||||
-rw-r--r-- | libs/ardour/smf_source.cc | 3 | ||||
-rw-r--r-- | libs/ardour/source.cc | 19 |
9 files changed, 63 insertions, 25 deletions
diff --git a/libs/ardour/ardour/audiosource.h b/libs/ardour/ardour/audiosource.h index 6df4146259..524c5fa209 100644 --- a/libs/ardour/ardour/audiosource.h +++ b/libs/ardour/ardour/audiosource.h @@ -39,8 +39,7 @@ namespace ARDOUR { class LIBARDOUR_API AudioSource : virtual public Source, - public ARDOUR::Readable, - public boost::enable_shared_from_this<ARDOUR::AudioSource> + public ARDOUR::Readable { public: AudioSource (Session&, const std::string& name); diff --git a/libs/ardour/ardour/midi_source.h b/libs/ardour/ardour/midi_source.h index 4d6c5689f5..370572ea7e 100644 --- a/libs/ardour/ardour/midi_source.h +++ b/libs/ardour/ardour/midi_source.h @@ -43,7 +43,7 @@ class MidiStateTracker; template<typename T> class MidiRingBuffer; /** Source for MIDI data */ -class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_shared_from_this<MidiSource> +class LIBARDOUR_API MidiSource : virtual public Source { public: typedef Temporal::Beats TimeType; diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 45dfb6fcff..0453994d33 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1754,8 +1754,20 @@ private: mutable Glib::Threads::Mutex source_lock; public: + + /* Emited when a new source is added to the session */ + PBD::Signal1< void, boost::shared_ptr<Source> > SourceAdded; + PBD::Signal1< void, boost::shared_ptr<Source> > SourceRemoved; + typedef std::map<PBD::ID,boost::shared_ptr<Source> > SourceMap; + void foreach_source (boost::function<void( boost::shared_ptr<Source> )> f) { + Glib::Threads::Mutex::Lock ls (source_lock); + for (SourceMap::iterator i = sources.begin(); i != sources.end(); ++i) { + f ( (*i).second ); + } + } + private: void reset_write_sources (bool mark_write_complete, bool force = false); SourceMap sources; diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h index e3a386b97a..d6ed19b610 100644 --- a/libs/ardour/ardour/source.h +++ b/libs/ardour/ardour/source.h @@ -25,6 +25,8 @@ #include <glibmm/threads.h> +#include <boost/shared_ptr.hpp> +#include <boost/enable_shared_from_this.hpp> #include <boost/utility.hpp> #include "pbd/statefuldestructible.h" @@ -36,7 +38,8 @@ namespace ARDOUR { class Session; -class LIBARDOUR_API Source : public SessionObject +class LIBARDOUR_API Source : public SessionObject, + public boost::enable_shared_from_this<ARDOUR::Source> { public: enum Flag { @@ -117,25 +120,24 @@ public: uint32_t level() const { return _level; } std::string ancestor_name() { return _ancestor_name.empty() ? name() : _ancestor_name; } - void set_ancestor_name(const std::string& name) { _ancestor_name = name; } - -protected: - DataType _type; - Flag _flags; - time_t _timestamp; - std::string _take_id; - samplepos_t _timeline_position; - bool _analysed; - - mutable Glib::Threads::Mutex _lock; - mutable Glib::Threads::Mutex _analysis_lock; - - gint _use_count; /* atomic */ - uint32_t _level; /* how deeply nested is this source w.r.t a disk file */ - std::string _ancestor_name; - -private: - + void set_ancestor_name(const std::string& name) { _ancestor_name = name; } + + static PBD::Signal1<void,boost::shared_ptr<ARDOUR::Source> > SourcePropertyChanged; + + protected: + DataType _type; + Flag _flags; + time_t _timestamp; + std::string _take_id; + samplepos_t _timeline_position; + bool _analysed; + mutable Glib::Threads::Mutex _lock; + mutable Glib::Threads::Mutex _analysis_lock; + gint _use_count; /* atomic */ + uint32_t _level; /* how deeply nested is this source w.r.t a disk file */ + std::string _ancestor_name; + + private: void fix_writable_flags (); }; diff --git a/libs/ardour/disk_writer.cc b/libs/ardour/disk_writer.cc index e8c380f8d4..e0dcb42453 100644 --- a/libs/ardour/disk_writer.cc +++ b/libs/ardour/disk_writer.cc @@ -1220,6 +1220,8 @@ DiskWriter::transport_stopped_wallclock (struct tm& when, time_t twhen, bool abo strftime (buf, sizeof(buf), "%F %H.%M.%S", &when); as->set_take_id ( buf ); + Source::SourcePropertyChanged(as); + if (Config->get_auto_analyse_audio()) { Analyser::queue_source_for_analysis (as, true); } diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 16c84824f1..4c20e2236a 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -1555,6 +1555,7 @@ Region::set_master_sources (const SourceList& srcs) for (SourceList::const_iterator i = _master_sources.begin (); i != _master_sources.end(); ++i) { (*i)->inc_use_count (); +// Source::SourcePropertyChanged( *i ); } } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 8915add5e9..d955da9ac1 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -4789,6 +4789,7 @@ Session::destroy_sources (list<boost::shared_ptr<Source> > srcs) (*s)->mark_for_remove (); (*s)->drop_references (); + SourceRemoved(*s); s = srcs.erase (s); } @@ -4862,6 +4863,8 @@ Session::add_source (boost::shared_ptr<Source> source) } source->DropReferences.connect_same_thread (*this, boost::bind (&Session::remove_source, this, boost::weak_ptr<Source> (source))); + + SourceAdded(source); } } @@ -4884,6 +4887,7 @@ Session::remove_source (boost::weak_ptr<Source> src) if ((i = sources.find (source->id())) != sources.end()) { sources.erase (i); + SourceRemoved(source); } } diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc index 078113fb9b..68230d5c3d 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -622,7 +622,8 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload } if (!_model) { - _model = boost::shared_ptr<MidiModel> (new MidiModel (shared_from_this ())); + boost::shared_ptr<SMFSource> smf = boost::dynamic_pointer_cast<SMFSource> ( shared_from_this () ); + _model = boost::shared_ptr<MidiModel> (new MidiModel (smf)); } else { _model->clear(); } diff --git a/libs/ardour/source.cc b/libs/ardour/source.cc index 412f78c886..003fd35fe1 100644 --- a/libs/ardour/source.cc +++ b/libs/ardour/source.cc @@ -52,6 +52,9 @@ using namespace std; using namespace ARDOUR; using namespace PBD; +PBD::Signal1<void,boost::shared_ptr<ARDOUR::Source> > Source::SourcePropertyChanged; + + Source::Source (Session& s, DataType type, const string& name, Flag flags) : SessionObject(s, name) , _type(type) @@ -292,7 +295,14 @@ Source::set_allow_remove_if_empty (bool yn) void Source::inc_use_count () { - g_atomic_int_inc (&_use_count); + g_atomic_int_inc (&_use_count); + + try { + boost::shared_ptr<Source> sptr = shared_from_this(); + SourcePropertyChanged (sptr); + } catch (...) { + /* no shared_ptr available, relax; */ + } } void @@ -308,6 +318,13 @@ Source::dec_use_count () #else g_atomic_int_add (&_use_count, -1); #endif + + try { + boost::shared_ptr<Source> sptr = shared_from_this(); + SourcePropertyChanged (sptr); + } catch (...) { + /* no shared_ptr available, relax; */ + } } bool |