strict i/o: limit output channels.
[ardour.git] / libs / ardour / session.cc
index d0fe74db2141850f5a1f77f4caf8db8be537f3db..edae568645e8e92634b445eb054a7567b76952e7 100644 (file)
@@ -204,8 +204,8 @@ Session::Session (AudioEngine &eng,
        , post_export_sync (false)
        , post_export_position (0)
        , _exporting (false)
-       , _export_started (false)
        , _export_rolling (false)
+       , _export_preroll (0)
        , _pre_export_mmc_enabled (false)
        , _name (snapshot_name)
        , _is_new (true)
@@ -232,6 +232,7 @@ Session::Session (AudioEngine &eng,
        , pending_auto_loop (false)
        , _mempool ("Session", 1048576)
        , lua (lua_newstate (&PBD::ReallocPool::lalloc, &_mempool))
+       , _n_lua_scripts (0)
        , _butler (new Butler (*this))
        , _post_transport_work (0)
        ,  cumulative_rf_motion (0)
@@ -2434,6 +2435,92 @@ Session::new_midi_track (const ChanCount& input, const ChanCount& output, boost:
        return ret;
 }
 
+RouteList
+Session::new_midi_route (RouteGroup* route_group, uint32_t how_many, string name_template, boost::shared_ptr<PluginInfo> instrument)
+{
+       string bus_name;
+       uint32_t bus_id = 0;
+       string port;
+       RouteList ret;
+
+       bool const use_number = (how_many != 1) || name_template.empty () || name_template == _("Midi Bus");
+
+       while (how_many) {
+               if (!find_route_name (name_template.empty () ? _("Midi Bus") : name_template, ++bus_id, bus_name, use_number)) {
+                       error << "cannot find name for new midi bus" << endmsg;
+                       goto failure;
+               }
+
+               try {
+                       boost::shared_ptr<Route> bus (new Route (*this, bus_name, Route::Flag(0), DataType::AUDIO)); // XXX Editor::add_routes is not ready for ARDOUR::DataType::MIDI
+
+                       if (bus->init ()) {
+                               goto failure;
+                       }
+
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
+                       // boost_debug_shared_ptr_mark_interesting (bus.get(), "Route");
+#endif
+                       {
+                               Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
+
+                               if (bus->input()->ensure_io (ChanCount(DataType::MIDI, 1), false, this)) {
+                                       error << _("cannot configure new midi bus input") << endmsg;
+                                       goto failure;
+                               }
+
+
+                               if (bus->output()->ensure_io (ChanCount(DataType::MIDI, 1), false, this)) {
+                                       error << _("cannot configure new midi bus output") << endmsg;
+                                       goto failure;
+                               }
+                       }
+
+                       if (route_group) {
+                               route_group->add (bus);
+                       }
+                       if (Config->get_remote_model() == UserOrdered) {
+                               bus->set_remote_control_id (next_control_id());
+                       }
+
+                       ret.push_back (bus);
+                       RouteAddedOrRemoved (true); /* EMIT SIGNAL */
+                       ARDOUR::GUIIdle ();
+               }
+
+               catch (failed_constructor &err) {
+                       error << _("Session: could not create new audio route.") << endmsg;
+                       goto failure;
+               }
+
+               catch (AudioEngine::PortRegistrationFailure& pfe) {
+                       error << pfe.what() << endmsg;
+                       goto failure;
+               }
+
+
+               --how_many;
+       }
+
+  failure:
+       if (!ret.empty()) {
+               StateProtector sp (this);
+               add_routes (ret, false, false, false);
+
+               if (instrument) {
+                       for (RouteList::iterator r = ret.begin(); r != ret.end(); ++r) {
+                               PluginPtr plugin = instrument->load (*this);
+                               boost::shared_ptr<Processor> p (new PluginInsert (*this, plugin));
+                               (*r)->add_processor (p, PreFader);
+                       }
+               }
+       }
+
+       return ret;
+
+}
+
+
 void
 Session::midi_output_change_handler (IOChange change, void * /*src*/, boost::weak_ptr<Route> wmt)
 {
@@ -3700,7 +3787,7 @@ Session::route_solo_changed (bool self_solo_change, Controllable::GroupControlDi
         */
 
        RouteGroup* rg = route->route_group ();
-       const bool group_already_accounted_for = route->use_group (group_override, &RouteGroup::is_solo);
+       const bool group_already_accounted_for = (group_override == Controllable::ForGroup);
 
        if (delta == 1 && Config->get_exclusive_solo()) {
 
@@ -5851,6 +5938,12 @@ Session::get_scratch_buffers (ChanCount count, bool silence)
        return ProcessThread::get_scratch_buffers (count, silence);
 }
 
+BufferSet&
+Session::get_noinplace_buffers (ChanCount count)
+{
+       return ProcessThread::get_noinplace_buffers (count);
+}
+
 BufferSet&
 Session::get_route_buffers (ChanCount count, bool silence)
 {