X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Faudio_playlist.cc;h=cb65164a9b03f2adb4be7032798227d72948e8fe;hb=f188ffffc18687c47d1d5a5c8b35bda4d7b75f5f;hp=85c3ffe1b2909511e411aebf656a5d2b2663e588;hpb=aae367b63c9b619db1e40f27dc334c6987219481;p=ardour.git diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc index 85c3ffe1b2..cb65164a9b 100644 --- a/libs/ardour/audio_playlist.cc +++ b/libs/ardour/audio_playlist.cc @@ -23,6 +23,7 @@ #include "ardour/types.h" +#include "ardour/debug.h" #include "ardour/configuration.h" #include "ardour/audioplaylist.h" #include "ardour/audioregion.h" @@ -40,8 +41,10 @@ using namespace PBD; AudioPlaylist::AudioPlaylist (Session& session, const XMLNode& node, bool hidden) : Playlist (session, node, DataType::AUDIO, hidden) { +#ifndef NDEBUG const XMLProperty* prop = node.property("type"); assert(!prop || DataType(prop->value()) == DataType::AUDIO); +#endif in_set_state++; set_state (node, Stateful::loading_state_version); @@ -102,10 +105,6 @@ AudioPlaylist::AudioPlaylist (boost::shared_ptr other, nfra AudioPlaylist::~AudioPlaylist () { - drop_references (); - - /* drop connections to signals */ - _crossfades.clear (); } @@ -167,7 +166,7 @@ AudioPlaylist::read (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, nf if ((*i)->coverage (start, end) != OverlapNone) { relevant_regions[(*i)->layer()].push_back (*i); relevant_layers.push_back ((*i)->layer()); - } + } } for (Crossfades::iterator i = _crossfades.begin(); i != _crossfades.end(); ++i) { @@ -192,8 +191,10 @@ AudioPlaylist::read (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, nf vector > r (relevant_regions[*l]); vector >& x (relevant_xfades[*l]); + for (vector >::iterator i = r.begin(); i != r.end(); ++i) { boost::shared_ptr ar = boost::dynamic_pointer_cast(*i); + DEBUG_TRACE (DEBUG::AudioPlayback, string_compose ("read from region %1\n", ar->name())); assert(ar); ar->read_at (buf, mixdown_buffer, gain_buffer, start, cnt, chan_n, read_frames, skip_frames); _read_data_count += ar->read_data_count(); @@ -369,9 +370,6 @@ AudioPlaylist::check_dependents (boost::shared_ptr r, bool norefresh) } for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) { - - nframes_t xfade_length; - other = boost::dynamic_pointer_cast (*i); if (other == region) { @@ -401,6 +399,7 @@ AudioPlaylist::check_dependents (boost::shared_ptr r, bool norefresh) touched_regions = 0; try { + nframes_t xfade_length; switch (c) { case OverlapNone: break; @@ -424,7 +423,7 @@ AudioPlaylist::check_dependents (boost::shared_ptr r, bool norefresh) audio engineering. */ - xfade_length = min ((nframes_t) 720, top->length()); + xfade_length = min ((framecnt_t) 720, top->length()); if (top_region_at (top->first_frame()) == top) { @@ -458,7 +457,7 @@ AudioPlaylist::check_dependents (boost::shared_ptr r, bool norefresh) } else { touched_regions = regions_touched (top->first_frame(), - top->first_frame() + min ((nframes_t)_session.config.get_short_xfade_seconds() * _session.frame_rate(), + top->first_frame() + min ((framecnt_t) _session.config.get_short_xfade_seconds() * _session.frame_rate(), top->length())); if (touched_regions->size() <= 2) { xfade = boost::shared_ptr (new Crossfade (region, other, _session.config.get_xfade_model(), _session.config.get_xfades_active())); @@ -484,7 +483,7 @@ AudioPlaylist::check_dependents (boost::shared_ptr r, bool norefresh) } else { touched_regions = regions_touched (bottom->first_frame(), - bottom->first_frame() + min ((nframes_t)_session.config.get_short_xfade_seconds() * _session.frame_rate(), + bottom->first_frame() + min ((framecnt_t)_session.config.get_short_xfade_seconds() * _session.frame_rate(), bottom->length())); if (touched_regions->size() <= 2) { xfade = boost::shared_ptr (new Crossfade (region, other, _session.config.get_xfade_model(), _session.config.get_xfades_active())); @@ -528,8 +527,8 @@ AudioPlaylist::add_crossfade (boost::shared_ptr xfade) } else { _crossfades.push_back (xfade); - xfade->Invalidated.connect (*this, boost::bind (&AudioPlaylist::crossfade_invalidated, this, _1)); - xfade->StateChanged.connect (*this, boost::bind (&AudioPlaylist::crossfade_changed, this, _1)); + xfade->Invalidated.connect_same_thread (*this, boost::bind (&AudioPlaylist::crossfade_invalidated, this, _1)); + xfade->PropertyChanged.connect_same_thread (*this, boost::bind (&AudioPlaylist::crossfade_changed, this, _1)); notify_crossfade_added (xfade); } @@ -584,8 +583,8 @@ AudioPlaylist::set_state (const XMLNode& node, int version) try { boost::shared_ptr xfade = boost::shared_ptr (new Crossfade (*((const Playlist *)this), *child)); _crossfades.push_back (xfade); - xfade->Invalidated.connect (*this, boost::bind (&AudioPlaylist::crossfade_invalidated, this, _1)); - xfade->StateChanged.connect (*this, boost::bind (&AudioPlaylist::crossfade_changed, this, _1)); + xfade->Invalidated.connect_same_thread (*this, boost::bind (&AudioPlaylist::crossfade_invalidated, this, _1)); + xfade->PropertyChanged.connect_same_thread (*this, boost::bind (&AudioPlaylist::crossfade_changed, this, _1)); NewCrossfade(xfade); } @@ -666,17 +665,15 @@ bool AudioPlaylist::destroy_region (boost::shared_ptr region) { boost::shared_ptr r = boost::dynamic_pointer_cast (region); + + if (!r) { + return false; + } + bool changed = false; Crossfades::iterator c, ctmp; set > unique_xfades; - if (r == 0) { - fatal << _("programming error: non-audio Region passed to remove_overlap in audio playlist") - << endmsg; - /*NOTREACHED*/ - return false; - } - { RegionLock rlock (this); @@ -730,7 +727,7 @@ AudioPlaylist::destroy_region (boost::shared_ptr region) } void -AudioPlaylist::crossfade_changed (Change) +AudioPlaylist::crossfade_changed (const PropertyChange&) { if (in_flush || in_set_state) { return; @@ -742,29 +739,32 @@ AudioPlaylist::crossfade_changed (Change) that occured. */ - notify_modified (); + notify_contents_changed (); } bool -AudioPlaylist::region_changed (Change what_changed, boost::shared_ptr region) +AudioPlaylist::region_changed (const PropertyChange& what_changed, boost::shared_ptr region) { if (in_flush || in_set_state) { return false; } - Change our_interests = Change (AudioRegion::FadeInChanged| - AudioRegion::FadeOutChanged| - AudioRegion::FadeInActiveChanged| - AudioRegion::FadeOutActiveChanged| - AudioRegion::EnvelopeActiveChanged| - AudioRegion::ScaleAmplitudeChanged| - AudioRegion::EnvelopeChanged); + PropertyChange our_interests; + + our_interests.add (Properties::fade_in_active); + our_interests.add (Properties::fade_out_active); + our_interests.add (Properties::scale_amplitude); + our_interests.add (Properties::envelope_active); + our_interests.add (Properties::envelope); + our_interests.add (Properties::fade_in); + our_interests.add (Properties::fade_out); + bool parent_wants_notify; parent_wants_notify = Playlist::region_changed (what_changed, region); - if ((parent_wants_notify || (what_changed & our_interests))) { - notify_modified (); + if (parent_wants_notify || (what_changed.contains (our_interests))) { + notify_contents_changed (); } return true;