RAII to postpone processor changes/graph recalculation
This commit is contained in:
parent
98f1cb76ed
commit
4d81e3ec07
|
@ -581,20 +581,40 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
|
||||||
StateOfTheState state_of_the_state() const { return _state_of_the_state; }
|
StateOfTheState state_of_the_state() const { return _state_of_the_state; }
|
||||||
|
|
||||||
class StateProtector {
|
class StateProtector {
|
||||||
public:
|
public:
|
||||||
StateProtector (Session* s) : _session (s) {
|
StateProtector (Session* s) : _session (s) {
|
||||||
g_atomic_int_inc (&s->_suspend_save);
|
g_atomic_int_inc (&s->_suspend_save);
|
||||||
}
|
}
|
||||||
~StateProtector () {
|
~StateProtector () {
|
||||||
if (g_atomic_int_dec_and_test (&_session->_suspend_save)) {
|
if (g_atomic_int_dec_and_test (&_session->_suspend_save)) {
|
||||||
while (_session->_save_queued) {
|
while (_session->_save_queued) {
|
||||||
_session->_save_queued = false;
|
_session->_save_queued = false;
|
||||||
_session->save_state ("");
|
_session->save_state ("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
private:
|
||||||
private:
|
Session * _session;
|
||||||
Session * _session;
|
};
|
||||||
|
|
||||||
|
class ProcessorChangeBlocker {
|
||||||
|
public:
|
||||||
|
ProcessorChangeBlocker (Session* s, bool rc = true)
|
||||||
|
: _session (s)
|
||||||
|
, _reconfigure_on_delete (rc)
|
||||||
|
{
|
||||||
|
g_atomic_int_inc (&s->_ignore_route_processor_changes);
|
||||||
|
}
|
||||||
|
~ProcessorChangeBlocker () {
|
||||||
|
if (g_atomic_int_dec_and_test (&_session->_ignore_route_processor_changes)) {
|
||||||
|
if (_reconfigure_on_delete) {
|
||||||
|
_session->route_processors_changed (RouteProcessorChange ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
Session* _session;
|
||||||
|
bool _reconfigure_on_delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
void add_route_group (RouteGroup *);
|
void add_route_group (RouteGroup *);
|
||||||
|
@ -2005,7 +2025,9 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
|
||||||
GraphEdges _current_route_graph;
|
GraphEdges _current_route_graph;
|
||||||
|
|
||||||
void ensure_route_presentation_info_gap (PresentationInfo::order_t, uint32_t gap_size);
|
void ensure_route_presentation_info_gap (PresentationInfo::order_t, uint32_t gap_size);
|
||||||
bool ignore_route_processor_changes;
|
|
||||||
|
friend class ProcessorChangeBlocker;
|
||||||
|
gint _ignore_route_processor_changes; /* atomic */
|
||||||
|
|
||||||
MidiClockTicker* midi_clock;
|
MidiClockTicker* midi_clock;
|
||||||
|
|
||||||
|
|
|
@ -312,7 +312,7 @@ Session::Session (AudioEngine &eng,
|
||||||
, _step_editors (0)
|
, _step_editors (0)
|
||||||
, _suspend_timecode_transmission (0)
|
, _suspend_timecode_transmission (0)
|
||||||
, _speakers (new Speakers)
|
, _speakers (new Speakers)
|
||||||
, ignore_route_processor_changes (false)
|
, _ignore_route_processor_changes (0)
|
||||||
, midi_clock (0)
|
, midi_clock (0)
|
||||||
, _scene_changer (0)
|
, _scene_changer (0)
|
||||||
, _midi_ports (0)
|
, _midi_ports (0)
|
||||||
|
@ -1129,7 +1129,7 @@ Session::remove_monitor_section ()
|
||||||
|
|
||||||
|
|
||||||
boost::shared_ptr<RouteList> r = routes.reader ();
|
boost::shared_ptr<RouteList> r = routes.reader ();
|
||||||
PBD::Unwinder<bool> uw (ignore_route_processor_changes, true);
|
ProcessorChangeBlocker pcb (this, false);
|
||||||
|
|
||||||
for (RouteList::iterator x = r->begin(); x != r->end(); ++x) {
|
for (RouteList::iterator x = r->begin(); x != r->end(); ++x) {
|
||||||
|
|
||||||
|
@ -1289,7 +1289,7 @@ Session::add_monitor_section ()
|
||||||
|
|
||||||
boost::shared_ptr<RouteList> rls = routes.reader ();
|
boost::shared_ptr<RouteList> rls = routes.reader ();
|
||||||
|
|
||||||
PBD::Unwinder<bool> uw (ignore_route_processor_changes, true);
|
ProcessorChangeBlocker pcb (this, false /* XXX */);
|
||||||
|
|
||||||
for (RouteList::iterator x = rls->begin(); x != rls->end(); ++x) {
|
for (RouteList::iterator x = rls->begin(); x != rls->end(); ++x) {
|
||||||
|
|
||||||
|
@ -1413,7 +1413,7 @@ Session::reset_monitor_section ()
|
||||||
|
|
||||||
boost::shared_ptr<RouteList> rls = routes.reader ();
|
boost::shared_ptr<RouteList> rls = routes.reader ();
|
||||||
|
|
||||||
PBD::Unwinder<bool> uw (ignore_route_processor_changes, true);
|
ProcessorChangeBlocker pcb (this, false);
|
||||||
|
|
||||||
for (RouteList::iterator x = rls->begin(); x != rls->end(); ++x) {
|
for (RouteList::iterator x = rls->begin(); x != rls->end(); ++x) {
|
||||||
|
|
||||||
|
@ -3662,7 +3662,7 @@ Session::remove_routes (boost::shared_ptr<RouteList> routes_to_remove)
|
||||||
/* if the monitoring section had a pointer to this route, remove it */
|
/* if the monitoring section had a pointer to this route, remove it */
|
||||||
if (_monitor_out && !(*iter)->is_master() && !(*iter)->is_monitor()) {
|
if (_monitor_out && !(*iter)->is_master() && !(*iter)->is_monitor()) {
|
||||||
Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
|
Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
|
||||||
PBD::Unwinder<bool> uw (ignore_route_processor_changes, true);
|
ProcessorChangeBlocker pcb (this, false);
|
||||||
(*iter)->remove_aux_or_listen (_monitor_out);
|
(*iter)->remove_aux_or_listen (_monitor_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6216,14 +6216,11 @@ Session::update_route_record_state ()
|
||||||
void
|
void
|
||||||
Session::listen_position_changed ()
|
Session::listen_position_changed ()
|
||||||
{
|
{
|
||||||
{
|
ProcessorChangeBlocker pcb (this);
|
||||||
boost::shared_ptr<RouteList> r = routes.reader ();
|
boost::shared_ptr<RouteList> r = routes.reader ();
|
||||||
PBD::Unwinder<bool> uw (ignore_route_processor_changes, true);
|
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
|
||||||
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
|
(*i)->listen_position_changed ();
|
||||||
(*i)->listen_position_changed ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
route_processors_changed (RouteProcessorChange ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -1992,7 +1992,7 @@ Session::xrun_recovery ()
|
||||||
void
|
void
|
||||||
Session::route_processors_changed (RouteProcessorChange c)
|
Session::route_processors_changed (RouteProcessorChange c)
|
||||||
{
|
{
|
||||||
if (ignore_route_processor_changes) {
|
if (g_atomic_int_get (&_ignore_route_processor_changes) > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user