+
+
+/**
+ * Setup bundles that describe our inputs and outputs.
+ */
+
+void
+IO::setup_bundles ()
+{
+ char buf[32];
+
+ snprintf(buf, sizeof (buf), _("%s in"), _name.c_str());
+ _bundle_for_inputs->set_name (buf, 0);
+ int const ins = n_inputs().n_total();
+ _bundle_for_inputs->set_nchannels (ins);
+
+ for (int i = 0; i < ins; ++i) {
+ _bundle_for_inputs->add_port_to_channel (i, _inputs.port(i)->name ());
+ }
+
+ snprintf(buf, sizeof (buf), _("%s out"), _name.c_str());
+ _bundle_for_outputs->set_name (buf, 0);
+ int const outs = n_outputs().n_total();
+ _bundle_for_outputs->set_nchannels (outs);
+
+ for (int i = 0; i < outs; ++i) {
+ _bundle_for_outputs->add_port_to_channel (i, _outputs.port(i)->name ());
+ }
+}
+
+
+/**
+ * Create and setup bundles that describe our inputs and outputs.
+ */
+
+void
+IO::create_bundles ()
+{
+ _bundle_for_inputs = boost::shared_ptr<Bundle> (
+ new InputBundle ("", true)
+ );
+
+ _bundle_for_outputs = boost::shared_ptr<Bundle> (
+ new OutputBundle ("", true)
+ );
+
+ setup_bundles ();
+}
+
+boost::shared_ptr<Bundle>
+IO::input_bundle()
+{
+ if (_input_bundle) {
+ return _input_bundle;
+ }
+
+ /* XXX: will only report the first bundle found; should really return a list, I think */
+
+ /* check that _input_bundle is right wrt the connections that are currently made */
+
+ /* make a vector of the first output connected to each of our inputs */
+ std::vector<std::string> connected;
+ for (uint32_t i = 0; i < _inputs.num_ports(); ++i) {
+ const char** c = _inputs.port(i)->get_connections ();
+ if (c) {
+ connected.push_back (c[0]);
+ }
+ }
+
+ _input_bundle = _session.bundle_by_ports (connected);
+ return _input_bundle;
+}
+
+
+boost::shared_ptr<Bundle>
+IO::output_bundle()
+{
+ if (_output_bundle) {
+ return _output_bundle;
+ }
+
+ /* XXX: will only report the first bundle found; should really return a list, I think */
+
+ /* check that _output_bundle is right wrt the connections that are currently made */
+
+ /* make a vector of the first input connected to each of our outputs */
+ std::vector<std::string> connected;
+ for (uint32_t i = 0; i < _outputs.num_ports(); ++i) {
+ const char** c = _outputs.port(i)->get_connections ();
+ if (c) {
+ connected.push_back (c[0]);
+ }
+ }
+
+ _output_bundle = _session.bundle_by_ports (connected);
+ return _output_bundle;
+}