add new A/B comparison for plugins, plus ways of disabling all plugins quickly (not undoable at this time)

git-svn-id: svn://localhost/ardour2/trunk@1840 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2007-05-14 14:13:59 +00:00
parent 20cdab6416
commit bac4734a13
11 changed files with 304 additions and 6 deletions

View file

@ -108,6 +108,9 @@ class Redirect : public IO
bool find_next_event (nframes_t, nframes_t, ControlEvent&) const;
virtual void transport_stopped (nframes_t frame) {};
bool get_next_ab_is_active () const { return _next_ab_is_active; }
void set_next_ab_is_active (bool yn);
protected:
/* children may use this stuff as they see fit */
@ -127,6 +130,7 @@ class Redirect : public IO
private:
bool _active;
bool _next_ab_is_active;
Placement _placement;
uint32_t _sort_key;
void* _gui; /* generic, we don't know or care what this is */

View file

@ -168,7 +168,11 @@ class Route : public IO
int remove_redirect (boost::shared_ptr<Redirect>, void *src, uint32_t* err_streams = 0);
int copy_redirects (const Route&, Placement, uint32_t* err_streams = 0);
int sort_redirects (uint32_t* err_streams = 0);
void disable_redirects (Placement);
void disable_redirects ();
void disable_plugins (Placement);
void disable_plugins ();
void ab_plugins (bool forward);
void clear_redirects (Placement, void *src);
void all_redirects_flip();
void all_redirects_active (Placement, bool state);
@ -202,6 +206,9 @@ class Route : public IO
int set_state(const XMLNode& node);
virtual XMLNode& get_template();
XMLNode& get_redirect_state ();
int set_redirect_state (const XMLNode&);
sigc::signal<void,void*> SelectedChanged;
int set_control_outs (const vector<std::string>& ports);

View file

@ -613,13 +613,13 @@ PluginInsert::state (bool full)
/* add port automation state */
XMLNode *autonode = new XMLNode(port_automation_node_name);
set<uint32_t> automatable = _plugins[0]->automatable();
for (set<uint32_t>::iterator x = automatable.begin(); x != automatable.end(); ++x) {
XMLNode* child = new XMLNode("port");
snprintf(buf, sizeof(buf), "%" PRIu32, *x);
child->add_property("number", string(buf));
child->add_child_nocopy (automation_list (*x).state (full));
autonode->add_child_nocopy (*child);
}

View file

@ -51,6 +51,7 @@ Redirect::Redirect (Session& s, const string& name, Placement p,
{
_placement = p;
_active = false;
_next_ab_is_active = false;
_sort_key = 0;
_gui = 0;
_extra_xml = 0;
@ -477,3 +478,8 @@ Redirect::set_active (bool yn, void* src)
_session.set_dirty ();
}
void
Redirect::set_next_ab_is_active (bool yn)
{
_next_ab_is_active = yn;
}

View file

@ -883,6 +883,110 @@ Route::add_redirects (const RedirectList& others, void *src, uint32_t* err_strea
return 0;
}
/** Turn off all redirects with a given placement
* @param p Placement of redirects to disable
*/
void
Route::disable_redirects (Placement p)
{
Glib::RWLock::ReaderLock lm (redirect_lock);
for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
if ((*i)->placement() == p) {
(*i)->set_active (false, this);
}
}
}
/** Turn off all redirects
*/
void
Route::disable_redirects ()
{
Glib::RWLock::ReaderLock lm (redirect_lock);
for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
(*i)->set_active (false, this);
}
}
/** Turn off all redirects with a given placement
* @param p Placement of redirects to disable
*/
void
Route::disable_plugins (Placement p)
{
Glib::RWLock::ReaderLock lm (redirect_lock);
for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
if (boost::dynamic_pointer_cast<PluginInsert> (*i) && (*i)->placement() == p) {
(*i)->set_active (false, this);
}
}
}
/** Turn off all plugins
*/
void
Route::disable_plugins ()
{
Glib::RWLock::ReaderLock lm (redirect_lock);
for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
(*i)->set_active (false, this);
}
}
}
void
Route::ab_plugins (bool forward)
{
Glib::RWLock::ReaderLock lm (redirect_lock);
if (forward) {
/* forward = turn off all active redirects, and mark them so that the next time
we go the other way, we will revert them
*/
for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
if (!boost::dynamic_pointer_cast<PluginInsert> (*i)) {
continue;
}
if ((*i)->active()) {
(*i)->set_active (false, this);
(*i)->set_next_ab_is_active (true);
} else {
(*i)->set_next_ab_is_active (false);
}
}
} else {
/* backward = if the redirect was marked to go active on the next ab, do so */
for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
if (!boost::dynamic_pointer_cast<PluginInsert> (*i)) {
continue;
}
if ((*i)->get_next_ab_is_active()) {
(*i)->set_active (true, this);
} else {
(*i)->set_active (false, this);
}
}
}
}
/** Remove redirects with a given placement.
* @param p Placement of redirects to remove.
*/
@ -1424,6 +1528,74 @@ Route::state(bool full_state)
return *node;
}
XMLNode&
Route::get_redirect_state ()
{
XMLNode* root = new XMLNode (X_("redirects"));
for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
root->add_child_nocopy ((*i)->state (true));
}
return *root;
}
int
Route::set_redirect_state (const XMLNode& root)
{
if (root.name() != X_("redirects")) {
return -1;
}
XMLNodeList nlist;
XMLNodeList nnlist;
XMLNodeConstIterator iter;
XMLNodeConstIterator niter;
Glib::RWLock::ReaderLock lm (redirect_lock);
nlist = root.children();
for (iter = nlist.begin(); iter != nlist.end(); ++iter){
/* iter now points to a Redirect state node */
nnlist = (*iter)->children ();
for (niter = nnlist.begin(); niter != nnlist.end(); ++niter) {
/* find the IO child node, since it contains the ID we need */
/* XXX OOP encapsulation violation, ugh */
if ((*niter)->name() == IO::state_node_name) {
XMLProperty* prop = (*niter)->property (X_("id"));
if (!prop) {
warning << _("Redirect node has no ID, ignored") << endmsg;
break;
}
ID id = prop->value ();
/* now look for a redirect with that ID */
for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
if ((*i)->id() == id) {
(*i)->set_state (**iter);
break;
}
}
break;
}
}
}
return 0;
}
void
Route::set_deferred_state ()
{