if (new_session) {
if (create (new_session, mix_template, compute_initial_length())) {
cerr << "create failed\n";
+ destroy ();
throw failed_constructor ();
}
}
if (second_stage_init (new_session)) {
- cerr << "2nd state failed\n";
+ destroy ();
throw failed_constructor ();
}
if (new_session) {
if (create (new_session, 0, initial_length)) {
+ destroy ();
throw failed_constructor ();
}
}
- if (control_out_channels) {
- shared_ptr<Route> r (new Route (*this, _("monitor"), -1, control_out_channels, -1, control_out_channels, Route::ControlOut));
- RouteList rl;
- rl.push_back (r);
- add_routes (rl);
- _control_out = r;
- }
-
- if (master_out_channels) {
- shared_ptr<Route> r (new Route (*this, _("master"), -1, master_out_channels, -1, master_out_channels, Route::MasterOut));
+ {
+ /* set up Master Out and Control Out if necessary */
+
RouteList rl;
- rl.push_back (r);
- add_routes (rl);
- _master_out = r;
- } else {
- /* prohibit auto-connect to master, because there isn't one */
- output_ac = AutoConnectOption (output_ac & ~AutoConnectMaster);
+ int control_id = 1;
+
+ if (control_out_channels) {
+ shared_ptr<Route> r (new Route (*this, _("monitor"), -1, control_out_channels, -1, control_out_channels, Route::ControlOut));
+ r->set_remote_control_id (control_id++);
+
+ rl.push_back (r);
+ }
+
+ if (master_out_channels) {
+ shared_ptr<Route> r (new Route (*this, _("master"), -1, master_out_channels, -1, master_out_channels, Route::MasterOut));
+ r->set_remote_control_id (control_id);
+
+ rl.push_back (r);
+ } else {
+ /* prohibit auto-connect to master, because there isn't one */
+ output_ac = AutoConnectOption (output_ac & ~AutoConnectMaster);
+ }
+
+ if (!rl.empty()) {
+ add_routes (rl);
+ }
+
}
Config->set_input_auto_connect (input_ac);
Config->set_output_auto_connect (output_ac);
if (second_stage_init (new_session)) {
+ destroy ();
throw failed_constructor ();
}
_state_of_the_state = StateOfTheState (_state_of_the_state & ~Dirty);
+ Config->ParameterChanged.connect (mem_fun (*this, &Session::config_changed));
+
if (was_dirty) {
DirtyChanged (); /* EMIT SIGNAL */
}
}
Session::~Session ()
+{
+ destroy ();
+}
+
+void
+Session::destroy ()
{
/* if we got to here, leaving pending capture state around
is a mistake.
string port;
RouteList new_routes;
list<boost::shared_ptr<AudioTrack> > ret;
+ uint32_t control_id;
/* count existing audio tracks */
_engine.get_physical_outputs (physoutputs);
_engine.get_physical_inputs (physinputs);
+ control_id = ntracks() + nbusses() + 1;
while (how_many) {
}
track->DiskstreamChanged.connect (mem_fun (this, &Session::resort_routes));
- track->set_remote_control_id (ntracks());
+ track->set_remote_control_id (control_id);
+ ++control_id;
new_routes.push_back (track);
ret.push_back (track);
uint32_t n = 0;
string port;
RouteList ret;
+ uint32_t control_id;
/* count existing audio busses */
_engine.get_physical_outputs (physoutputs);
_engine.get_physical_inputs (physinputs);
+ control_id = ntracks() + nbusses() + 1;
while (how_many) {
bus->set_control_outs (cports);
}
+ bus->set_remote_control_id (control_id);
+ ++control_id;
+
ret.push_back (bus);
}
source->GoingAway.connect (sigc::bind (mem_fun (this, &Session::remove_source), boost::weak_ptr<Source> (source)));
set_dirty();
}
+
}
}
if (cnt > limit) {
error << string_compose(_("There are already %1 recordings for %2, which I consider too many."), limit, name) << endmsg;
+ destroy ();
throw failed_constructor();
}
}
{
Glib::Mutex::Lock lm (playlist_lock);
- cerr << "removing playlist: " << playlist->name() << endl;
PlaylistList::iterator i;
i = find (playlists.begin(), playlists.end(), playlist);
if (i != playlists.end()) {
- cerr << "\tfound it in used playlist\n";
playlists.erase (i);
}
i = find (unused_playlists.begin(), unused_playlists.end(), playlist);
if (i != unused_playlists.end()) {
- cerr << "\tfound it in unused playlist\n";
unused_playlists.erase (i);
}
Insert* insert;
PortInsert* port_insert;
PluginInsert* plugin_insert;
-
+
if ((insert = dynamic_cast<Insert *> (redirect)) != 0) {
if ((port_insert = dynamic_cast<PortInsert *> (insert)) != 0) {
- _port_inserts.remove (port_insert);
+ list<PortInsert*>::iterator x = find (_port_inserts.begin(), _port_inserts.end(), port_insert);
+ if (x != _port_inserts.end()) {
+ insert_bitset[port_insert->bit_slot()] = false;
+ _port_inserts.erase (x);
+ }
} else if ((plugin_insert = dynamic_cast<PluginInsert *> (insert)) != 0) {
_plugin_inserts.remove (plugin_insert);
} else {
/*NOTREACHED*/
}
} else if ((send = dynamic_cast<Send *> (redirect)) != 0) {
- _sends.remove (send);
+ list<Send*>::iterator x = find (_sends.begin(), _sends.end(), send);
+ if (x != _sends.end()) {
+ send_bitset[send->bit_slot()] = false;
+ _sends.erase (x);
+ }
} else {
fatal << _("programming error: unknown type of Redirect deleted!") << endmsg;
/*NOTREACHED*/
allocate_pan_automation_buffers (current_block_size, howmany, false);
}
-string
-Session::next_send_name ()
+uint32_t
+Session::next_insert_id ()
{
- uint32_t cnt = 0;
-
- shared_ptr<RouteList> r = routes.reader ();
-
- for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) {
- cnt += (*i)->count_sends ();
+ /* this doesn't really loop forever. just think about it */
+
+ while (true) {
+ for (boost::dynamic_bitset<uint32_t>::size_type n = 0; n < insert_bitset.size(); ++n) {
+ if (!insert_bitset[n]) {
+ insert_bitset[n] = true;
+ cerr << "Returning " << n << " as insert ID\n";
+ return n;
+
+ }
+ }
+
+ /* none available, so resize and try again */
+
+ insert_bitset.resize (insert_bitset.size() + 16, false);
+ }
+}
+
+uint32_t
+Session::next_send_id ()
+{
+ /* this doesn't really loop forever. just think about it */
+
+ while (true) {
+ for (boost::dynamic_bitset<uint32_t>::size_type n = 0; n < send_bitset.size(); ++n) {
+ if (!send_bitset[n]) {
+ send_bitset[n] = true;
+ cerr << "Returning " << n << " as send ID\n";
+ return n;
+
+ }
+ }
+
+ /* none available, so resize and try again */
+
+ send_bitset.resize (send_bitset.size() + 16, false);
}
+}
- return string_compose (_("send %1"), ++cnt);
+void
+Session::mark_send_id (uint32_t id)
+{
+ if (id >= send_bitset.size()) {
+ send_bitset.resize (id+16, false);
+ }
+ if (send_bitset[id]) {
+ warning << string_compose (_("send ID %1 appears to be in use already"), id) << endmsg;
+ }
+ send_bitset[id] = true;
}
-string
-Session::next_insert_name ()
+void
+Session::mark_insert_id (uint32_t id)
{
- char buf[32];
- snprintf (buf, sizeof (buf), "insert %" PRIu32, ++insert_cnt);
- return buf;
+ if (id >= insert_bitset.size()) {
+ insert_bitset.resize (id+16, false);
+ }
+ if (insert_bitset[id]) {
+ warning << string_compose (_("insert ID %1 appears to be in use already"), id) << endmsg;
+ }
+ insert_bitset[id] = true;
}
/* Named Selection management */
named_selections.insert (named_selections.begin(), named_selection);
}
+ for (list<boost::shared_ptr<Playlist> >::iterator i = named_selection->playlists.begin(); i != named_selection->playlists.end(); ++i) {
+ add_playlist (*i);
+ }
+
set_dirty();
- NamedSelectionAdded (); /* EMIT SIGNAL */
+ NamedSelectionAdded (); /* EMIT SIGNAL */
}
void
return true;
}
-int
-Session::cleanup_audio_file_source (boost::shared_ptr<AudioFileSource> fs)
-{
- return fs->move_to_trash (dead_sound_dir_name);
-}
-
uint32_t
Session::n_playlists () const
{
/* construct a region to represent the bounced material */
boost::shared_ptr<Region> aregion = RegionFactory::create (srcs, 0, srcs.front()->length(),
- region_name_from_path (srcs.front()->name()));
+ region_name_from_path (srcs.front()->name(), true));
ret = 0;
}