a boatload of minor and middle-sized changes to try to speed up undo. imperfect,...
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 25 Jan 2010 20:34:09 +0000 (20:34 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 25 Jan 2010 20:34:09 +0000 (20:34 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@6561 d708f5d6-7413-0410-9779-e7cbd77b26cf

26 files changed:
gtk2_ardour/add_route_dialog.cc
gtk2_ardour/audio_streamview.cc
gtk2_ardour/audio_streamview.h
gtk2_ardour/editor.cc
gtk2_ardour/editor_actions.cc
gtk2_ardour/editor_drag.cc
gtk2_ardour/editor_mouse.cc
gtk2_ardour/editor_regions.cc
gtk2_ardour/editor_regions.h
gtk2_ardour/editor_selection.cc
gtk2_ardour/enums.cc
gtk2_ardour/midi_tracer.h
gtk2_ardour/processor_box.cc
gtk2_ardour/streamview.cc
gtk2_ardour/streamview.h
libs/ardour/ardour/playlist.h
libs/ardour/audio_diskstream.cc
libs/ardour/audio_playlist.cc
libs/ardour/audioregion.cc
libs/ardour/automation_list.cc
libs/ardour/crossfade.cc
libs/ardour/diskstream.cc
libs/ardour/midi_playlist.cc
libs/ardour/playlist.cc
libs/ardour/region.cc
libs/pbd/undo.cc

index a3d3deaea5bd801d3c12e795f488450ff95a1ef1..47eeb94320c7c07303e988216f9317e78012672a 100644 (file)
@@ -366,7 +366,7 @@ AddRouteDialog::refill_channel_setups ()
                chn.channels = 12;
                channel_setups.push_back (chn);
 
-               chn.name = X_("Custom");
+               chn.name = _("Custom");
                chn.channels = 0;
                channel_setups.push_back (chn);
        }
index fe4d601e3f0df5568f7a18d3e2a17abbf1908a81..b6abbb4b22673cf521106aaa100aca3ae18905aa 100644 (file)
@@ -24,6 +24,8 @@
 
 #include <gtkmm2ext/gtk_ui.h>
 
+#include "pbd/stacktrace.h"
+
 #include "ardour/audioplaylist.h"
 #include "ardour/audioregion.h"
 #include "ardour/audiofilesource.h"
@@ -202,14 +204,14 @@ AudioStreamView::remove_region_view (boost::weak_ptr<Region> weak_r)
 {
        ENSURE_GUI_THREAD (*this, &AudioStreamView::remove_region_view, weak_r);
 
-       cerr << "a region went way, it appears to be ours (" << this << ")\n";
-
        boost::shared_ptr<Region> r (weak_r.lock());
 
        if (!r) {
                return;
        }
 
+       cerr << "a region went way, it appears to be ours (" << this << ")\n";
+
        if (!_trackview.session()->deletion_in_progress()) {
 
                for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end();) {
@@ -244,46 +246,41 @@ AudioStreamView::undisplay_diskstream ()
 }
 
 void
-AudioStreamView::playlist_modified_weak (boost::weak_ptr<Diskstream> ds)
+AudioStreamView::playlist_layered (boost::weak_ptr<Diskstream> wds)
 {
-       boost::shared_ptr<Diskstream> sp (ds.lock());
-       if (sp) {
-               playlist_modified (sp);
+       boost::shared_ptr<Diskstream> ds (wds.lock());
+
+       if (!ds) {
+               return;
        }
-}
 
-void
-AudioStreamView::playlist_modified (boost::shared_ptr<Diskstream> ds)
-{
-       /* we do not allow shared_ptr<T> to be bound to slots */
-       ENSURE_GUI_THREAD (*this, &AudioStreamView::playlist_modified_weak, ds)
+       cerr << "AS, call SV::modified @ " << get_microseconds() << endl;
+
+       StreamView::playlist_layered (wds);
 
-       StreamView::playlist_modified (ds);
+       cerr << "AS, done with SV::modified @ " << get_microseconds() << endl;
 
        /* make sure xfades are on top and all the regionviews are stacked correctly. */
 
+       cerr << "AS, raise xfades @ " << get_microseconds() << endl;
        for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) {
                i->second->get_canvas_group()->raise_to_top();
        }
+       cerr << "AS, done with xfades @ " << get_microseconds() << endl;
 }
 
 void
-AudioStreamView::playlist_changed_weak (boost::weak_ptr<Diskstream> ds)
+AudioStreamView::playlist_switched (boost::weak_ptr<Diskstream> wds)
 {
-       boost::shared_ptr<Diskstream> sp (ds.lock());
-       if (sp) {
-               playlist_changed (sp);
-       }
-}
+       boost::shared_ptr<Diskstream> ds (wds.lock());
 
-void
-AudioStreamView::playlist_changed (boost::shared_ptr<Diskstream> ds)
-{
-       ENSURE_GUI_THREAD (*this, &AudioStreamView::playlist_changed_weak, boost::weak_ptr<Diskstream> (ds));
+       if (!ds) {
+               return;
+       }
 
        playlist_connections.drop_connections ();
 
-       StreamView::playlist_changed(ds);
+       StreamView::playlist_switched (ds);
 
        boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist>(ds->playlist());
 
@@ -293,27 +290,17 @@ AudioStreamView::playlist_changed (boost::shared_ptr<Diskstream> ds)
 }
 
 void
-AudioStreamView::add_crossfade_weak (boost::weak_ptr<Crossfade> crossfade)
+AudioStreamView::add_crossfade (boost::weak_ptr<Crossfade> wc)
 {
-       boost::shared_ptr<Crossfade> sp (crossfade.lock());
+       boost::shared_ptr<Crossfade> crossfade (wc.lock());
 
-       if (!sp) {
+       if (!crossfade) {
                return;
        }
 
-       add_crossfade (sp);
-}
-
-void
-AudioStreamView::add_crossfade (boost::shared_ptr<Crossfade> crossfade)
-{
        AudioRegionView* lview = 0;
        AudioRegionView* rview = 0;
 
-       /* we do not allow shared_ptr<T> to be bound to slots */
-
-       ENSURE_GUI_THREAD (*this, &AudioStreamView::add_crossfade_weak, boost::weak_ptr<Crossfade> (crossfade));
-
        /* first see if we already have a CrossfadeView for this Crossfade */
 
        CrossfadeViewList::iterator i = crossfade_views.find (crossfade);
index d17a67f23c6740de847a4ead2856f0a526377cd4..ce21c7dacbe7f888db50ebd2b28610cb6bea4fa7 100644 (file)
@@ -88,13 +88,10 @@ class AudioStreamView : public StreamView
 
        void undisplay_diskstream ();
        void redisplay_diskstream ();
-       void playlist_modified_weak (boost::weak_ptr<ARDOUR::Diskstream>);
-       void playlist_modified (boost::shared_ptr<ARDOUR::Diskstream>);
-       void playlist_changed_weak (boost::weak_ptr<ARDOUR::Diskstream>);
-       void playlist_changed (boost::shared_ptr<ARDOUR::Diskstream>);
+       void playlist_layered (boost::weak_ptr<ARDOUR::Diskstream>);
+       void playlist_switched (boost::weak_ptr<ARDOUR::Diskstream>);
 
-       void add_crossfade (boost::shared_ptr<ARDOUR::Crossfade>);
-       void add_crossfade_weak (boost::weak_ptr<ARDOUR::Crossfade>);
+       void add_crossfade (boost::weak_ptr<ARDOUR::Crossfade>);
        void remove_crossfade (boost::shared_ptr<ARDOUR::Region>);
 
        void color_handler ();
index 3c7bd3f37c7e2373d4c3d914c5c7d5421c41a7f8..387c61ecc6437833a69bda1b6d7a899a5a658a08 100644 (file)
@@ -2198,6 +2198,8 @@ Editor::set_state (const XMLNode& node, int /*version*/)
        int x, y, xoff, yoff;
        Gdk::Geometry g;
 
+       // return 0;
+
        if ((prop = node.property ("id")) != 0) {
                _id = prop->value ();
        }
@@ -2355,7 +2357,8 @@ Editor::set_state (const XMLNode& node, int /*version*/)
        }
 
        if ((prop = node.property ("region-list-sort-type"))) {
-               _regions->reset_sort_type (str2regionlistsorttype(prop->value()), true);
+               RegionListSortType st;
+               _regions->reset_sort_type ((RegionListSortType) string_2_enum (prop->value(), st), true);
        }
 
        if ((prop = node.property ("xfades-visible"))) {
@@ -2458,7 +2461,7 @@ Editor::get_state ()
        node->add_property ("show-measures", _show_measures ? "yes" : "no");
        node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
        node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
-       node->add_property ("region-list-sort-type", enum2str (_regions->sort_type ()));
+       node->add_property ("region-list-sort-type", enum_2_string (_regions->sort_type ()));
        node->add_property ("mouse-mode", enum2str(mouse_mode));
        node->add_property ("internal-edit", _internal_editing ? "yes" : "no");
        node->add_property ("join-object-range", join_object_range_button.get_active () ? "yes" : "no");
index 1b2654561c387cbc744d939ab257bf435cecdb75..64495fb2ffc6e54540745be44801e7cdda450c4d 100644 (file)
@@ -340,6 +340,7 @@ Editor::register_actions ()
        ActionManager::region_selection_sensitive_actions.push_back (act);
        act = ActionManager::register_action (editor_actions, "set-punch-from-edit-range", _("Set Punch from Edit Range"), sigc::mem_fun(*this, &Editor::set_punch_from_edit_range));
        ActionManager::session_sensitive_actions.push_back (act);
+       ActionManager::region_selection_sensitive_actions.push_back (act);
        act = ActionManager::register_action (editor_actions, "set-punch-from-region", _("Set Punch From Region"), sigc::mem_fun(*this, &Editor::set_punch_from_region));
        ActionManager::session_sensitive_actions.push_back (act);
        ActionManager::region_selection_sensitive_actions.push_back (act);
index ab5aa45cb304de65497a23f8a989ba139db935a1..8f59b9e699a40592986ee9a501b3fe99183f3e51 100644 (file)
@@ -1003,20 +1003,19 @@ RegionMoveDrag::finished (GdkEvent* /*event*/, bool movement_occurred)
                                rv->region()->set_layer (dest_layer);
                                rv->region()->set_pending_explicit_relayer (true);
                        }
+                       
+                       /* freeze playlist to avoid lots of relayering in the case of a multi-region drag */
 
-                       insert_result = modified_playlists.insert (playlist);
-
-                       if (insert_result.second) {
-                               _editor->session()->add_command (new MementoCommand<Playlist>(*playlist, &playlist->get_state(), 0));
-                       }
-                       /* freeze to avoid lots of relayering in the case of a multi-region drag */
                        frozen_insert_result = frozen_playlists.insert(playlist);
 
                        if (frozen_insert_result.second) {
                                playlist->freeze();
                        }
 
+                       XMLNode& before (rv->region()->get_state());
                        rv->region()->set_position (where, (void*) this);
+                       _editor->session()->add_command (new MementoCommand<Region>(*rv->region(), &before, &playlist->get_state()));
+
                }
 
                if (changed_tracks && !_copy) {
index c3b4528876355bb167f1c77aed6fd31b72b1eb51..64d1bf39f7f94878447b8659d742f98249e56244 100644 (file)
@@ -2454,13 +2454,14 @@ Editor::mouse_brush_insert_region (RegionView* rv, nframes64_t pos)
        double speed = rtv->get_diskstream()->speed();
 
        XMLNode &before = playlist->get_state();
-       playlist->add_region (RegionFactory::create (rv->region()), (nframes64_t) (pos * speed));
+       boost::shared_ptr<Region> new_region (RegionFactory::create (rv->region()));
+       playlist->add_region (new_region, (nframes64_t) (pos * speed));
        XMLNode &after = playlist->get_state();
        _session->add_command(new MementoCommand<Playlist>(*playlist.get(), &before, &after));
 
-       // playlist is frozen, so we have to update manually
+       // playlist is frozen, so we have to update manually XXX this is disgusting
 
-       playlist->Modified(); /* EMIT SIGNAL */
+       playlist->RegionAdded (new_region); /* EMIT SIGNAL */
 }
 
 gint
index 490f6991e3aa2be19a626c436d1f36e5158eb8bd..58a0a5d7e7b4a32bd85633843ce421515f988f12 100644 (file)
@@ -24,6 +24,7 @@
 #include <sstream>
 
 #include "pbd/basename.h"
+#include "pbd/enumwriter.h"
 
 #include "ardour/audioregion.h"
 #include "ardour/audiofilesource.h"
@@ -54,11 +55,13 @@ using namespace Editing;
 using Gtkmm2ext::Keyboard;
 
 EditorRegions::EditorRegions (Editor* e)
-       : EditorComponent (e),
-         _menu (0),
-         _show_automatic_regions (true),
-         _sort_type ((Editing::RegionListSortType) 0),
-         _no_redisplay (false)
+       : EditorComponent (e)
+       , _menu (0)
+       , _show_automatic_regions (true)
+       , _sort_type ((Editing::RegionListSortType) 0)
+       , _no_redisplay (false) 
+       , ignore_region_list_selection_change (false)
+       , ignore_selected_region_change (false)
 {
        _display.set_size_request (100, -1);
        _display.set_name ("RegionListDisplay");
@@ -383,37 +386,42 @@ EditorRegions::region_changed (Change what_changed, boost::weak_ptr<Region> regi
 void
 EditorRegions::selection_changed ()
 {
+       if (ignore_region_list_selection_change) {
+               return;
+       }
+
        if (_display.get_selection()->count_selected_rows() > 0) {
 
                TreeIter iter;
                TreeView::Selection::ListHandle_Path rows = _display.get_selection()->get_selected_rows ();
 
-               _editor->deselect_all ();
+               _editor->get_selection().clear_regions ();
 
                for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin(); i != rows.end(); ++i) {
 
-                       if (iter = _model->get_iter (*i)) {                                                                     // they could have clicked on a row that is just a placeholder, like "Hidden"
+                       if (iter = _model->get_iter (*i)) { 
                                boost::shared_ptr<Region> region = (*iter)[_columns.region];
 
+                                // they could have clicked on a row that is just a placeholder, like "Hidden"
+
                                if (region) {
 
                                        if (region->automatic()) {
+
                                                _display.get_selection()->unselect(*i);
 
                                        } else {
                                                _change_connection.block (true);
-                                               //editor_regions_selection_changed_connection.block(true);
-
+                                               cerr << "\tpush to region selection\n";
                                                _editor->set_selected_regionview_from_region_list (region, Selection::Add);
 
                                                _change_connection.block (false);
-                                               //editor_regions_selection_changed_connection.block(false);
                                        }
                                }
                        }
                }
        } else {
-               _editor->deselect_all ();
+               _editor->get_selection().clear_regions ();
        }
 }
 
@@ -431,11 +439,13 @@ EditorRegions::set_selected (RegionSelection& regions)
                        boost::shared_ptr<Region> compared_region = (*i)[_columns.region];
 
                        if (r == compared_region) {
+                               cerr << "\tpush into region list\n";
                                _display.get_selection()->select(*i);
                                break;
                        }
 
                        if (!(*i).children().empty()) {
+                               cerr << "\tlook for " << r->name() << " among children of " << (compared_region ? compared_region->name() : string ("NO REGION")) << endl;
                                if (set_selected_in_subrow(r, (*i), 2)) {
                                        break;
                                }
@@ -524,6 +534,8 @@ EditorRegions::update_row (boost::shared_ptr<Region> region)
 
        TreeModel::iterator i;
        TreeModel::Children rows = _model->children();
+       
+       return;
 
        for (i = rows.begin(); i != rows.end(); ++i) {
 
@@ -543,6 +555,7 @@ EditorRegions::update_row (boost::shared_ptr<Region> region)
                        }
                }
        }
+
 //     cerr << "Returning - No match\n";
 }
 
@@ -570,6 +583,7 @@ EditorRegions::update_subrows (boost::shared_ptr<Region> region, TreeModel::Row
                        }
                }
        }
+
        return false;
 }
 
@@ -579,7 +593,7 @@ EditorRegions::update_all_rows ()
        if (!_session) {
                return;
        }
-
+       
        TreeModel::iterator i;
        TreeModel::Children rows = _model->children();
 
@@ -1049,6 +1063,7 @@ EditorRegions::sorter (TreeModel::iterator a, TreeModel::iterator b)
                break;
 
        case ByEndInFile:
+               // cerr << "Compare " << (region1->start() + region1->length()) << " and " << (region2->start() + region2->length()) << endl;
                cmp = (region1->start() + region1->length()) - (region2->start() + region2->length());
                break;
 
@@ -1073,6 +1088,8 @@ EditorRegions::sorter (TreeModel::iterator a, TreeModel::iterator b)
                break;
        }
 
+       // cerr << "Comparison on " << enum_2_string (_sort_type) << " gives " << cmp << endl;
+
        if (cmp < 0) {
                return -1;
        } else if (cmp > 0) {
index 83fd91aacad101d92ea0df43f684271b190c3b42..5a9c2aad5a72b44f465bec473533618fde9730f5 100644 (file)
@@ -150,6 +150,8 @@ private:
        bool _no_redisplay;
        std::list<boost::shared_ptr<ARDOUR::Region> > tmp_region_list;
        PBD::ScopedConnection region_property_connection;
+       bool ignore_region_list_selection_change;
+       bool ignore_selected_region_change;
 };
 
 #endif /* __gtk_ardour_editor_regions_h__ */
index 4c4b4f0c8640512e24f48fb3c10db7367d38feeb..2b94a0561901f84525008c639192eaa23db379cd 100644 (file)
@@ -870,6 +870,8 @@ Editor::region_selection_changed ()
        _regions->block_change_connection (true);
        editor_regions_selection_changed_connection.block(true);
 
+       _regions->unselect_all ();
+
        for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
                (*i)->set_selected_regionviews (selection->regions);
        }
index 4820a930ac8f7271d018ac01245519bcc9c4ddcd..4b205141750105c21381f9b59a3ff85eab163458 100644 (file)
@@ -40,6 +40,7 @@ setup_gtk_ardour_enums ()
        ImportMode import_mode;
        EditPoint edit_point;
        LayerDisplay layer_display;
+       RegionListSortType region_list_sort_type;
 
 #define REGISTER(e) enum_writer.register_distinct (typeid(e).name(), i, s); i.clear(); s.clear()
 #define REGISTER_BITS(e) enum_writer.register_bits (typeid(e).name(), i, s); i.clear(); s.clear()
@@ -71,4 +72,16 @@ setup_gtk_ardour_enums ()
        REGISTER_ENUM (Overlaid);
        REGISTER_ENUM (Stacked);
        REGISTER (layer_display);
+
+       REGISTER_ENUM (ByEndInFile);
+       REGISTER_ENUM (ByLength);
+       REGISTER_ENUM (ByName);
+       REGISTER_ENUM (ByPosition);
+       REGISTER_ENUM (BySourceFileCreationDate);
+       REGISTER_ENUM (BySourceFileFS);
+       REGISTER_ENUM (BySourceFileLength);
+       REGISTER_ENUM (BySourceFileName);
+       REGISTER_ENUM (ByStartInFile);
+       REGISTER_ENUM (ByTimestamp);
+       REGISTER (region_list_sort_type);
 }
index fc6abee15cc472510eba1ff84ee42a57e370564e..58cdd6776e0dd126adf9550f9738fc7f27f55731 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef __ardour_gtk_midi_tracer_h__
 #define __ardour_gtk_midi_tracer_h__
 
-#include <types.h>
 #include <gtkmm/textview.h>
 #include <gtkmm/scrolledwindow.h>
 #include <gtkmm/togglebutton.h>
index 07d2a4e6d47487fa91cbc544eed2426dd899d307..7324541ae207fd2d4147413dc2c806e19380369c 100644 (file)
@@ -1019,10 +1019,11 @@ ProcessorBox::compute_processor_sort_keys ()
                Label label;
 
                label.set_text (_("\
-You cannot reorder this set of processors\n\
+You cannot reorder these plugins/sends/inserts\n\
 in that way because the inputs and\n\
-outputs do not work correctly."));
+outputs will not work correctly."));
 
+               dialog.get_vbox()->set_border_width (12);
                dialog.get_vbox()->pack_start (label);
                dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
 
index b93606fbe8b8c072ffbff5324d4d6a5ba68514b3..da773ea273d6344aed82bed4eceaf5aca8569828 100644 (file)
@@ -169,20 +169,12 @@ StreamView::set_samples_per_unit (gdouble spp)
 }
 
 void
-StreamView::add_region_view_weak (boost::weak_ptr<Region> r)
+StreamView::add_region_view (boost::weak_ptr<Region> wr)
 {
-       boost::shared_ptr<Region> sp (r.lock());
-
-       if (sp) {
-               add_region_view (sp);
+       boost::shared_ptr<Region> r (wr.lock());
+       if (!r) {
+               return;
        }
-}
-
-
-void
-StreamView::add_region_view (boost::shared_ptr<Region> r)
-{
-       ENSURE_GUI_THREAD (*this, &StreamView::add_region_view_weak, boost::weak_ptr<Region>(r));
 
        add_region_view_internal (r, true);
 
@@ -229,9 +221,9 @@ StreamView::undisplay_diskstream ()
 void
 StreamView::display_diskstream (boost::shared_ptr<Diskstream> ds)
 {
-       playlist_change_connection.disconnect();
-       playlist_changed (ds);
-       ds->PlaylistChanged.connect (playlist_change_connection, boost::bind (&StreamView::playlist_changed_weak, this, boost::weak_ptr<Diskstream> (ds)), gui_context());
+       playlist_switched_connection.disconnect();
+       playlist_switched (ds);
+       ds->PlaylistChanged.connect (playlist_switched_connection, boost::bind (&StreamView::playlist_switched, this, boost::weak_ptr<Diskstream> (ds)), gui_context());
 }
 
 void
@@ -292,20 +284,13 @@ StreamView::layer_regions()
 }
 
 void
-StreamView::playlist_modified_weak (boost::weak_ptr<Diskstream> ds)
+StreamView::playlist_layered (boost::weak_ptr<Diskstream> wds)
 {
-       boost::shared_ptr<Diskstream> sp (ds.lock());
+       boost::shared_ptr<Diskstream> ds (wds.lock());
 
-       if (sp) {
-               playlist_modified (sp);
+       if (!ds) {
+               return;
        }
-}
-
-void
-StreamView::playlist_modified (boost::shared_ptr<Diskstream> ds)
-{
-       /* we do not allow shared_ptr<T> to be bound to slots */
-       ENSURE_GUI_THREAD (*this, &StreamView::playlist_modified_weak, ds)
 
        /* update layers count and the y positions and heights of our regions */
        if (ds->playlist()) {
@@ -322,18 +307,13 @@ StreamView::playlist_modified (boost::shared_ptr<Diskstream> ds)
 }
 
 void
-StreamView::playlist_changed_weak (boost::weak_ptr<Diskstream> ds)
+StreamView::playlist_switched (boost::weak_ptr<Diskstream> wds)
 {
-       boost::shared_ptr<Diskstream> sp (ds.lock());
-       if (sp) {
-               playlist_changed (sp);
-       }
-}
+       boost::shared_ptr<Diskstream> ds (wds.lock());
 
-void
-StreamView::playlist_changed (boost::shared_ptr<Diskstream> ds)
-{
-       ENSURE_GUI_THREAD (*this, &StreamView::playlist_changed_weak, boost::weak_ptr<Diskstream> (ds));
+       if (!ds) {
+               return;
+       }
 
        /* disconnect from old playlist */
 
@@ -353,8 +333,8 @@ StreamView::playlist_changed (boost::shared_ptr<Diskstream> ds)
 
        /* catch changes */
 
-       ds->playlist()->Modified.connect (playlist_connections, boost::bind (&StreamView::playlist_modified_weak, this, ds), gui_context());
-       ds->playlist()->RegionAdded.connect (playlist_connections, ui_bind (&StreamView::add_region_view_weak, this, _1), gui_context());
+       ds->playlist()->LayeringChanged.connect (playlist_connections, boost::bind (&StreamView::playlist_layered, this, boost::weak_ptr<Diskstream>(ds)), gui_context());
+       ds->playlist()->RegionAdded.connect (playlist_connections, ui_bind (&StreamView::add_region_view, this, _1), gui_context());
        ds->playlist()->RegionRemoved.connect (playlist_connections, ui_bind (&StreamView::remove_region_view, this, _1), gui_context());
 }
 
index b32d75d5acc54f300ff94da5420531cc5f9f8c3d..a1ebe2cc2a9fefee42be4f64d65bcae4a9f7e64b 100644 (file)
@@ -99,8 +99,7 @@ public:
 
        virtual void update_contents_metrics(boost::shared_ptr<ARDOUR::Region>) {}
 
-       void add_region_view_weak (boost::weak_ptr<ARDOUR::Region> r);
-       void add_region_view (boost::shared_ptr<ARDOUR::Region>);
+       void add_region_view (boost::weak_ptr<ARDOUR::Region>);
 
        void region_layered (RegionView*);
        virtual void update_contents_height ();
@@ -135,10 +134,8 @@ protected:
        void         diskstream_changed ();
        void         layer_regions ();
 
-       virtual void playlist_changed_weak (boost::weak_ptr<ARDOUR::Diskstream>);
-       virtual void playlist_changed (boost::shared_ptr<ARDOUR::Diskstream>);
-       virtual void playlist_modified_weak (boost::weak_ptr<ARDOUR::Diskstream>);
-       virtual void playlist_modified (boost::shared_ptr<ARDOUR::Diskstream>);
+       virtual void playlist_switched (boost::weak_ptr<ARDOUR::Diskstream>);
+       virtual void playlist_layered (boost::weak_ptr<ARDOUR::Diskstream>);
 
        virtual void color_handler () = 0;
 
@@ -164,7 +161,7 @@ protected:
        uint32_t   stream_base_color; ///< Background color
 
        PBD::ScopedConnectionList playlist_connections;
-       PBD::ScopedConnection playlist_change_connection;
+       PBD::ScopedConnection playlist_switched_connection;
 
        ARDOUR::layer_t _layers;
        LayerDisplay    _layer_display;
index 8bcdc5540b1c30beb20dc449d77d8df843e39788..fb734458d548b648562ae12c1c9d6e612d021f28 100644 (file)
@@ -130,11 +130,12 @@ class Playlist : public SessionObject
        XMLNode& get_template ();
 
        PBD::Signal1<void,bool> InUse;
-       PBD::Signal0<void>      Modified;
+       PBD::Signal0<void>      ContentsChanged;
        PBD::Signal1<void,boost::weak_ptr<Region> > RegionAdded;
        PBD::Signal1<void,boost::weak_ptr<Region> > RegionRemoved;
        PBD::Signal0<void>      NameChanged;
        PBD::Signal0<void>      LengthChanged;
+       PBD::Signal0<void>      LayeringChanged;
        PBD::Signal1<void,std::list< Evoral::RangeMove<nframes_t> > const &> RangesMoved;
 
        static std::string bump_name (std::string old_name, Session&);
@@ -201,7 +202,8 @@ class Playlist : public SessionObject
        std::set<boost::shared_ptr<Region> > pending_adds;
        std::set<boost::shared_ptr<Region> > pending_removes;
        RegionList       pending_bounds;
-       bool             pending_modified;
+       bool             pending_contents_change;
+       bool             pending_layering;
        bool             pending_length;
        std::list< Evoral::RangeMove<nframes_t> > pending_range_moves;
        bool             save_on_thaw;
@@ -240,12 +242,13 @@ class Playlist : public SessionObject
        void delay_notifications ();
        void release_notifications ();
        virtual void flush_notifications ();
+       void clear_pending ();
 
        void notify_region_removed (boost::shared_ptr<Region>);
        void notify_region_added (boost::shared_ptr<Region>);
        void notify_length_changed ();
        void notify_layering_changed ();
-       void notify_modified ();
+       void notify_contents_changed ();
        void notify_state_changed (Change);
        void notify_region_moved (boost::shared_ptr<Region>);
 
index fb225671e9ba8198ea1a8bb557803c2946d0a7c8..db1a343d175eac33d2074ec832df0eba59e8a913 100644 (file)
@@ -1451,7 +1451,7 @@ AudioDiskstream::transport_stopped (struct tm& when, time_t twhen, bool abort_ca
                   process. this problem is deferred to the UI.
                 */
 
-               _playlist->Modified();
+               _playlist->LayeringChanged(); // XXX this may not get the UI to do the right thing
 
        } else {
 
index 1ecba28653f615f44838ed73c4a0c83c42bd8a45..7f75d448526d4ffa433d9d3e90cdb128d8096d16 100644 (file)
@@ -738,7 +738,7 @@ AudioPlaylist::crossfade_changed (Change)
           that occured.
        */
 
-       notify_modified ();
+       notify_contents_changed ();
 }
 
 bool
@@ -760,7 +760,7 @@ AudioPlaylist::region_changed (Change what_changed, boost::shared_ptr<Region> re
        parent_wants_notify = Playlist::region_changed (what_changed, region);
 
        if ((parent_wants_notify || (what_changed & our_interests))) {
-               notify_modified ();
+               notify_contents_changed ();
        }
 
        return true;
index 5a99c164d9743f9b553f8de5b1a6e8bc81290f6b..729398cf213311e667bc7834cc4a9b64570d7099 100644 (file)
@@ -294,6 +294,8 @@ AudioRegion::connect_to_header_position_offset_changed ()
 void
 AudioRegion::listen_to_my_curves ()
 {
+       cerr << _name << ": listeing my own curves\n";
+
        _envelope->StateChanged.connect_same_thread (*this, boost::bind (&AudioRegion::envelope_changed, this));
        _fade_in->StateChanged.connect_same_thread (*this, boost::bind (&AudioRegion::fade_in_changed, this));
        _fade_out->StateChanged.connect_same_thread (*this, boost::bind (&AudioRegion::fade_out_changed, this));
@@ -637,8 +639,15 @@ AudioRegion::set_live_state (const XMLNode& node, int version, Change& what_chan
        const XMLNodeList& nlist = node.children();
        const XMLProperty *prop;
        LocaleGuard lg (X_("POSIX"));
+       boost::shared_ptr<Playlist> the_playlist (_playlist.lock());    
+
+       freeze ();
+       if (the_playlist) {
+               the_playlist->freeze ();
+       }
 
        Region::set_live_state (node, version, what_changed, false);
+       cerr << "After region SLS, wc = " << what_changed << endl;
 
        uint32_t old_flags = _flags;
 
@@ -661,23 +670,32 @@ AudioRegion::set_live_state (const XMLNode& node, int version, Change& what_chan
 
        if ((old_flags ^ _flags) & Muted) {
                what_changed = Change (what_changed|MuteChanged);
+               cerr << _name << " mute changed\n";
        }
        if ((old_flags ^ _flags) & Opaque) {
                what_changed = Change (what_changed|OpacityChanged);
+               cerr << _name << " opacity changed\n";
        }
        if ((old_flags ^ _flags) & Locked) {
                what_changed = Change (what_changed|LockChanged);
+               cerr << _name << " lock changed\n";
        }
 
        if ((prop = node.property ("scale-gain")) != 0) {
-               _scale_amplitude = atof (prop->value().c_str());
-               what_changed = Change (what_changed|ScaleAmplitudeChanged);
+               float a = atof (prop->value().c_str());
+               if (a != _scale_amplitude) {
+                       _scale_amplitude = a;
+                       what_changed = Change (what_changed|ScaleAmplitudeChanged);
+                       cerr << _name << " amp changed\n";
+               }
        } else {
                _scale_amplitude = 1.0;
        }
 
        /* Now find envelope description and other misc child items */
 
+       _envelope->freeze ();
+
        for (XMLNodeConstIterator niter = nlist.begin(); niter != nlist.end(); ++niter) {
 
                XMLNode *child;
@@ -685,6 +703,7 @@ AudioRegion::set_live_state (const XMLNode& node, int version, Change& what_chan
 
                child = (*niter);
 
+#if 0
                if (child->name() == "Envelope") {
 
                        _envelope->clear ();
@@ -696,6 +715,9 @@ AudioRegion::set_live_state (const XMLNode& node, int version, Change& what_chan
                        _envelope->set_max_xval (_length);
                        _envelope->truncate_end (_length);
 
+                       cerr << _name << " envelope changd\n";
+               
+
                } else if (child->name() == "FadeIn") {
 
                        _fade_in->clear ();
@@ -716,6 +738,7 @@ AudioRegion::set_live_state (const XMLNode& node, int version, Change& what_chan
                                        set_fade_in_active (false);
                                }
                        }
+                       cerr << _name << " fadein changd\n";
 
                } else if (child->name() == "FadeOut") {
 
@@ -737,14 +760,24 @@ AudioRegion::set_live_state (const XMLNode& node, int version, Change& what_chan
                                        set_fade_out_active (false);
                                }
                        }
+                       cerr << _name << " fadeout changd\n";
 
                }
+#endif
        }
 
+       _envelope->thaw ();
+       thaw ("");
+
        if (send) {
+               cerr << _name << ": audio final change: " << hex << what_changed << dec << endl;
                send_change (what_changed);
        }
 
+       if (the_playlist) {
+               the_playlist->thaw ();
+       }
+
        return 0;
 }
 
@@ -836,8 +869,6 @@ AudioRegion::set_fade_in (FadeShape shape, nframes_t len)
        }
 
        _fade_in->thaw ();
-
-       send_change (FadeInChanged);
 }
 
 void
@@ -903,8 +934,6 @@ AudioRegion::set_fade_out (FadeShape shape, nframes_t len)
        }
 
        _fade_out->thaw ();
-
-       send_change (FadeOutChanged);
 }
 
 void
@@ -1175,7 +1204,7 @@ AudioRegion::set_scale_amplitude (gain_t g)
        /* tell the diskstream we're in */
 
        if (pl) {
-               pl->Modified();
+               pl->ContentsChanged();
        }
 
        /* tell everybody else */
@@ -1245,7 +1274,7 @@ AudioRegion::normalize_to (float target_dB)
        boost::shared_ptr<Playlist> pl (playlist());
 
        if (pl) {
-               pl->Modified();
+               pl->ContentsChanged();
        }
 
        /* tell everybody else */
index 3ecf3f0172309e0dae8f779f905a14542874a7ef..479674aee6a55aee94ad86aaca3dbaf54454e707 100644 (file)
@@ -219,6 +219,7 @@ AutomationList::thaw ()
        ControlList::thaw();
 
        if (_changed_when_thawed) {
+               _changed_when_thawed = false;
                StateChanged(); /* EMIT SIGNAL */
        }
 }
index 75f2bae587bc2fca12704851abbf80b43d525eb1..fd59982f6200fb17745a625c50a9883c54f62e2b 100644 (file)
@@ -72,7 +72,7 @@ Crossfade::Crossfade (boost::shared_ptr<AudioRegion> in, boost::shared_ptr<Audio
                      nframes_t length,
                      nframes_t position,
                      AnchorPoint ap)
-       : AudioRegion (in->session(), position, length, "foobar"),
+       : AudioRegion (in->session(), position, length, in->name() + string ("<>") + out->name()),
          _fade_in (Evoral::Parameter(FadeInAutomation)), // linear (gain coefficient) => -inf..+6dB
          _fade_out (Evoral::Parameter(FadeOutAutomation)) // linear (gain coefficient) => -inf..+6dB
 
@@ -89,7 +89,7 @@ Crossfade::Crossfade (boost::shared_ptr<AudioRegion> in, boost::shared_ptr<Audio
 }
 
 Crossfade::Crossfade (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioRegion> b, CrossfadeModel model, bool act)
-       : AudioRegion (a->session(), 0, 0, "foobar"),
+       : AudioRegion (a->session(), 0, 0, a->name() + string ("<>") + b->name()),
          _fade_in (Evoral::Parameter(FadeInAutomation)), // linear (gain coefficient) => -inf..+6dB
          _fade_out (Evoral::Parameter(FadeOutAutomation)) // linear (gain coefficient) => -inf..+6dB
 {
@@ -107,7 +107,7 @@ Crossfade::Crossfade (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioR
 }
 
 Crossfade::Crossfade (const Playlist& playlist, XMLNode& node)
-       : AudioRegion (playlist.session(), 0, 0, "foobar"),
+       : AudioRegion (playlist.session(), 0, 0, "unnamed crossfade"),
          _fade_in (Evoral::Parameter(FadeInAutomation)), // linear (gain coefficient) => -inf..+6dB
          _fade_out (Evoral::Parameter(FadeOutAutomation)) // linear (gain coefficient) => -inf..+6dB
 
index 7920f3b27949f7294963ab9e46da737ce2ee15a7..a4f8c22e285d8f0558cfbcced4bd0155bf53f800 100644 (file)
@@ -339,7 +339,7 @@ Diskstream::use_playlist (boost::shared_ptr<Playlist> playlist)
                        reset_write_sources (false);
                }
 
-               _playlist->Modified.connect_same_thread (playlist_connections, boost::bind (&Diskstream::playlist_modified, this));
+               _playlist->ContentsChanged.connect_same_thread (playlist_connections, boost::bind (&Diskstream::playlist_modified, this));
                _playlist->DropReferences.connect_same_thread (playlist_connections, boost::bind (&Diskstream::playlist_deleted, this, boost::weak_ptr<Playlist>(_playlist)));
                _playlist->RangesMoved.connect_same_thread (playlist_connections, boost::bind (&Diskstream::playlist_ranges_moved, this, _1));
        }
index 789c91b2363114a6b50d48cc8f0105b5044e281e..1721647c7cff69489eb0db09c9472b9486f2efe2 100644 (file)
@@ -435,7 +435,7 @@ MidiPlaylist::region_changed (Change what_changed, boost::shared_ptr<Region> reg
        parent_wants_notify = Playlist::region_changed (what_changed, region);
 
        if ((parent_wants_notify || (what_changed & our_interests))) {
-               notify_modified ();
+               notify_contents_changed ();
        }
 
        return true;
index e638a7a6b0261d75ec2409b5021de24f42ccd855..689c1fe35bc20b6e1e1a7144c9ea03bc287b6bad 100644 (file)
@@ -251,8 +251,9 @@ Playlist::init (bool hide)
 {
        g_atomic_int_set (&block_notifications, 0);
        g_atomic_int_set (&ignore_state_changes, 0);
-       pending_modified = false;
+       pending_contents_change = false;
        pending_length = false;
+       pending_layering = false;
        first_set_state = true;
        _refcnt = 0;
        _hidden = hide;
@@ -270,7 +271,7 @@ Playlist::init (bool hide)
        freeze_length = 0;
        _explicit_relayering = false;
 
-       Modified.connect_same_thread (*this, boost::bind (&Playlist::mark_session_dirty, this));
+       ContentsChanged.connect_same_thread (*this, boost::bind (&Playlist::mark_session_dirty, this));
 }
 
 Playlist::~Playlist ()
@@ -343,13 +344,28 @@ Playlist::release_notifications ()
 }
 
 void
-Playlist::notify_modified ()
+Playlist::notify_contents_changed ()
 {
        if (holding_state ()) {
-               pending_modified = true;
+               pending_contents_change = true;
        } else {
-               pending_modified = false;
-               Modified(); /* EMIT SIGNAL */
+               pending_contents_change = false;
+               cerr << _name << "send contents change @ " << get_microseconds() << endl;
+               ContentsChanged(); /* EMIT SIGNAL */
+               cerr << _name << "done with cc @ " << get_microseconds() << endl;
+       }
+}
+
+void
+Playlist::notify_layering_changed ()
+{
+       if (holding_state ()) {
+               pending_layering = true;
+       } else {
+               pending_layering = false;
+               cerr << _name << "send layering @ " << get_microseconds() << endl;
+               LayeringChanged(); /* EMIT SIGNAL */
+               cerr << _name << "done with layering @ " << get_microseconds() << endl;
        }
 }
 
@@ -358,7 +374,7 @@ Playlist::notify_region_removed (boost::shared_ptr<Region> r)
 {
        if (holding_state ()) {
                pending_removes.insert (r);
-               pending_modified = true;
+               pending_contents_change = true;
                pending_length = true;
        } else {
                /* this might not be true, but we have to act
@@ -366,9 +382,9 @@ Playlist::notify_region_removed (boost::shared_ptr<Region> r)
                */
                pending_length = false;
                LengthChanged (); /* EMIT SIGNAL */
-               pending_modified = false;
+               pending_contents_change = false;
                RegionRemoved (boost::weak_ptr<Region> (r)); /* EMIT SIGNAL */
-               Modified (); /* EMIT SIGNAL */
+               ContentsChanged (); /* EMIT SIGNAL */
        }
 }
 
@@ -399,14 +415,16 @@ Playlist::notify_region_added (boost::shared_ptr<Region> r)
 
        if (holding_state()) {
                pending_adds.insert (r);
-               pending_modified = true;
+               pending_contents_change = true;
                pending_length = true;
        } else {
                pending_length = false;
                LengthChanged (); /* EMIT SIGNAL */
-               pending_modified = false;
+               pending_contents_change = false;
                RegionAdded (boost::weak_ptr<Region> (r)); /* EMIT SIGNAL */
-               Modified (); /* EMIT SIGNAL */
+               cerr << _name << "send3 contents changed @ " << get_microseconds() << endl;
+               ContentsChanged (); /* EMIT SIGNAL */
+               cerr << _name << "done contents changed @ " << get_microseconds() << endl;
        }
 }
 
@@ -418,8 +436,10 @@ Playlist::notify_length_changed ()
        } else {
                pending_length = false;
                LengthChanged(); /* EMIT SIGNAL */
-               pending_modified = false;
-               Modified (); /* EMIT SIGNAL */
+               pending_contents_change = false;
+               cerr << _name << "send4 contents change @ " << get_microseconds() << endl;
+               ContentsChanged (); /* EMIT SIGNAL */
+               cerr << _name << "done contents change @ " << get_microseconds() << endl;
        }
 }
 
@@ -428,7 +448,9 @@ Playlist::flush_notifications ()
 {
        set<boost::shared_ptr<Region> > dependent_checks_needed;
        set<boost::shared_ptr<Region> >::iterator s;
-       uint32_t n = 0;
+       uint32_t regions_changed = false;
+       bool check_length = false;
+       nframes64_t old_length = 0;
 
        if (in_flush) {
                return;
@@ -436,6 +458,14 @@ Playlist::flush_notifications ()
 
        in_flush = true;
 
+       if (!pending_bounds.empty() || !pending_removes.empty() || !pending_adds.empty()) {
+               regions_changed = true;
+               if (!pending_length) {
+                       old_length = _get_maximum_extent ();
+                       check_length = true;
+               }
+       }
+
        /* we have no idea what order the regions ended up in pending
           bounds (it could be based on selection order, for example).
           so, to preserve layering in the "most recently moved is higher"
@@ -449,37 +479,42 @@ Playlist::flush_notifications ()
                if (_session.config.get_layer_model() == MoveAddHigher) {
                        timestamp_layer_op (*r);
                }
-
-               pending_length = true;
                dependent_checks_needed.insert (*r);
-
-               n++;
        }
 
        for (s = pending_removes.begin(); s != pending_removes.end(); ++s) {
                remove_dependents (*s);
+               cerr << _name << " sends RegionRemoved\n";
                RegionRemoved (boost::weak_ptr<Region> (*s)); /* EMIT SIGNAL */
-               n++;
        }
 
        for (s = pending_adds.begin(); s != pending_adds.end(); ++s) {
+               cerr << _name << " sends RegionAdded\n";
                RegionAdded (boost::weak_ptr<Region> (*s)); /* EMIT SIGNAL */
                dependent_checks_needed.insert (*s);
-               n++;
        }
 
-       if ((freeze_length != _get_maximum_extent()) || pending_length) {
-               pending_length = 0;
+       if (check_length) {
+               if (old_length != _get_maximum_extent()) {
+                       pending_length = true;
+                       cerr << _name << " length has changed\n";
+               }
+       }
+
+       if (pending_length || (freeze_length != _get_maximum_extent())) {
+               pending_length = false;
+               cerr << _name << " sends LengthChanged\n";
                LengthChanged(); /* EMIT SIGNAL */
-               n++;
        }
 
-       if (n || pending_modified) {
+       if (regions_changed || pending_contents_change) {
                if (!in_set_state) {
                        relayer ();
                }
-               pending_modified = false;
-               Modified (); /* EMIT SIGNAL */
+               pending_contents_change = false;
+               cerr << _name << " sends 5 contents change @ " << get_microseconds() << endl;
+               ContentsChanged (); /* EMIT SIGNAL */
+               cerr << _name << "done contents change @ " << get_microseconds() << endl;
        }
 
        for (s = dependent_checks_needed.begin(); s != dependent_checks_needed.end(); ++s) {
@@ -487,15 +522,24 @@ Playlist::flush_notifications ()
        }
 
        if (!pending_range_moves.empty ()) {
+               cerr << _name << " sends RangesMoved\n";
                RangesMoved (pending_range_moves);
        }
+       
+       clear_pending ();
 
+       in_flush = false;
+}
+
+void
+Playlist::clear_pending ()
+{
        pending_adds.clear ();
        pending_removes.clear ();
        pending_bounds.clear ();
        pending_range_moves.clear ();
-
-       in_flush = false;
+       pending_contents_change = false;
+       pending_length = false;
 }
 
 /*************************************************************
@@ -638,6 +682,7 @@ Playlist::remove_region_internal (boost::shared_ptr<Region> region)
 {
        RegionList::iterator i;
        nframes_t old_length = 0;
+       int ret = -1;
 
        if (!holding_state()) {
                old_length = _get_maximum_extent();
@@ -648,6 +693,8 @@ Playlist::remove_region_internal (boost::shared_ptr<Region> region)
                region->set_playlist (boost::weak_ptr<Playlist>());
        }
 
+       /* XXX should probably freeze here .... */
+
        for (i = regions.begin(); i != regions.end(); ++i) {
                if (*i == region) {
 
@@ -668,13 +715,14 @@ Playlist::remove_region_internal (boost::shared_ptr<Region> region)
                        }
 
                        notify_region_removed (region);
-                       return 0;
+                       ret = 0;
+                       break;
                }
        }
 
+       /* XXX and thaw ... */
 
-
-       return -1;
+       return ret;
 }
 
 void
@@ -1348,6 +1396,11 @@ Playlist::region_changed (Change what_changed, boost::shared_ptr<Region> region)
                notify_region_moved (region);
        }
 
+
+       /* don't notify about layer changes, since we are the only object that can initiate
+          them, and we notify in ::relayer()
+       */
+
        if (what_changed & our_interests) {
                save = true;
        }
@@ -1381,8 +1434,10 @@ Playlist::clear (bool with_signals)
        if (with_signals) {
                pending_length = false;
                LengthChanged ();
-               pending_modified = false;
-               Modified ();
+               pending_contents_change = false;
+               cerr << _name << "send2 contents change @ " << get_microseconds() << endl;
+               ContentsChanged ();
+               cerr << _name << "done with contents changed @ " << get_microseconds() << endl;
        }
 
 }
@@ -1842,12 +1897,16 @@ Playlist::set_state (const XMLNode& node, int version)
 
                                Change what_changed = Change (0);
 
-                               if (region->set_live_state (*child, version, what_changed, true)) {
-                                       error << _("Playlist: cannot reset region state from XML") << endmsg;
+                               region->freeze ();
+
+                               if (region->set_live_state (*child, version, what_changed, false)) {
+                                       region->thaw ("");
                                        continue;
                                }
 
-                       } else if ((region = RegionFactory::create (_session, *child, true)) == 0) {
+                       } else if ((region = RegionFactory::create (_session, *child, true)) != 0) {
+                               region->freeze ();
+                       } else {
                                error << _("Playlist: cannot create region from XML") << endmsg;
                                continue;
                        }
@@ -1856,14 +1915,10 @@ Playlist::set_state (const XMLNode& node, int version)
 
                        // So that layer_op ordering doesn't get screwed up
                        region->set_last_layer_op( region->layer());
-
+                       region->thaw ("");
                }
        }
 
-       notify_modified ();
-
-       thaw ();
-
        /* update dependents, which was not done during add_region_internal
           due to in_set_state being true
        */
@@ -1872,6 +1927,10 @@ Playlist::set_state (const XMLNode& node, int version)
                check_dependents (*r, false);
        }
 
+       clear_pending (); // this makes thaw() do nothing
+       thaw ();
+       notify_contents_changed ();
+
        in_set_state--;
        first_set_state = false;
        return 0;
@@ -1993,11 +2052,7 @@ Playlist::set_edit_mode (EditMode mode)
 void
 Playlist::relayer ()
 {
-       /* don't send multiple Modified notifications
-          when multiple regions are relayered.
-       */
-
-       freeze ();
+       bool changed = false;
 
        /* Build up a new list of regions on each layer, stored in a set of lists
           each of which represent some period of time on some layer.  The idea
@@ -2093,21 +2148,17 @@ Playlist::relayer ()
                for (int k = start_division; k <= end_division; ++k) {
                        layers[j][k].push_back (*i);
                }
+               
+               if ((*i)->layer() != j) {
+                       changed = true;
+               }
 
                (*i)->set_layer (j);
        }
 
-       /* sending Modified means that various kinds of layering
-          models operate correctly at the GUI
-          level. slightly inefficient, but only slightly.
-
-          We force a Modified signal here in case no layers actually
-          changed.
-       */
-
-       notify_modified ();
-
-       thaw ();
+       if (changed) {
+               notify_layering_changed ();
+       }
 }
 
 /* XXX these layer functions are all deprecated */
@@ -2454,7 +2505,7 @@ Playlist::shuffle (boost::shared_ptr<Region> region, int dir)
                relayer ();
                check_dependents (region, false);
 
-               notify_modified();
+               notify_contents_changed();
        }
 
 }
index 09f60926c48fd27a2f76bd994b2a506efa511adb..1f4d6f0f912221d78d3fc4739ea8840a82d13af4 100644 (file)
@@ -1148,6 +1148,7 @@ Region::set_live_state (const XMLNode& node, int /*version*/, Change& what_chang
                sscanf (prop->value().c_str(), "%" PRIu32, &val);
                if (val != _start) {
                        what_changed = Change (what_changed|StartChanged);
+                       cerr << _name << " start changed\n";
                        _start = val;
                }
        } else {
@@ -1158,6 +1159,7 @@ Region::set_live_state (const XMLNode& node, int /*version*/, Change& what_chang
                sscanf (prop->value().c_str(), "%" PRIu32, &val);
                if (val != _length) {
                        what_changed = Change (what_changed|LengthChanged);
+                       cerr << _name << " length changed\n";
                        _last_length = _length;
                        _length = val;
                }
@@ -1170,6 +1172,7 @@ Region::set_live_state (const XMLNode& node, int /*version*/, Change& what_chang
                sscanf (prop->value().c_str(), "%" PRIu32, &val);
                if (val != _position) {
                        what_changed = Change (what_changed|PositionChanged);
+                       cerr << _name << " position changed\n";
                        _last_position = _position;
                        _position = val;
                }
@@ -1183,6 +1186,7 @@ Region::set_live_state (const XMLNode& node, int /*version*/, Change& what_chang
                x = (layer_t) atoi (prop->value().c_str());
                if (x != _layer) {
                        what_changed = Change (what_changed|LayerChanged);
+                       cerr << _name << " layer changed\n";
                        _layer = x;
                }
        } else {
@@ -1193,6 +1197,7 @@ Region::set_live_state (const XMLNode& node, int /*version*/, Change& what_chang
                sscanf (prop->value().c_str(), "%" PRIu32, &val);
                if (val != _sync_position) {
                        what_changed = Change (what_changed|SyncOffsetChanged);
+                       cerr << _name << " sync changed\n";
                        _sync_position = val;
                }
        } else {
@@ -1281,6 +1286,7 @@ Region::set_live_state (const XMLNode& node, int /*version*/, Change& what_chang
        }
 
        if (send) {
+               cerr << _name << ": final change to be sent: " << hex << what_changed << dec << endl;
                send_change (what_changed);
        }
 
@@ -1346,12 +1352,13 @@ Region::thaw (const string& /*why*/)
                recompute_at_end ();
        }
 
-       StateChanged (what_changed);
+       send_change (what_changed);
 }
 
 void
 Region::send_change (Change what_changed)
 {
+
        {
                Glib::Mutex::Lock lm (_lock);
                if (_frozen) {
@@ -1360,7 +1367,9 @@ Region::send_change (Change what_changed)
                }
        }
 
+       cerr << _name << " actually sends " << hex << what_changed << dec << " @" << get_microseconds() << endl;
        StateChanged (what_changed);
+       cerr << _name << " done with " << hex << what_changed << dec << " @" << get_microseconds() << endl;
 
        if (!(_flags & DoNotSendPropertyChanges)) {
 
@@ -1370,7 +1379,9 @@ Region::send_change (Change what_changed)
 
                try {
                        boost::shared_ptr<Region> rptr = shared_from_this();
+                       cerr << _name << " actually sends prop change " << hex << what_changed << dec <<  " @ " << get_microseconds() << endl;
                        RegionPropertyChanged (rptr);
+                       cerr << _name << " done with prop change  @ " << get_microseconds() << endl;
                } catch (...) {
                        /* no shared_ptr available, relax; */
                }
index c3594b16584cf10c6b56f57c7aae068d2678afb6..8d6510191372f1a122f0eb0ae78bbd248bc613a6 100644 (file)
@@ -18,6 +18,7 @@
     $Id$
 */
 
+#include <iostream>
 #include <string>
 #include <sstream>
 #include <time.h>