#include <glibmm/thread.h>
#include <glibmm/miscutils.h>
#include <glibmm/fileutils.h>
+#include <glibmm/thread.h>
#include "pbd/error.h"
-#include <glibmm/thread.h>
#include "pbd/boost_debug.h"
#include "pbd/pathscanner.h"
#include "pbd/stl_delete.h"
#include "ardour/tempo.h"
#include "ardour/utils.h"
+#include "midi++/jack.h"
+
#include "i18n.h"
using namespace std;
bool Session::_disable_all_loaded_plugins = false;
-boost::signals2::signal<void(std::string)> Session::Dialog;
-boost::signals2::signal<int()> Session::AskAboutPendingState;
-boost::signals2::signal<int(nframes_t,nframes_t)> Session::AskAboutSampleRateMismatch;
-boost::signals2::signal<void()> Session::SendFeedback;
+PBD::Signal1<void,std::string> Session::Dialog;
+PBD::Signal0<int> Session::AskAboutPendingState;
+PBD::Signal2<int,nframes_t,nframes_t> Session::AskAboutSampleRateMismatch;
+PBD::Signal0<void> Session::SendFeedback;
-boost::signals2::signal<void()> Session::TimecodeOffsetChanged;
-boost::signals2::signal<void()> Session::StartTimeChanged;
-boost::signals2::signal<void()> Session::EndTimeChanged;
-boost::signals2::signal<void()> Session::AutoBindingOn;
-boost::signals2::signal<void()> Session::AutoBindingOff;
-boost::signals2::signal<void(std::string, std::string)> Session::Exported;
+PBD::Signal0<void> Session::TimecodeOffsetChanged;
+PBD::Signal0<void> Session::StartTimeChanged;
+PBD::Signal0<void> Session::EndTimeChanged;
+PBD::Signal0<void> Session::AutoBindingOn;
+PBD::Signal0<void> Session::AutoBindingOff;
+PBD::Signal2<void,std::string, std::string> Session::Exported;
+PBD::Signal1<int,boost::shared_ptr<Playlist> > Session::AskAboutPlaylistDeletion;
static void clean_up_session_event (SessionEvent* ev) { delete ev; }
const SessionEvent::RTeventCallback Session::rt_cleanup (clean_up_session_event);
_state_of_the_state = StateOfTheState (_state_of_the_state & ~Dirty);
- scoped_connect (Config->ParameterChanged, boost::bind (&Session::config_changed, this, _1, false));
- scoped_connect (config.ParameterChanged, boost::bind (&Session::config_changed, this, _1, true));
+ Config->ParameterChanged.connect_same_thread (*this, boost::bind (&Session::config_changed, this, _1, false));
+ config.ParameterChanged.connect_same_thread (*this, boost::bind (&Session::config_changed, this, _1, true));
if (was_dirty) {
DirtyChanged (); /* EMIT SIGNAL */
if (master_out_channels) {
ChanCount count(DataType::AUDIO, master_out_channels);
Route* rt = new Route (*this, _("master"), Route::MasterOut, DataType::AUDIO);
- boost_debug_shared_ptr_mark_interesting (rt, typeid (rt).name());
- shared_ptr<Route> r (rt);
+ boost_debug_shared_ptr_mark_interesting (rt, "Route");
+ boost::shared_ptr<Route> r (rt);
r->input()->ensure_io (count, false, this);
r->output()->ensure_io (count, false, this);
r->set_remote_control_id (control_id);
if (control_out_channels) {
ChanCount count(DataType::AUDIO, control_out_channels);
Route* rt = new Route (*this, _("monitor"), Route::ControlOut, DataType::AUDIO);
- boost_debug_shared_ptr_mark_interesting (rt, typeid (rt).name());
+ boost_debug_shared_ptr_mark_interesting (rt, "Route");
shared_ptr<Route> r (rt);
r->input()->ensure_io (count, false, this);
r->output()->ensure_io (count, false, this);
_state_of_the_state = StateOfTheState (_state_of_the_state & ~Dirty);
- scoped_connect (Config->ParameterChanged, boost::bind (&Session::config_changed, this, _1, false));
+ Config->ParameterChanged.connect_same_thread (*this, boost::bind (&Session::config_changed, this, _1, false));
}
Session::~Session ()
Stateful::loading_state_version = 0;
- _butler->terminate_thread ();
-
+ delete _butler;
delete midi_control_ui;
if (click_data != default_click) {
AudioDiskstream::free_working_buffers();
- // BOOST::SIGNALS: Route::SyncOrderKeys.clear();
-
- DEBUG_TRACE (DEBUG::Destruction, "delete named selections\n");
- for (NamedSelectionList::iterator i = named_selections.begin(); i != named_selections.end(); ) {
- NamedSelectionList::iterator tmp;
+ /* tell everyone who is still standing that we're about to die */
+ drop_references ();
- tmp = i;
- ++tmp;
+ /* tell everyone to drop references and delete objects as we go */
- delete *i;
- i = tmp;
- }
+ DEBUG_TRACE (DEBUG::Destruction, "delete named selections\n");
+ named_selections.clear ();
DEBUG_TRACE (DEBUG::Destruction, "delete regions\n");
- for (RegionList::iterator i = regions.begin(); i != regions.end(); ) {
- RegionList::iterator tmp;
-
- tmp = i;
- ++tmp;
-
- boost::shared_ptr<Region> keep (i->second);
-
- DEBUG_TRACE(DEBUG::Destruction, string_compose ("Dropping for region %1 (%2); pre-ref = %3\n", i->second->name(), i->second.get(), i->second.use_count()));
+ for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
+ DEBUG_TRACE(DEBUG::Destruction, string_compose ("Dropping for region %1 ; pre-ref = %2\n", i->second->name(), i->second.use_count()));
i->second->drop_references ();
- DEBUG_TRACE(DEBUG::Destruction, string_compose ("region post ref = %1\n", i->second.use_count()));
- i = tmp;
}
-
regions.clear ();
DEBUG_TRACE (DEBUG::Destruction, "delete routes\n");
{
RCUWriter<RouteList> writer (routes);
boost::shared_ptr<RouteList> r = writer.get_copy ();
+
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
DEBUG_TRACE(DEBUG::Destruction, string_compose ("Dropping for route %1 ; pre-ref = %2\n", (*i)->name(), (*i).use_count()));
(*i)->drop_references ();
}
+
r->clear ();
/* writer goes out of scope and updates master */
}
routes.flush ();
+ boost::shared_ptr<RouteList> r = routes.reader ();
+
DEBUG_TRACE (DEBUG::Destruction, "delete diskstreams\n");
{
RCUWriter<DiskstreamList> dwriter (diskstreams);
DEBUG_TRACE(DEBUG::Destruction, string_compose ("Dropping for diskstream %1 ; pre-ref = %2\n", (*i)->name(), (*i).use_count()));
(*i)->drop_references ();
}
+
dsl->clear ();
}
diskstreams.flush ();
DEBUG_TRACE (DEBUG::Destruction, "delete sources\n");
- for (SourceMap::iterator i = sources.begin(); i != sources.end(); ) {
- SourceMap::iterator tmp;
-
- tmp = i;
- ++tmp;
-
+ for (SourceMap::iterator i = sources.begin(); i != sources.end(); ++i) {
DEBUG_TRACE(DEBUG::Destruction, string_compose ("Dropping for source %1 ; pre-ref = %2\n", i->second->path(), i->second.use_count()));
i->second->drop_references ();
-
- i = tmp;
}
sources.clear ();
-
DEBUG_TRACE (DEBUG::Destruction, "delete route groups\n");
for (list<RouteGroup *>::iterator i = _route_groups.begin(); i != _route_groups.end(); ++i) {
+
delete *i;
}
/* not strictly necessary, but doing it here allows the shared_ptr debugging to work */
playlists.reset ();
- /* tell everyone who is still standing that we're about to die */
-
- drop_references ();
-
boost_debug_list_ptrs ();
DEBUG_TRACE (DEBUG::Destruction, "Session::destroy() done\n");
/* every time we reconnect, recompute worst case output latencies */
- scoped_connect (_engine.Running, boost::bind (&Session::set_worst_io_latencies, this));
+ _engine.Running.connect_same_thread (*this, boost::bind (&Session::set_worst_io_latencies, this));
if (synced_to_jack()) {
_engine.transport_stop ();
/* Tell all IO objects to connect themselves together */
IO::enable_connecting ();
+ MIDI::JACK_MidiPort::MakeConnections ();
/* Now reset all panners */
boost::shared_ptr<Playlist> playlist;
if ((playlist = dstream->playlist()) != 0) {
- scoped_connect (playlist->LengthChanged, boost::bind (&Session::playlist_length_changed, this));
+ playlist->LengthChanged.connect_same_thread (*this, boost::bind (&Session::playlist_length_changed, this));
}
/* see comment in playlist_length_changed () */
punch_connections.drop_connections ();
- punch_connections.add_connection (location->start_changed.connect (boost::bind (&Session::auto_punch_start_changed, this, _1)));
- punch_connections.add_connection (location->end_changed.connect (boost::bind (&Session::auto_punch_end_changed, this, _1)));
- punch_connections.add_connection (location->changed.connect (boost::bind (&Session::auto_punch_changed, this, _1)));
+ location->start_changed.connect_same_thread (punch_connections, boost::bind (&Session::auto_punch_start_changed, this, _1));
+ location->end_changed.connect_same_thread (punch_connections, boost::bind (&Session::auto_punch_end_changed, this, _1));
+ location->changed.connect_same_thread (punch_connections, boost::bind (&Session::auto_punch_changed, this, _1));
location->set_auto_punch (true, this);
loop_connections.drop_connections ();
- loop_connections.add_connection (location->start_changed.connect (boost::bind (&Session::auto_loop_changed, this, _1)));
- loop_connections.add_connection (location->end_changed.connect (boost::bind (&Session::auto_loop_changed, this, _1)));
- loop_connections.add_connection (location->changed.connect (boost::bind (&Session::auto_loop_changed, this, _1)));
+ location->start_changed.connect_same_thread (loop_connections, boost::bind (&Session::auto_loop_changed, this, _1));
+ location->end_changed.connect_same_thread (loop_connections, boost::bind (&Session::auto_loop_changed, this, _1));
+ location->changed.connect_same_thread (loop_connections, boost::bind (&Session::auto_loop_changed, this, _1));
location->set_auto_loop (true, this);
route_group->add (track);
}
- scoped_connect (track->DiskstreamChanged, boost::bind (&Session::resort_routes, this));
+ track->DiskstreamChanged.connect_same_thread (*this, boost::bind (&Session::resort_routes, this));
//track->set_remote_control_id (control_id);
new_routes.push_back (track);
try {
AudioTrack* at = new AudioTrack (*this, track_name, Route::Flag (0), mode);
- boost_debug_shared_ptr_mark_interesting (at, typeid (at).name());
+ boost_debug_shared_ptr_mark_interesting (at, "Track");
track = boost::shared_ptr<AudioTrack>(at);
if (track->input()->ensure_io (ChanCount(DataType::AUDIO, input_channels), false, this)) {
track->audio_diskstream()->non_realtime_input_change();
- scoped_connect (track->DiskstreamChanged, boost::bind (&Session::resort_routes, this));
+ track->DiskstreamChanged.connect_same_thread (*this, boost::bind (&Session::resort_routes, this));
track->set_remote_control_id (control_id);
++control_id;
Session::set_remote_control_ids ()
{
RemoteModel m = Config->get_remote_model();
+ bool emit_signal = false;
shared_ptr<RouteList> r = routes.reader ();
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
- if ( MixerOrdered == m) {
+ if (MixerOrdered == m) {
long order = (*i)->order_key(N_("signal"));
- (*i)->set_remote_control_id( order+1 );
- } else if ( EditorOrdered == m) {
+ (*i)->set_remote_control_id (order+1, false);
+ emit_signal = true;
+ } else if (EditorOrdered == m) {
long order = (*i)->order_key(N_("editor"));
- (*i)->set_remote_control_id( order+1 );
- } else if ( UserOrdered == m) {
+ (*i)->set_remote_control_id (order+1, false);
+ emit_signal = true;
+ } else if (UserOrdered == m) {
//do nothing ... only changes to remote id's are initiated by user
}
}
+
+ if (emit_signal) {
+ Route::RemoteControlIDChange();
+ }
}
try {
Route* rt = new Route (*this, bus_name, Route::Flag(0), DataType::AUDIO);
- boost_debug_shared_ptr_mark_interesting (rt, typeid (rt).name());
+ boost_debug_shared_ptr_mark_interesting (rt, "Route");
shared_ptr<Route> bus (rt);
if (bus->input()->ensure_io (ChanCount(DataType::AUDIO, input_channels), false, this)) {
for (RouteList::iterator x = new_routes.begin(); x != new_routes.end(); ++x) {
boost::weak_ptr<Route> wpr (*x);
+ boost::shared_ptr<Route> r (*x);
- scoped_connect ((*x)->listen_changed, boost::bind (&Session::route_listen_changed, this, _1, wpr));
- scoped_connect ((*x)->solo_changed, boost::bind (&Session::route_solo_changed, this, _1, wpr));
- scoped_connect ((*x)->mute_changed, boost::bind (&Session::route_mute_changed, this, _1));
- scoped_connect ((*x)->output()->changed, boost::bind (&Session::set_worst_io_latencies_x, this, _1, _2));
- scoped_connect ((*x)->processors_changed, boost::bind (&Session::route_processors_changed, this, _1));
- scoped_connect ((*x)->route_group_changed, boost::bind (&Session::route_group_changed, this));
+ r->listen_changed.connect_same_thread (*this, boost::bind (&Session::route_listen_changed, this, _1, wpr));
+ r->solo_changed.connect_same_thread (*this, boost::bind (&Session::route_solo_changed, this, _1, wpr));
+ r->mute_changed.connect_same_thread (*this, boost::bind (&Session::route_mute_changed, this, _1));
+ r->output()->changed.connect_same_thread (*this, boost::bind (&Session::set_worst_io_latencies_x, this, _1, _2));
+ r->processors_changed.connect_same_thread (*this, boost::bind (&Session::route_processors_changed, this, _1));
+ r->route_group_changed.connect_same_thread (*this, boost::bind (&Session::route_group_changed, this));
- if ((*x)->is_master()) {
- _master_out = (*x);
+ if (r->is_master()) {
+ _master_out = r;
}
- if ((*x)->is_control()) {
- _control_out = (*x);
+ if (r->is_control()) {
+ _control_out = r;
}
}
}
RouteAdded (new_routes); /* EMIT SIGNAL */
+ Route::RemoteControlIDChange (); /* EMIT SIGNAL */
}
void
/* writer goes out of scope, copies ds back to main */
}
- scoped_connect (dstream->PlaylistChanged, boost::bind (&Session::diskstream_playlist_changed, this, boost::weak_ptr<Diskstream> (dstream)));
+ dstream->PlaylistChanged.connect_same_thread (*this, boost::bind (&Session::diskstream_playlist_changed, this, boost::weak_ptr<Diskstream> (dstream)));
/* this will connect to future changes, and check the current length */
diskstream_playlist_changed (boost::weak_ptr<Diskstream> (dstream));
- scoped_connect (dstream->RecordEnableChanged, boost::bind (&Session::update_have_rec_enabled_diskstream, this));
+ dstream->RecordEnableChanged.connect_same_thread (*this, boost::bind (&Session::update_have_rec_enabled_diskstream, this));
dstream->prepare ();
sync_order_keys (N_("session"));
+ Route::RemoteControlIDChange(); /* EMIT SIGNAL */
+
/* save the new state of the world */
if (save_state (_current_snapshot_name)) {
}
}
- scoped_connect (region->StateChanged, boost::bind (&Session::region_changed, this, _1, boost::weak_ptr<Region>(region)));
- scoped_connect (region->GoingAway, boost::bind (&Session::remove_region, this, boost::weak_ptr<Region>(region)));
-
+ region->StateChanged.connect_same_thread (*this, boost::bind (&Session::region_changed, this, _1, boost::weak_ptr<Region>(region)));
update_region_name_map (region);
}
}
}
+ for (list<boost::shared_ptr<Region> >::iterator i = r.begin(); i != r.end(); ++i) {
+ remove_region (*i);
+ }
+
destroy_regions (r);
save_state (_current_snapshot_name);
}
if (result.second) {
- scoped_connect (source->GoingAway, boost::bind (&Session::remove_source, this, boost::weak_ptr<Source> (source)));
set_dirty();
}
return;
}
- bool existing = playlists->add (playlist);
- if (!existing) {
- scoped_connect (playlist->GoingAway, boost::bind (&Session::remove_playlist, this, boost::weak_ptr<Playlist>(playlist)));
- }
+ playlists->add (playlist);
if (unused) {
playlist->release();
void
Session::add_processor (Processor* processor)
{
- scoped_connect (processor->GoingAway, boost::bind (&Session::remove_processor, this, processor));
+ /* Session does not own Processors (they belong to a Route) but we do want to track
+ the arrival and departure of port inserts, sends and returns for naming
+ purposes.
+ */
+ processor->DropReferences.connect_same_thread (*this, boost::bind (&Session::remove_processor, this, processor));
set_dirty();
}
/* Named Selection management */
-NamedSelection *
+boost::shared_ptr<NamedSelection>
Session::named_selection_by_name (string name)
{
Glib::Mutex::Lock lm (named_selection_lock);
for (NamedSelectionList::iterator i = named_selections.begin(); i != named_selections.end(); ++i) {
if ((*i)->name == name) {
- return* i;
+ return *i;
}
}
- return 0;
+ return boost::shared_ptr<NamedSelection>();
}
void
-Session::add_named_selection (NamedSelection* named_selection)
+Session::add_named_selection (boost::shared_ptr<NamedSelection> named_selection)
{
{
Glib::Mutex::Lock lm (named_selection_lock);
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 */
}
void
-Session::remove_named_selection (NamedSelection* named_selection)
+Session::remove_named_selection (boost::shared_ptr<NamedSelection> named_selection)
{
bool removed = false;
NamedSelectionList::iterator i = find (named_selections.begin(), named_selections.end(), named_selection);
if (i != named_selections.end()) {
- delete (*i);
named_selections.erase (i);
set_dirty();
removed = true;
void
Session::sync_order_keys (std::string const & base)
{
+ if (deletion_in_progress()) {
+ return;
+ }
+
if (!Config->get_sync_all_route_ordering()) {
/* leave order keys as they are */
return;
}
Route::SyncOrderKeys (base); // EMIT SIGNAL
-}
+ /* this might not do anything */
+
+ set_remote_control_ids ();
+}
/** @return true if there is at least one record-enabled diskstream, otherwise false */
bool