mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-20 21:56:30 +01:00
(Source List) Source property signals (libardour part)
This commit is contained in:
parent
949450bbb5
commit
ca3c191d7c
9 changed files with 60 additions and 22 deletions
|
|
@ -39,8 +39,7 @@
|
||||||
namespace ARDOUR {
|
namespace ARDOUR {
|
||||||
|
|
||||||
class LIBARDOUR_API AudioSource : virtual public Source,
|
class LIBARDOUR_API AudioSource : virtual public Source,
|
||||||
public ARDOUR::Readable,
|
public ARDOUR::Readable
|
||||||
public boost::enable_shared_from_this<ARDOUR::AudioSource>
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AudioSource (Session&, const std::string& name);
|
AudioSource (Session&, const std::string& name);
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class MidiStateTracker;
|
||||||
template<typename T> class MidiRingBuffer;
|
template<typename T> class MidiRingBuffer;
|
||||||
|
|
||||||
/** Source for MIDI data */
|
/** 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:
|
public:
|
||||||
typedef Temporal::Beats TimeType;
|
typedef Temporal::Beats TimeType;
|
||||||
|
|
|
||||||
|
|
@ -1754,8 +1754,20 @@ private:
|
||||||
mutable Glib::Threads::Mutex source_lock;
|
mutable Glib::Threads::Mutex source_lock;
|
||||||
|
|
||||||
public:
|
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;
|
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:
|
private:
|
||||||
void reset_write_sources (bool mark_write_complete, bool force = false);
|
void reset_write_sources (bool mark_write_complete, bool force = false);
|
||||||
SourceMap sources;
|
SourceMap sources;
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@
|
||||||
|
|
||||||
#include <glibmm/threads.h>
|
#include <glibmm/threads.h>
|
||||||
|
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
#include <boost/enable_shared_from_this.hpp>
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
#include "pbd/statefuldestructible.h"
|
#include "pbd/statefuldestructible.h"
|
||||||
|
|
||||||
|
|
@ -36,7 +38,8 @@ namespace ARDOUR {
|
||||||
|
|
||||||
class Session;
|
class Session;
|
||||||
|
|
||||||
class LIBARDOUR_API Source : public SessionObject
|
class LIBARDOUR_API Source : public SessionObject,
|
||||||
|
public boost::enable_shared_from_this<ARDOUR::Source>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Flag {
|
enum Flag {
|
||||||
|
|
@ -119,23 +122,22 @@ public:
|
||||||
std::string ancestor_name() { return _ancestor_name.empty() ? name() : _ancestor_name; }
|
std::string ancestor_name() { return _ancestor_name.empty() ? name() : _ancestor_name; }
|
||||||
void set_ancestor_name(const std::string& name) { _ancestor_name = name; }
|
void set_ancestor_name(const std::string& name) { _ancestor_name = name; }
|
||||||
|
|
||||||
protected:
|
static PBD::Signal1<void,boost::shared_ptr<ARDOUR::Source> > SourcePropertyChanged;
|
||||||
|
|
||||||
|
protected:
|
||||||
DataType _type;
|
DataType _type;
|
||||||
Flag _flags;
|
Flag _flags;
|
||||||
time_t _timestamp;
|
time_t _timestamp;
|
||||||
std::string _take_id;
|
std::string _take_id;
|
||||||
samplepos_t _timeline_position;
|
samplepos_t _timeline_position;
|
||||||
bool _analysed;
|
bool _analysed;
|
||||||
|
|
||||||
mutable Glib::Threads::Mutex _lock;
|
mutable Glib::Threads::Mutex _lock;
|
||||||
mutable Glib::Threads::Mutex _analysis_lock;
|
mutable Glib::Threads::Mutex _analysis_lock;
|
||||||
|
|
||||||
gint _use_count; /* atomic */
|
gint _use_count; /* atomic */
|
||||||
uint32_t _level; /* how deeply nested is this source w.r.t a disk file */
|
uint32_t _level; /* how deeply nested is this source w.r.t a disk file */
|
||||||
std::string _ancestor_name;
|
std::string _ancestor_name;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void fix_writable_flags ();
|
void fix_writable_flags ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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);
|
strftime (buf, sizeof(buf), "%F %H.%M.%S", &when);
|
||||||
as->set_take_id ( buf );
|
as->set_take_id ( buf );
|
||||||
|
|
||||||
|
Source::SourcePropertyChanged(as);
|
||||||
|
|
||||||
if (Config->get_auto_analyse_audio()) {
|
if (Config->get_auto_analyse_audio()) {
|
||||||
Analyser::queue_source_for_analysis (as, true);
|
Analyser::queue_source_for_analysis (as, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1555,6 +1555,7 @@ Region::set_master_sources (const SourceList& srcs)
|
||||||
|
|
||||||
for (SourceList::const_iterator i = _master_sources.begin (); i != _master_sources.end(); ++i) {
|
for (SourceList::const_iterator i = _master_sources.begin (); i != _master_sources.end(); ++i) {
|
||||||
(*i)->inc_use_count ();
|
(*i)->inc_use_count ();
|
||||||
|
// Source::SourcePropertyChanged( *i );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4789,6 +4789,7 @@ Session::destroy_sources (list<boost::shared_ptr<Source> > srcs)
|
||||||
|
|
||||||
(*s)->mark_for_remove ();
|
(*s)->mark_for_remove ();
|
||||||
(*s)->drop_references ();
|
(*s)->drop_references ();
|
||||||
|
SourceRemoved(*s);
|
||||||
|
|
||||||
s = srcs.erase (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)));
|
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()) {
|
if ((i = sources.find (source->id())) != sources.end()) {
|
||||||
sources.erase (i);
|
sources.erase (i);
|
||||||
|
SourceRemoved(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -622,7 +622,8 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_model) {
|
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 {
|
} else {
|
||||||
_model->clear();
|
_model->clear();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,9 @@ using namespace std;
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
using namespace PBD;
|
using namespace PBD;
|
||||||
|
|
||||||
|
PBD::Signal1<void,boost::shared_ptr<ARDOUR::Source> > Source::SourcePropertyChanged;
|
||||||
|
|
||||||
|
|
||||||
Source::Source (Session& s, DataType type, const string& name, Flag flags)
|
Source::Source (Session& s, DataType type, const string& name, Flag flags)
|
||||||
: SessionObject(s, name)
|
: SessionObject(s, name)
|
||||||
, _type(type)
|
, _type(type)
|
||||||
|
|
@ -293,6 +296,13 @@ void
|
||||||
Source::inc_use_count ()
|
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
|
void
|
||||||
|
|
@ -308,6 +318,13 @@ Source::dec_use_count ()
|
||||||
#else
|
#else
|
||||||
g_atomic_int_add (&_use_count, -1);
|
g_atomic_int_add (&_use_count, -1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
try {
|
||||||
|
boost::shared_ptr<Source> sptr = shared_from_this();
|
||||||
|
SourcePropertyChanged (sptr);
|
||||||
|
} catch (...) {
|
||||||
|
/* no shared_ptr available, relax; */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue