Make send automation work (#4734).
[ardour.git] / gtk2_ardour / port_group.cc
1 /*
2     Copyright (C) 2002-2009 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <cstring>
21 #include <boost/shared_ptr.hpp>
22 #include <boost/algorithm/string.hpp>
23
24 #include "midi++/manager.h"
25 #include "midi++/mmc.h"
26
27 #include "ardour/audioengine.h"
28 #include "ardour/auditioner.h"
29 #include "ardour/bundle.h"
30 #include "ardour/control_protocol_manager.h"
31 #include "ardour/io_processor.h"
32 #include "ardour/session.h"
33 #include "ardour/user_bundle.h"
34 #include "control_protocol/control_protocol.h"
35
36 #include "gui_thread.h"
37 #include "port_group.h"
38 #include "port_matrix.h"
39 #include "time_axis_view.h"
40 #include "public_editor.h"
41
42 #include "i18n.h"
43
44 using namespace std;
45 using namespace Gtk;
46 using namespace ARDOUR;
47
48 /** PortGroup constructor.
49  * @param n Name.
50  */
51 PortGroup::PortGroup (std::string const & n)
52         : name (n)
53 {
54
55 }
56
57 PortGroup::~PortGroup()
58 {
59         for (BundleList::iterator i = _bundles.begin(); i != _bundles.end(); ++i) {
60                 delete *i;
61         }
62         _bundles.clear ();
63 }
64
65 /** Add a bundle to a group.
66  *  @param b Bundle.
67  *  @param allow_dups true to allow the group to contain more than one bundle with the same port, otherwise false.
68  */
69 void
70 PortGroup::add_bundle (boost::shared_ptr<Bundle> b, bool allow_dups)
71 {
72         add_bundle_internal (b, boost::shared_ptr<IO> (), false, Gdk::Color (), allow_dups);
73 }
74
75 /** Add a bundle to a group.
76  *  @param b Bundle.
77  *  @param io IO whose ports are in the bundle.
78  */
79 void
80 PortGroup::add_bundle (boost::shared_ptr<Bundle> b, boost::shared_ptr<IO> io)
81 {
82         add_bundle_internal (b, io, false, Gdk::Color (), false);
83 }
84
85 /** Add a bundle to a group.
86  *  @param b Bundle.
87  *  @param c Colour to represent the bundle with.
88  */
89 void
90 PortGroup::add_bundle (boost::shared_ptr<Bundle> b, boost::shared_ptr<IO> io, Gdk::Color c)
91 {
92         add_bundle_internal (b, io, true, c, false);
93 }
94
95 PortGroup::BundleRecord::BundleRecord (boost::shared_ptr<ARDOUR::Bundle> b, boost::shared_ptr<ARDOUR::IO> iop, Gdk::Color c, bool has_c)
96         : bundle (b)
97         , io (iop)
98         , colour (c)
99         , has_colour (has_c)
100 {
101 }
102
103 void
104 PortGroup::add_bundle_internal (boost::shared_ptr<Bundle> b, boost::shared_ptr<IO> io, bool has_colour, Gdk::Color colour, bool allow_dups)
105 {
106         assert (b.get());
107
108         if (!allow_dups) {
109
110                 /* don't add this bundle if we already have one with the same ports */
111
112                 BundleList::iterator i = _bundles.begin ();
113                 while (i != _bundles.end() && b->has_same_ports ((*i)->bundle) == false) {
114                         ++i;
115                 }
116
117                 if (i != _bundles.end ()) {
118                         return;
119                 }
120         }
121
122         BundleRecord* br = new BundleRecord (b, io, colour, has_colour);
123         b->Changed.connect (br->changed_connection, invalidator (*this), boost::bind (&PortGroup::bundle_changed, this, _1), gui_context());
124         _bundles.push_back (br);
125
126         Changed ();
127 }
128
129 void
130 PortGroup::remove_bundle (boost::shared_ptr<Bundle> b)
131 {
132         assert (b.get());
133
134         BundleList::iterator i = _bundles.begin ();
135         while (i != _bundles.end() && (*i)->bundle != b) {
136                 ++i;
137         }
138
139         if (i == _bundles.end()) {
140                 return;
141         }
142
143         delete *i;
144         _bundles.erase (i);
145
146         Changed ();
147 }
148
149 void
150 PortGroup::bundle_changed (Bundle::Change c)
151 {
152         BundleChanged (c);
153 }
154
155
156 void
157 PortGroup::clear ()
158 {
159         for (BundleList::iterator i = _bundles.begin(); i != _bundles.end(); ++i) {
160                 delete *i;
161         }
162
163         _bundles.clear ();
164         Changed ();
165 }
166
167 bool
168 PortGroup::has_port (std::string const& p) const
169 {
170         for (BundleList::const_iterator i = _bundles.begin(); i != _bundles.end(); ++i) {
171                 if ((*i)->bundle->offers_port_alone (p)) {
172                         return true;
173                 }
174         }
175
176         return false;
177 }
178
179 boost::shared_ptr<Bundle>
180 PortGroup::only_bundle ()
181 {
182         assert (_bundles.size() == 1);
183         return _bundles.front()->bundle;
184 }
185
186
187 ChanCount
188 PortGroup::total_channels () const
189 {
190         ChanCount n;
191         for (BundleList::const_iterator i = _bundles.begin(); i != _bundles.end(); ++i) {
192                 n += (*i)->bundle->nchannels ();
193         }
194
195         return n;
196 }
197
198 boost::shared_ptr<IO>
199 PortGroup::io_from_bundle (boost::shared_ptr<ARDOUR::Bundle> b) const
200 {
201         BundleList::const_iterator i = _bundles.begin ();
202         while (i != _bundles.end() && (*i)->bundle != b) {
203                 ++i;
204         }
205
206         if (i == _bundles.end()) {
207                 return boost::shared_ptr<IO> ();
208         }
209
210         boost::shared_ptr<IO> io ((*i)->io.lock ());
211         return io;
212 }
213
214 /** Remove bundles whose channels are already represented by other, larger bundles */
215 void
216 PortGroup::remove_duplicates ()
217 {
218         BundleList::iterator i = _bundles.begin();
219         while (i != _bundles.end()) {
220
221                 BundleList::iterator tmp = i;
222                 ++tmp;
223
224                 bool remove = false;
225
226                 for (BundleList::iterator j = _bundles.begin(); j != _bundles.end(); ++j) {
227
228                         if ((*j)->bundle->nchannels() > (*i)->bundle->nchannels()) {
229                                 /* this bundle is larger */
230
231                                 uint32_t k = 0;
232                                 while (k < (*i)->bundle->nchannels().n_total()) {
233                                         /* see if this channel on *i has an equivalent on *j */
234                                         uint32_t l = 0;
235                                         while (l < (*j)->bundle->nchannels().n_total() && (*i)->bundle->channel_ports (k) != (*j)->bundle->channel_ports (l)) {
236                                                 ++l;
237                                         }
238
239                                         if (l == (*j)->bundle->nchannels().n_total()) {
240                                                 /* it does not */
241                                                 break;
242                                         }
243
244                                         ++k;
245                                 }
246
247                                 if (k == (*i)->bundle->nchannels().n_total()) {
248                                         /* all channels on *i are represented by the larger bundle *j, so remove *i */
249                                         remove = true;
250                                         break;
251                                 }
252                         }
253                 }
254
255                 if (remove) {
256                         _bundles.erase (i);
257                 }
258
259                 i = tmp;
260         }
261 }
262
263
264 /** PortGroupList constructor.
265  */
266 PortGroupList::PortGroupList ()
267         : _signals_suspended (false), _pending_change (false), _pending_bundle_change ((Bundle::Change) 0)
268 {
269
270 }
271
272 PortGroupList::~PortGroupList()
273 {
274         /* XXX need to clean up bundles, but ownership shared with PortGroups */
275 }
276
277 void
278 PortGroupList::maybe_add_processor_to_list (
279         boost::weak_ptr<Processor> wp, list<boost::shared_ptr<IO> >* route_ios, bool inputs, set<boost::shared_ptr<IO> >& used_io
280         )
281 {
282         boost::shared_ptr<Processor> p (wp.lock());
283
284         if (!p) {
285                 return;
286         }
287
288         boost::shared_ptr<IOProcessor> iop = boost::dynamic_pointer_cast<IOProcessor> (p);
289
290         if (iop) {
291
292                 boost::shared_ptr<IO> io = inputs ? iop->input() : iop->output();
293
294                 if (io && used_io.find (io) == used_io.end()) {
295                         route_ios->push_back (io);
296                         used_io.insert (io);
297                 }
298         }
299 }
300
301 struct RouteIOs {
302         RouteIOs (boost::shared_ptr<Route> r, boost::shared_ptr<IO> i) {
303                 route = r;
304                 ios.push_back (i);
305         }
306
307         boost::shared_ptr<Route> route;
308         /* it's ok to use a shared_ptr here as RouteIOs structs are only used during ::gather () */
309         std::list<boost::shared_ptr<IO> > ios;
310 };
311
312 class RouteIOsComparator {
313 public:
314         bool operator() (RouteIOs const & a, RouteIOs const & b) {
315                 return a.route->order_key (X_("editor")) < b.route->order_key (X_("editor"));
316         }
317 };
318
319 /** Gather ports from around the system and put them in this PortGroupList.
320  *  @param type Type of ports to collect, or NIL for all types.
321  *  @param use_session_bundles true to use the session's non-user bundles.  Doing this will mean that
322  *  hardware ports will be gathered into stereo pairs, as the session sets up bundles for these pairs.
323  *  Not using the session bundles will mean that all hardware IO will be presented separately.
324  */
325 void
326 PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inputs, bool allow_dups, bool use_session_bundles)
327 {
328         clear ();
329
330         if (session == 0) {
331                 return;
332         }
333
334         boost::shared_ptr<PortGroup> bus (new PortGroup (string_compose (_("%1 Busses"), PROGRAM_NAME)));
335         boost::shared_ptr<PortGroup> track (new PortGroup (string_compose (_("%1 Tracks"), PROGRAM_NAME)));
336         boost::shared_ptr<PortGroup> system (new PortGroup (_("Hardware")));
337         boost::shared_ptr<PortGroup> ardour (new PortGroup (string_compose (_("%1 Misc"), PROGRAM_NAME)));
338         boost::shared_ptr<PortGroup> other (new PortGroup (_("Other")));
339
340         /* Find the IOs which have bundles for routes and their processors.  We store
341            these IOs in a RouteIOs class so that we can then sort the results by route
342            order key.
343         */
344
345         boost::shared_ptr<RouteList> routes = session->get_routes ();
346         list<RouteIOs> route_ios;
347
348         for (RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
349
350                 /* we never show the monitor bus inputs */
351
352                 if (inputs && (*i)->is_monitor()) {
353                         continue;
354                 }
355
356                 /* keep track of IOs that we have taken bundles from,
357                    so that we can avoid taking the same IO from both
358                    Route::output() and the main_outs Delivery
359                 */
360
361                 set<boost::shared_ptr<IO> > used_io;
362                 boost::shared_ptr<IO> io = inputs ? (*i)->input() : (*i)->output();
363                 used_io.insert (io);
364
365                 RouteIOs rb (*i, io);
366                 (*i)->foreach_processor (boost::bind (&PortGroupList::maybe_add_processor_to_list, this, _1, &rb.ios, inputs, used_io));
367
368                 route_ios.push_back (rb);
369         }
370
371         /* Sort RouteIOs by the routes' editor order keys */
372         route_ios.sort (RouteIOsComparator ());
373
374         /* Now put the bundles that belong to these sorted RouteIOs into the PortGroup.
375            Note that if the RouteIO's bundles are multi-type, we may make new Bundles
376            with only the ports of one type.
377         */
378
379         for (list<RouteIOs>::iterator i = route_ios.begin(); i != route_ios.end(); ++i) {
380                 TimeAxisView* tv = PublicEditor::instance().axis_view_from_route (i->route);
381
382                 /* Work out which group to put these IOs' bundles in */
383                 boost::shared_ptr<PortGroup> g;
384                 if (boost::dynamic_pointer_cast<Track> (i->route)) {
385                         g = track;
386                 } else {
387                         g = bus;
388                 }
389
390                 for (list<boost::shared_ptr<IO> >::iterator j = i->ios.begin(); j != i->ios.end(); ++j) {
391                         if (tv) {
392                                 g->add_bundle ((*j)->bundle(), *j, tv->color ());
393                         } else {
394                                 g->add_bundle ((*j)->bundle(), *j);
395                         }
396                 }
397         }
398
399         /* Bundles owned by the session; add user bundles first, then normal ones, so
400            that UserBundles that offer the same ports as a normal bundle get priority
401         */
402
403         boost::shared_ptr<BundleList> b = session->bundles ();
404
405         for (BundleList::iterator i = b->begin(); i != b->end(); ++i) {
406                 if (boost::dynamic_pointer_cast<UserBundle> (*i) && (*i)->ports_are_inputs() == inputs) {
407                         system->add_bundle (*i, allow_dups);
408                 }
409         }
410
411         /* Only look for non-user bundles if instructed to do so */
412         if (use_session_bundles) {
413                 for (BundleList::iterator i = b->begin(); i != b->end(); ++i) {
414                         if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0 && (*i)->ports_are_inputs() == inputs) {
415                                 system->add_bundle (*i, allow_dups);
416                         }
417                 }
418         }
419
420         /* Ardour stuff */
421
422         if (!inputs) {
423                 ardour->add_bundle (session->the_auditioner()->output()->bundle());
424                 ardour->add_bundle (session->click_io()->bundle());
425         }
426
427         /* Ardour's surfaces */
428
429         ControlProtocolManager& m = ControlProtocolManager::instance ();
430         for (list<ControlProtocolInfo*>::iterator i = m.control_protocol_info.begin(); i != m.control_protocol_info.end(); ++i) {
431                 if ((*i)->protocol) {
432                         list<boost::shared_ptr<Bundle> > b = (*i)->protocol->bundles ();
433                         for (list<boost::shared_ptr<Bundle> >::iterator j = b.begin(); j != b.end(); ++j) {
434                                 if ((*j)->ports_are_inputs() == inputs) {
435                                         ardour->add_bundle (*j);
436                                 }
437                         }
438                 }
439         }
440
441         /* Ardour's sync ports */
442
443         MIDI::Manager* midi_manager = MIDI::Manager::instance ();
444         if (midi_manager && (type == DataType::MIDI || type == DataType::NIL)) {
445                 boost::shared_ptr<Bundle> sync (new Bundle (_("Sync"), inputs));
446                 MIDI::MachineControl* mmc = midi_manager->mmc ();
447                 AudioEngine& ae = session->engine ();
448                 if (inputs) {
449                         sync->add_channel (
450                                 _("MTC in"), DataType::MIDI, ae.make_port_name_non_relative (midi_manager->mtc_input_port()->name())
451                                 );
452                         sync->add_channel (
453                                 _("MIDI control in"), DataType::MIDI, ae.make_port_name_non_relative (midi_manager->midi_input_port()->name())
454                                 );
455                         sync->add_channel (
456                                 _("MIDI clock in"), DataType::MIDI, ae.make_port_name_non_relative (midi_manager->midi_clock_input_port()->name())
457                                 );
458                         sync->add_channel (
459                                 _("MMC in"), DataType::MIDI, ae.make_port_name_non_relative (mmc->input_port()->name())
460                                 );
461                 } else {
462                         sync->add_channel (
463                                 _("MTC out"), DataType::MIDI, ae.make_port_name_non_relative (midi_manager->mtc_output_port()->name())
464                                 );
465                         sync->add_channel (
466                                 _("MIDI control out"), DataType::MIDI, ae.make_port_name_non_relative (midi_manager->midi_output_port()->name())
467                                 );
468                         sync->add_channel (
469                                 _("MIDI clock out"), DataType::MIDI, ae.make_port_name_non_relative (midi_manager->midi_clock_output_port()->name())
470                                 );
471                         sync->add_channel (
472                                 _("MMC out"), DataType::MIDI, ae.make_port_name_non_relative (mmc->output_port()->name())
473                                 );
474                 }
475
476                 ardour->add_bundle (sync);
477         }
478
479         /* Now find all other ports that we haven't thought of yet */
480
481         std::vector<std::string> extra_system[DataType::num_types];
482         std::vector<std::string> extra_other[DataType::num_types];
483
484         string lpn (PROGRAM_NAME);
485         boost::to_lower (lpn);
486         string lpnc = lpn;
487         lpnc += ':';
488
489         const char ** ports = 0;
490         if (type == DataType::NIL) {
491                 ports = session->engine().get_ports ("", "", inputs ? JackPortIsInput : JackPortIsOutput);
492         } else {
493                 ports = session->engine().get_ports ("", type.to_jack_type(), inputs ? JackPortIsInput : JackPortIsOutput);
494         }
495
496         if (ports) {
497
498                 int n = 0;
499
500                 while (ports[n]) {
501
502                         std::string const p = ports[n];
503
504                         if (!system->has_port(p) &&
505                             !bus->has_port(p) &&
506                             !track->has_port(p) &&
507                             !ardour->has_port(p) &&
508                             !other->has_port(p)) {
509
510                                 /* special hack: ignore MIDI ports labelled Midi-Through. these
511                                    are basically useless and mess things up for default
512                                    connections.
513                                 */
514
515                                 if (p.find ("Midi-Through") != string::npos) {
516                                         ++n;
517                                         continue;
518                                 }
519
520                                 /* special hack: ignore our monitor inputs (which show up here because
521                                    we excluded them earlier.
522                                 */
523
524                                 string lp = p;
525                                 boost::to_lower (lp);
526
527                                 if ((lp.find (N_(":monitor")) != string::npos) &&
528                                     (lp.find (lpn) != string::npos)) {
529                                         ++n;
530                                         continue;
531                                 }
532
533                                 /* can't use the audio engine for this as we are looking at non-Ardour ports */
534
535                                 jack_port_t* jp = jack_port_by_name (session->engine().jack(), p.c_str());
536                                 if (jp) {
537                                         DataType t (jack_port_type (jp));
538                                         if (t != DataType::NIL) {
539                                                 if (port_has_prefix (p, N_("system:")) ||
540                                                     port_has_prefix (p, N_("alsa_pcm")) ||
541                                                     port_has_prefix (p, lpnc)) {
542                                                         extra_system[t].push_back (p);
543                                                 } else {
544                                                         extra_other[t].push_back (p);
545                                                 }
546                                         }
547                                 }
548                         }
549
550                         ++n;
551                 }
552
553                 free (ports);
554         }
555
556         for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
557                 if (!extra_system[*i].empty()) {
558                         boost::shared_ptr<Bundle> b = make_bundle_from_ports (extra_system[*i], *i, inputs);
559                         system->add_bundle (b);
560                 }
561         }
562
563         for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
564                 if (!extra_other[*i].empty()) {
565                         boost::shared_ptr<Bundle> b = make_bundle_from_ports (extra_other[*i], *i, inputs);
566                         other->add_bundle (b);
567                 }
568         }
569
570         if (!allow_dups) {
571                 system->remove_duplicates ();
572         }
573
574         add_group_if_not_empty (other);
575         if (type != DataType::MIDI) {
576                 add_group_if_not_empty (bus);
577         }
578         add_group_if_not_empty (track);
579         add_group_if_not_empty (ardour);
580         add_group_if_not_empty (system);
581
582         emit_changed ();
583 }
584
585 boost::shared_ptr<Bundle>
586 PortGroupList::make_bundle_from_ports (std::vector<std::string> const & p, ARDOUR::DataType type, bool inputs) const
587 {
588         boost::shared_ptr<Bundle> b (new Bundle ("", inputs));
589
590         std::string const pre = common_prefix (p);
591         if (!pre.empty()) {
592                 b->set_name (pre.substr (0, pre.length() - 1));
593         }
594
595         for (uint32_t j = 0; j < p.size(); ++j) {
596                 b->add_channel (p[j].substr (pre.length()), type);
597                 b->set_port (j, p[j]);
598         }
599
600         return b;
601 }
602
603 bool
604 PortGroupList::port_has_prefix (const std::string& n, const std::string& p) const
605 {
606         return n.substr (0, p.length()) == p;
607 }
608
609 std::string
610 PortGroupList::common_prefix_before (std::vector<std::string> const & p, std::string const & s) const
611 {
612         /* we must have some strings and the first must contain the separator string */
613         if (p.empty() || p[0].find_first_of (s) == std::string::npos) {
614                 return "";
615         }
616
617         /* prefix of the first string */
618         std::string const fp = p[0].substr (0, p[0].find_first_of (s) + 1);
619
620         /* see if the other strings also start with fp */
621         uint32_t j = 1;
622         while (j < p.size()) {
623                 if (p[j].substr (0, fp.length()) != fp) {
624                         break;
625                 }
626                 ++j;
627         }
628
629         if (j != p.size()) {
630                 return "";
631         }
632
633         return fp;
634 }
635
636
637 std::string
638 PortGroupList::common_prefix (std::vector<std::string> const & p) const
639 {
640         /* common prefix before '/' ? */
641         std::string cp = common_prefix_before (p, "/");
642         if (!cp.empty()) {
643                 return cp;
644         }
645
646         cp = common_prefix_before (p, ":");
647         if (!cp.empty()) {
648                 return cp;
649         }
650
651         return "";
652 }
653
654 void
655 PortGroupList::clear ()
656 {
657         _groups.clear ();
658         _bundle_changed_connections.drop_connections ();
659         emit_changed ();
660 }
661
662
663 PortGroup::BundleList const &
664 PortGroupList::bundles () const
665 {
666         _bundles.clear ();
667
668         for (PortGroupList::List::const_iterator i = begin (); i != end (); ++i) {
669                 std::copy ((*i)->bundles().begin(), (*i)->bundles().end(), std::back_inserter (_bundles));
670         }
671
672         return _bundles;
673 }
674
675 ChanCount
676 PortGroupList::total_channels () const
677 {
678         ChanCount n;
679
680         for (PortGroupList::List::const_iterator i = begin(); i != end(); ++i) {
681                 n += (*i)->total_channels ();
682         }
683
684         return n;
685 }
686
687 void
688 PortGroupList::add_group_if_not_empty (boost::shared_ptr<PortGroup> g)
689 {
690         if (!g->bundles().empty ()) {
691                 add_group (g);
692         }
693 }
694
695 void
696 PortGroupList::add_group (boost::shared_ptr<PortGroup> g)
697 {
698         _groups.push_back (g);
699
700         g->Changed.connect (_changed_connections, invalidator (*this), boost::bind (&PortGroupList::emit_changed, this), gui_context());
701         g->BundleChanged.connect (_bundle_changed_connections, invalidator (*this), boost::bind (&PortGroupList::emit_bundle_changed, this, _1), gui_context());
702
703         emit_changed ();
704 }
705
706 void
707 PortGroupList::remove_bundle (boost::shared_ptr<Bundle> b)
708 {
709         for (List::iterator i = _groups.begin(); i != _groups.end(); ++i) {
710                 (*i)->remove_bundle (b);
711         }
712
713         emit_changed ();
714 }
715
716 void
717 PortGroupList::emit_changed ()
718 {
719         if (_signals_suspended) {
720                 _pending_change = true;
721         } else {
722                 Changed ();
723         }
724 }
725
726 void
727 PortGroupList::emit_bundle_changed (Bundle::Change c)
728 {
729         if (_signals_suspended) {
730                 _pending_bundle_change = c;
731         } else {
732                 BundleChanged (c);
733         }
734 }
735 void
736 PortGroupList::suspend_signals ()
737 {
738         _signals_suspended = true;
739 }
740
741 void
742 PortGroupList::resume_signals ()
743 {
744         if (_pending_change) {
745                 Changed ();
746                 _pending_change = false;
747         }
748
749         if (_pending_bundle_change != 0) {
750                 BundleChanged (_pending_bundle_change);
751                 _pending_bundle_change = (ARDOUR::Bundle::Change) 0;
752         }
753
754         _signals_suspended = false;
755 }
756
757 boost::shared_ptr<IO>
758 PortGroupList::io_from_bundle (boost::shared_ptr<ARDOUR::Bundle> b) const
759 {
760         List::const_iterator i = _groups.begin ();
761         while (i != _groups.end()) {
762                 boost::shared_ptr<IO> io = (*i)->io_from_bundle (b);
763                 if (io) {
764                         return io;
765                 }
766                 ++i;
767         }
768
769         return boost::shared_ptr<IO> ();
770 }
771
772 bool
773 PortGroupList::empty () const
774 {
775         return _groups.empty ();
776 }
777