Fix up some problems with Region::_master_sources

git-svn-id: svn://localhost/ardour2/branches/3.0@5189 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington
2009-06-14 16:54:40 +00:00
parent addaba4204
commit ebf60a31d8
4 changed files with 45 additions and 33 deletions

View File

@@ -200,7 +200,8 @@ class AudioRegion : public Region
void fade_out_changed ();
void source_offset_changed ();
void listen_to_my_curves ();
void listen_to_my_sources ();
void connect_to_analysis_changed ();
void connect_to_header_position_offset_changed ();
AutomatableControls _automatable;

View File

@@ -73,7 +73,7 @@ AudioRegion::init ()
set_default_envelope ();
listen_to_my_curves ();
listen_to_my_sources ();
connect_to_analysis_changed ();
}
/** Constructor for use by derived types only */
@@ -85,6 +85,7 @@ AudioRegion::AudioRegion (Session& s, nframes_t start, nframes_t length, string
, _envelope (new AutomationList(Evoral::Parameter(EnvelopeAutomation)))
{
init ();
assert (_sources.size() == _master_sources.size());
}
/** Basic AudioRegion constructor (one channel) */
@@ -101,6 +102,7 @@ AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, nframes_t start, n
}
init ();
assert (_sources.size() == _master_sources.size());
}
/* Basic AudioRegion constructor (one channel) */
@@ -117,6 +119,7 @@ AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, nframes_t start, n
}
init ();
assert (_sources.size() == _master_sources.size());
}
/** Basic AudioRegion constructor (many channels) */
@@ -128,7 +131,8 @@ AudioRegion::AudioRegion (const SourceList& srcs, nframes_t start, nframes_t len
, _envelope (new AutomationList(Evoral::Parameter(EnvelopeAutomation)))
{
init ();
listen_to_my_sources ();
connect_to_analysis_changed ();
assert (_sources.size() == _master_sources.size());
}
/** Create a new AudioRegion, that is part of an existing one */
@@ -139,22 +143,7 @@ AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other, nframes_t
, _fade_out (new AutomationList(*other->_fade_out))
, _envelope (new AutomationList(*other->_envelope, offset, offset + length))
{
set<boost::shared_ptr<Source> > unique_srcs;
for (SourceList::const_iterator i= other->_sources.begin(); i != other->_sources.end(); ++i) {
_sources.push_back (*i);
pair<set<boost::shared_ptr<Source> >::iterator,bool> result;
result = unique_srcs.insert (*i);
if (result.second) {
boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (*i);
if (afs) {
afs->HeaderPositionOffsetChanged.connect (mem_fun (*this, &AudioRegion::source_offset_changed));
}
}
}
connect_to_header_position_offset_changed ();
/* return to default fades if the existing ones are too long */
@@ -183,7 +172,9 @@ AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other, nframes_t
assert(_type == DataType::AUDIO);
listen_to_my_curves ();
listen_to_my_sources ();
connect_to_analysis_changed ();
assert (_sources.size() == _master_sources.size());
}
AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other)
@@ -199,7 +190,9 @@ AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other)
set_default_fades ();
listen_to_my_curves ();
listen_to_my_sources ();
connect_to_analysis_changed ();
assert (_sources.size() == _master_sources.size());
}
AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other, const SourceList& srcs,
@@ -212,12 +205,7 @@ AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other, const Sour
{
/* make-a-sort-of-copy-with-different-sources constructor (used by audio filter) */
set<boost::shared_ptr<AudioSource> > unique_srcs;
for (SourceList::const_iterator i=srcs.begin(); i != srcs.end(); ++i) {
_sources.push_back (*i);
_master_sources.push_back (*i);
for (SourceList::const_iterator i = _sources.begin(); i != _sources.end(); ++i) {
boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> ((*i));
if (afs) {
@@ -231,7 +219,9 @@ AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other, const Sour
_fade_out_disabled = 0;
listen_to_my_curves ();
listen_to_my_sources ();
connect_to_analysis_changed ();
assert (_sources.size() == _master_sources.size());
}
AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, const XMLNode& node)
@@ -253,7 +243,9 @@ AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, const XMLNode& nod
}
assert(_type == DataType::AUDIO);
listen_to_my_sources ();
connect_to_analysis_changed ();
assert (_sources.size() == _master_sources.size());
}
AudioRegion::AudioRegion (SourceList& srcs, const XMLNode& node)
@@ -270,7 +262,8 @@ AudioRegion::AudioRegion (SourceList& srcs, const XMLNode& node)
}
assert(_type == DataType::AUDIO);
listen_to_my_sources ();
connect_to_analysis_changed ();
assert (_sources.size() == _master_sources.size());
}
AudioRegion::~AudioRegion ()
@@ -278,13 +271,30 @@ AudioRegion::~AudioRegion ()
}
void
AudioRegion::listen_to_my_sources ()
AudioRegion::connect_to_analysis_changed ()
{
for (SourceList::const_iterator i = _sources.begin(); i != _sources.end(); ++i) {
(*i)->AnalysisChanged.connect (mem_fun (*this, &AudioRegion::invalidate_transients));
}
}
void
AudioRegion::connect_to_header_position_offset_changed ()
{
set<boost::shared_ptr<Source> > unique_srcs;
for (SourceList::const_iterator i = _sources.begin(); i != _sources.end(); ++i) {
if (unique_srcs.find (*i) == unique_srcs.end ()) {
unique_srcs.insert (*i);
boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (*i);
if (afs) {
afs->HeaderPositionOffsetChanged.connect (mem_fun (*this, &AudioRegion::source_offset_changed));
}
}
}
}
void
AudioRegion::listen_to_my_curves ()
{

View File

@@ -1473,6 +1473,7 @@ void
Region::set_master_sources (const SourceList& srcs)
{
_master_sources = srcs;
assert (_sources.size() == _master_sources.size());
}
bool

View File

@@ -1506,7 +1506,7 @@ Session::XMLAudioRegionFactory (const XMLNode& node, bool full)
}
}
for (uint32_t n=1; n < nchans; ++n) {
for (uint32_t n = 0; n < nchans; ++n) {
snprintf (buf, sizeof(buf), X_("master-source-%d"), n);
if ((prop = node.property (buf)) != 0) {
@@ -1541,7 +1541,7 @@ Session::XMLAudioRegionFactory (const XMLNode& node, bool full)
}
if (!master_sources.empty()) {
if (master_sources.size() == nchans) {
if (master_sources.size() != nchans) {
error << _("Session: XMLNode describing an AudioRegion is missing some master sources; ignored") << endmsg;
} else {
region->set_master_sources (master_sources);