fix AU cache clear
[ardour.git] / gtk2_ardour / plugin_pin_dialog.cc
index da3c096d9279fe8f55ba60ed777bfad7cf9fae20..346f1e771866986145f00a7d872b23ed6d68b11a 100644 (file)
@@ -284,6 +284,13 @@ PluginPinDialog::plugin_reconfigured ()
        _add_sc_audio.set_sensitive (_pi->has_sidechain ());
        _add_sc_midi.set_sensitive (_pi->has_sidechain ());
 
+#ifdef MIXBUS
+       if (_pi->plugin (0)->get_info()->type == ARDOUR::AudioUnit) {
+               _set_config.set_sensitive (false);
+               _tgl_sidechain.set_sensitive (false);
+       }
+#endif
+
        if (_pi->custom_cfg ()) {
                _set_config.set_active (true);
                _add_plugin.set_sensitive (true);
@@ -343,6 +350,9 @@ PluginPinDialog::plugin_reconfigured ()
                _elements.push_back (CtrlWidget ("", Output, (i < _out.n_midi () ? DataType::MIDI : DataType::AUDIO), id));
        }
 
+       _in_map.clear ();
+       _out_map.clear ();
+
        for (uint32_t n = 0; n < _n_plugins; ++n) {
                boost::shared_ptr<Plugin> plugin = _pi->plugin (n);
                for (uint32_t i = 0; i < _sinks.n_total (); ++i) {
@@ -358,7 +368,13 @@ PluginPinDialog::plugin_reconfigured ()
                        const Plugin::IOPortDescription& iod (plugin->describe_io_port (dt, false, idx));
                        _elements.push_back (CtrlWidget (iod.name, Source, dt, idx, n));
                }
+               _in_map[n] = _pi->input_map (n);
+               _out_map[n] = _pi->output_map (n);
        }
+       _has_midi_bypass = _pi->has_midi_bypass ();
+       _thru_map = _pi->thru_map ();
+
+       /* cache maps */
 
        /* calc minimum size */
        const uint32_t max_ports = std::max (_ins.n_total (), _out.n_total ());
@@ -504,14 +520,20 @@ PluginPinDialog::port_label (const std::string& portname, bool strip)
        boost::to_lower (lpn);
        std::string program_port_prefix = lpn + ":"; // e.g. "ardour:"
 
+       std::string pn = AudioEngine::instance ()->get_pretty_name_by_name (portname);
+       if (!pn.empty ()) {
+               string::size_type slash = pn.find ("/");
+               if (slash != string::npos) {
+                       pn = pn.substr (0, slash);
+               }
+               return pn;
+       }
        std::string label (portname);
        if (label.find ("system:capture_") == 0) {
-               label = AudioEngine::instance ()->get_pretty_name_by_name (label);
                if (label.empty ()) {
                        label = portname.substr (15);
                }
        } else if (label.find ("system:midi_capture_") == 0) {
-               label = AudioEngine::instance ()->get_pretty_name_by_name (label);
                if (label.empty ()) {
                        // "system:midi_capture_123" -> "123"
                        label = "M " + portname.substr (20);
@@ -958,15 +980,22 @@ PluginPinDialog::darea_expose_event (GdkEventExpose* ev)
        cairo_set_source_rgba (cr, 1., 1., 1., 1.);
        pango_cairo_show_layout (cr, layout->gobj ());
 
-       if (_pi->signal_latency () > 0) {
-               // TODO: this needs a better location also format to msec (and cache)
+#ifndef NDEBUG
+       if (_pi->signal_latency () > 0 || !_pi->inplace()) {
                layout->set_width ((_innerwidth - 2 * _pin_box_size) * PANGO_SCALE);
-               layout->set_text (string_compose (_("Latency %1 spl"), _pi->signal_latency ()));
+               if (_pi->signal_latency () > 0 && !_pi->inplace()) {
+                       layout->set_text (string_compose (_("Latency %1 spl%2 %3"), _pi->signal_latency (), ", ", _("no-inplace")));
+               } else if (_pi->signal_latency () > 0) {
+                       layout->set_text (string_compose (_("Latency %1 spl"), _pi->signal_latency ()));
+               } else {
+                       layout->set_text (_("no-inplace"));
+               }
                layout->get_pixel_size (text_width, text_height);
                cairo_move_to (cr, _margin_x + _pin_box_size * .5, _margin_y + 2);
                cairo_set_source_rgba (cr, 1., 1., 1., 1.);
                pango_cairo_show_layout (cr, layout->gobj ());
        }
+#endif
 
        if (_pi->strict_io () && !Profile->get_mixbus ()) {
                layout->set_text (_("Strict I/O"));
@@ -985,14 +1014,14 @@ PluginPinDialog::darea_expose_event (GdkEventExpose* ev)
        }
 
        /* draw midi-bypass (behind) */
-       if (_pi->has_midi_bypass ()) {
+       if (_has_midi_bypass) {
                const CtrlWidget& cw0 = get_io_ctrl (Input, DataType::MIDI, 0);
                const CtrlWidget& cw1 = get_io_ctrl (Output, DataType::MIDI, 0);
                draw_connection (cr, cw0, cw1, true);
        }
 
        /* thru connections */
-       const ChanMapping::Mappings thru_map = _pi->thru_map ().mappings ();
+       const ChanMapping::Mappings thru_map (_thru_map.mappings ());
        for (ChanMapping::Mappings::const_iterator t = thru_map.begin (); t != thru_map.end (); ++t) {
                for (ChanMapping::TypeMapping::const_iterator c = (*t).second.begin (); c != (*t).second.end () ; ++c) {
                        const CtrlWidget& cw0 = get_io_ctrl (Output, t->first, c->first);
@@ -1003,7 +1032,6 @@ PluginPinDialog::darea_expose_event (GdkEventExpose* ev)
                }
        }
 
-
        /* plugins & connection wires */
        for (uint32_t i = 0; i < _n_plugins; ++i) {
                double x0 = _margin_x + rint ((i + .5) * _innerwidth / (double)(_n_plugins)) - .5;
@@ -1020,8 +1048,8 @@ PluginPinDialog::darea_expose_event (GdkEventExpose* ev)
                cairo_set_source_rgba (cr, 1., 1., 1., 1.);
                pango_cairo_show_layout (cr, layout->gobj ());
 
-               const ChanMapping::Mappings in_map = _pi->input_map (i).mappings ();
-               const ChanMapping::Mappings out_map = _pi->output_map (i).mappings ();
+               const ChanMapping::Mappings in_map = _in_map[i].mappings ();
+               const ChanMapping::Mappings out_map = _out_map[i].mappings ();
 
                for (ChanMapping::Mappings::const_iterator t = in_map.begin (); t != in_map.end (); ++t) {
                        for (ChanMapping::TypeMapping::const_iterator c = (*t).second.begin (); c != (*t).second.end () ; ++c) {
@@ -1123,7 +1151,7 @@ PluginPinDialog::start_drag (const CtrlElem& e, double x, double y)
        _drag_dst.reset ();
        if (e->ct == Sink) {
                bool valid;
-               const ChanMapping& map (_pi->input_map (e->ip));
+               const ChanMapping& map (_in_map[e->ip]);
                uint32_t idx = map.get (e->dt, e->id, &valid);
                if (valid) {
                        const CtrlWidget& cw = get_io_ctrl (Input, e->dt, idx, 0);
@@ -1134,7 +1162,7 @@ PluginPinDialog::start_drag (const CtrlElem& e, double x, double y)
        else if (e->ct == Output) {
                for (uint32_t i = 0; i < _n_plugins; ++i) {
                        bool valid;
-                       const ChanMapping& map (_pi->output_map (i));
+                       const ChanMapping& map (_out_map[i]);
                        uint32_t idx = map.get_src (e->dt, e->id, &valid);
                        if (valid) {
                                const CtrlWidget& cw = get_io_ctrl (Source, e->dt, idx, i);
@@ -1145,7 +1173,7 @@ PluginPinDialog::start_drag (const CtrlElem& e, double x, double y)
                }
                if (!_drag_dst) {
                        bool valid;
-                       const ChanMapping& map (_pi->thru_map ());
+                       const ChanMapping& map (_thru_map);
                        uint32_t idx = map.get (e->dt, e->id, &valid);
                        if (valid) {
                                const CtrlWidget& cw = get_io_ctrl (Input, e->dt, idx, 0);
@@ -1640,7 +1668,7 @@ PluginPinDialog::add_send_from (boost::weak_ptr<ARDOUR::Port> wp, boost::weak_pt
        }
 
        boost::shared_ptr<Pannable> sendpan (new Pannable (*_session));
-       boost::shared_ptr<Send> send (new Send (*_session, sendpan, r->mute_master ()));
+       boost::shared_ptr<Send> send (new Send (*_session, r->pannable (), r->mute_master ()));
        const ChanCount& outs (r->amp ()->input_streams ());
        try {
                Glib::Threads::Mutex::Lock lm (AudioEngine::instance ()->process_lock ());
@@ -1650,8 +1678,15 @@ PluginPinDialog::add_send_from (boost::weak_ptr<ARDOUR::Port> wp, boost::weak_pt
                return;
        }
 
-       _ignore_updates = true;
+       std::string sendname = send->name ();
+       string::size_type last_letter = sendname.find_last_not_of ("0123456789");
+       if (last_letter != string::npos) {
+               send->output ()->set_pretty_name (string_compose (_("SC %1 (%2)"),
+                               r->name (),
+                               sendname.substr (last_letter + 1)));
+       }
 
+       _ignore_updates = true;
        p->disconnect_all ();
 
        DataType dt = p->type ();
@@ -1756,18 +1791,8 @@ PluginPinDialog::maybe_add_route_to_input_menu (boost::shared_ptr<Route> r, Data
                if (send->output ()->connected_to (_pi->sidechain_input ())) {
                        // only if (send->remove_on_disconnect ()) ??
                        already_present = true;
-                       ++nth;
-                       continue;
-               }
-#if 1 // add existing sends that are not connected
-               PortSet& p (send->output ()->ports ());
-               for (PortSet::iterator i = p.begin (dt); i != p.end (dt); ++i) {
-                       std::string n = i->name ();
-                       replace_all (n, "_", " ");
-                       citems.push_back (MenuElem (n, sigc::bind (sigc::mem_fun (*this, &PluginPinDialog::connect_port), wp, boost::weak_ptr<Port> (*i))));
-                       ++added;
+                       break;
                }
-#endif
                ++nth;
        }
        /* we're going to create the new send pre-fader, so check the route amp's data type.  */