#include <unistd.h>
#include <limits.h>
-#include <sigc++/bind.h>
-#include <sigc++/retype.h>
#include <glibmm/thread.h>
#include <glibmm/miscutils.h>
#include "pbd/error.h"
#include <glibmm/thread.h>
+#include "pbd/boost_debug.h"
#include "pbd/pathscanner.h"
#include "pbd/stl_delete.h"
#include "pbd/basename.h"
#include "ardour/crossfade.h"
#include "ardour/cycle_timer.h"
#include "ardour/data_type.h"
+#include "ardour/debug.h"
#include "ardour/filename_extensions.h"
#include "ardour/internal_send.h"
#include "ardour/io_processor.h"
#include "ardour/midi_playlist.h"
#include "ardour/midi_region.h"
#include "ardour/midi_track.h"
+#include "ardour/midi_ui.h"
#include "ardour/named_selection.h"
#include "ardour/playlist.h"
#include "ardour/plugin_insert.h"
#include "ardour/session_directory.h"
#include "ardour/session_directory.h"
#include "ardour/session_metadata.h"
+#include "ardour/session_playlists.h"
#include "ardour/slave.h"
#include "ardour/smf_source.h"
#include "ardour/source_factory.h"
using namespace ARDOUR;
using namespace PBD;
using boost::shared_ptr;
+using boost::weak_ptr;
bool Session::_disable_all_loaded_plugins = false;
-sigc::signal<void,std::string> Session::Dialog;
-sigc::signal<int> Session::AskAboutPendingState;
-sigc::signal<int,nframes_t,nframes_t> Session::AskAboutSampleRateMismatch;
-sigc::signal<void> Session::SendFeedback;
+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;
-sigc::signal<void> Session::TimecodeOffsetChanged;
-sigc::signal<void> Session::StartTimeChanged;
-sigc::signal<void> Session::EndTimeChanged;
-sigc::signal<void> Session::AutoBindingOn;
-sigc::signal<void> Session::AutoBindingOff;
-sigc::signal<void, std::string, std::string> Session::Exported;
+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;
+
+static void clean_up_session_event (SessionEvent* ev) { delete ev; }
+const SessionEvent::RTeventCallback Session::rt_cleanup (clean_up_session_event);
Session::Session (AudioEngine &eng,
const string& fullpath,
_midi_port (default_midi_port),
_midi_clock_port (default_midi_clock_port),
_session_dir (new SessionDirectory(fullpath)),
- pending_events (2048),
state_tree (0),
- _butler (new Butler (this)),
+ _butler (new Butler (*this)),
_post_transport_work (0),
_send_timecode_update (false),
- midi_thread (pthread_t (0)),
- midi_requests (128), // the size of this should match the midi request pool size
diskstreams (new DiskstreamList),
routes (new RouteList),
_total_free_4k_blocks (0),
_have_rec_enabled_diskstream (false)
{
+ playlists.reset (new SessionPlaylists);
+
bool new_session;
interpolation.add_channel_to (0, 0);
_state_of_the_state = StateOfTheState (_state_of_the_state & ~Dirty);
- Config->ParameterChanged.connect (bind (mem_fun (*this, &Session::config_changed), false));
- config.ParameterChanged.connect (bind (mem_fun (*this, &Session::config_changed), true));
+ scoped_connect (Config->ParameterChanged, boost::bind (&Session::config_changed, this, _1, false));
+ scoped_connect (config.ParameterChanged, boost::bind (&Session::config_changed, this, _1, true));
if (was_dirty) {
DirtyChanged (); /* EMIT SIGNAL */
_midi_port (default_midi_port),
_midi_clock_port (default_midi_clock_port),
_session_dir ( new SessionDirectory(fullpath)),
- pending_events (2048),
state_tree (0),
- _butler (new Butler (this)),
+ _butler (new Butler (*this)),
_post_transport_work (0),
_send_timecode_update (false),
- midi_thread (pthread_t (0)),
- midi_requests (16),
diskstreams (new DiskstreamList),
routes (new RouteList),
_total_free_4k_blocks (0),
_metadata (new SessionMetadata()),
_have_rec_enabled_diskstream (false)
{
+ playlists.reset (new SessionPlaylists);
+
bool new_session;
interpolation.add_channel_to (0, 0);
if (master_out_channels) {
ChanCount count(DataType::AUDIO, master_out_channels);
- shared_ptr<Route> r (new Route (*this, _("master"), Route::MasterOut, DataType::AUDIO));
+ 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);
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);
- shared_ptr<Route> r (new Route (*this, _("monitor"), Route::ControlOut, DataType::AUDIO));
+ Route* rt = new Route (*this, _("monitor"), Route::ControlOut, DataType::AUDIO);
+ boost_debug_shared_ptr_mark_interesting (rt, typeid (rt).name());
+ 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++);
_state_of_the_state = StateOfTheState (_state_of_the_state & ~Dirty);
- Config->ParameterChanged.connect (bind (mem_fun (*this, &Session::config_changed), false));
+ scoped_connect (Config->ParameterChanged, boost::bind (&Session::config_changed, this, _1, false));
}
Session::~Session ()
void
Session::destroy ()
{
+ vector<void*> debug_pointers;
+
/* if we got to here, leaving pending capture state around
is a mistake.
*/
_engine.remove_session ();
- GoingAway (); /* EMIT SIGNAL */
-
- /* do this */
-
- notify_callbacks ();
-
/* clear history so that no references to objects are held any more */
_history.clear ();
Stateful::loading_state_version = 0;
_butler->terminate_thread ();
- //terminate_midi_thread ();
+
+ delete midi_control_ui;
if (click_data != default_click) {
delete [] click_data;
delete _silent_buffers;
delete _mix_buffers;
+ /* clear out any pending dead wood from RCU managed objects */
+
+ routes.flush ();
+ diskstreams.flush ();
+ _bundles.flush ();
+
AudioDiskstream::free_working_buffers();
- Route::SyncOrderKeys.clear();
+ // BOOST::SIGNALS: Route::SyncOrderKeys.clear();
-#undef TRACK_DESTRUCTION
-#ifdef TRACK_DESTRUCTION
- cerr << "delete named selections\n";
-#endif /* TRACK_DESTRUCTION */
+ DEBUG_TRACE (DEBUG::Destruction, "delete named selections\n");
for (NamedSelectionList::iterator i = named_selections.begin(); i != named_selections.end(); ) {
NamedSelectionList::iterator tmp;
i = tmp;
}
-#ifdef TRACK_DESTRUCTION
- cerr << "delete playlists\n";
-#endif /* TRACK_DESTRUCTION */
- for (PlaylistList::iterator i = playlists.begin(); i != playlists.end(); ) {
- PlaylistList::iterator tmp;
-
- tmp = i;
- ++tmp;
-
- (*i)->drop_references ();
-
- i = tmp;
- }
-
- for (PlaylistList::iterator i = unused_playlists.begin(); i != unused_playlists.end(); ) {
- PlaylistList::iterator tmp;
-
- tmp = i;
- ++tmp;
-
- (*i)->drop_references ();
-
- i = tmp;
- }
-
- playlists.clear ();
- unused_playlists.clear ();
-
-#ifdef TRACK_DESTRUCTION
- cerr << "delete regions\n";
-#endif /* TRACK_DESTRUCTION */
-
+ 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()));
i->second->drop_references ();
-
+ DEBUG_TRACE(DEBUG::Destruction, string_compose ("region post ref = %1\n", i->second.use_count()));
i = tmp;
}
regions.clear ();
-#ifdef TRACK_DESTRUCTION
- cerr << "delete routes\n";
-#endif /* TRACK_DESTRUCTION */
+ DEBUG_TRACE (DEBUG::Destruction, "delete routes\n");
+
+ /* reset these three references to special routes before we do the usual route delete thing */
+
+ auditioner.reset ();
+ _master_out.reset ();
+ _control_out.reset ();
+
{
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 ();
-#ifdef TRACK_DESTRUCTION
- cerr << "delete diskstreams\n";
-#endif /* TRACK_DESTRUCTION */
- {
- RCUWriter<DiskstreamList> dwriter (diskstreams);
- boost::shared_ptr<DiskstreamList> dsl = dwriter.get_copy();
- for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) {
- (*i)->drop_references ();
- }
- dsl->clear ();
- }
- diskstreams.flush ();
-
-#ifdef TRACK_DESTRUCTION
- cerr << "delete audio sources\n";
-#endif /* TRACK_DESTRUCTION */
+ DEBUG_TRACE (DEBUG::Destruction, "delete diskstreams\n");
+ {
+ RCUWriter<DiskstreamList> dwriter (diskstreams);
+ boost::shared_ptr<DiskstreamList> dsl = dwriter.get_copy();
+ for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) {
+ 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;
+ 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 ();
-#ifdef TRACK_DESTRUCTION
- cerr << "delete route groups\n";
-#endif /* TRACK_DESTRUCTION */
+ DEBUG_TRACE (DEBUG::Destruction, "delete route groups\n");
for (list<RouteGroup *>::iterator i = _route_groups.begin(); i != _route_groups.end(); ++i) {
delete *i;
}
Crossfade::set_buffer_size (0);
delete mmc;
+
+ /* 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");
}
void
BootMessage (_("Using configuration"));
- Config->map_parameters (bind (mem_fun (*this, &Session::config_changed), false));
+ boost::function<void (std::string)> ff (boost::bind (&Session::config_changed, this, _1, false));
+ boost::function<void (std::string)> ft (boost::bind (&Session::config_changed, this, _1, true));
+
+ Config->map_parameters (ff);
+ config.map_parameters (ft);
/* every time we reconnect, recompute worst case output latencies */
- _engine.Running.connect (mem_fun (*this, &Session::set_worst_io_latencies));
+ scoped_connect (_engine.Running, boost::bind (&Session::set_worst_io_latencies, this));
if (synced_to_jack()) {
_engine.transport_stop ();
boost::shared_ptr<Playlist> playlist;
if ((playlist = dstream->playlist()) != 0) {
- playlist->LengthChanged.connect (mem_fun (this, &Session::playlist_length_changed));
+ scoped_connect (playlist->LengthChanged, boost::bind (&Session::playlist_length_changed, this));
}
/* see comment in playlist_length_changed () */
void
Session::auto_punch_start_changed (Location* location)
{
- replace_event (Event::PunchIn, location->start());
+ replace_event (SessionEvent::PunchIn, location->start());
if (get_record_enabled() && config.get_punch_in()) {
/* capture start has been changed, so save new pending state */
{
nframes_t when_to_stop = location->end();
// when_to_stop += _worst_output_latency + _worst_input_latency;
- replace_event (Event::PunchOut, when_to_stop);
+ replace_event (SessionEvent::PunchOut, when_to_stop);
}
void
{
nframes_t when_to_stop = location->end();
- replace_event (Event::PunchIn, location->start());
+ replace_event (SessionEvent::PunchIn, location->start());
//when_to_stop += _worst_output_latency + _worst_input_latency;
- replace_event (Event::PunchOut, when_to_stop);
+ replace_event (SessionEvent::PunchOut, when_to_stop);
}
void
Session::auto_loop_changed (Location* location)
{
- replace_event (Event::AutoLoop, location->end(), location->start());
+ replace_event (SessionEvent::AutoLoop, location->end(), location->start());
if (transport_rolling() && play_loop) {
if (_transport_frame < location->start() || _transport_frame > location->end()) {
// relocate to beginning of loop
- clear_events (Event::LocateRoll);
+ clear_events (SessionEvent::LocateRoll);
request_locate (location->start(), true);
loop_changing = true;
if (location->end() > last_loopend) {
- clear_events (Event::LocateRoll);
- Event *ev = new Event (Event::LocateRoll, Event::Add, last_loopend, last_loopend, 0, true);
+ clear_events (SessionEvent::LocateRoll);
+ SessionEvent *ev = new SessionEvent (SessionEvent::LocateRoll, SessionEvent::Add, last_loopend, last_loopend, 0, true);
queue_event (ev);
}
Location* existing;
if ((existing = _locations.auto_punch_location()) != 0 && existing != location) {
- auto_punch_start_changed_connection.disconnect();
- auto_punch_end_changed_connection.disconnect();
- auto_punch_changed_connection.disconnect();
+ punch_connections.drop_connections();
existing->set_auto_punch (false, this);
- remove_event (existing->start(), Event::PunchIn);
- clear_events (Event::PunchOut);
+ remove_event (existing->start(), SessionEvent::PunchIn);
+ clear_events (SessionEvent::PunchOut);
auto_punch_location_changed (0);
}
return;
}
- auto_punch_start_changed_connection.disconnect();
- auto_punch_end_changed_connection.disconnect();
- auto_punch_changed_connection.disconnect();
+ punch_connections.drop_connections ();
- auto_punch_start_changed_connection = location->start_changed.connect (mem_fun (this, &Session::auto_punch_start_changed));
- auto_punch_end_changed_connection = location->end_changed.connect (mem_fun (this, &Session::auto_punch_end_changed));
- auto_punch_changed_connection = location->changed.connect (mem_fun (this, &Session::auto_punch_changed));
+ 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->set_auto_punch (true, this);
-
auto_punch_changed (location);
auto_punch_location_changed (location);
Location* existing;
if ((existing = _locations.auto_loop_location()) != 0 && existing != location) {
- auto_loop_start_changed_connection.disconnect();
- auto_loop_end_changed_connection.disconnect();
- auto_loop_changed_connection.disconnect();
+ loop_connections.drop_connections ();
existing->set_auto_loop (false, this);
- remove_event (existing->end(), Event::AutoLoop);
+ remove_event (existing->end(), SessionEvent::AutoLoop);
auto_loop_location_changed (0);
}
last_loopend = location->end();
- auto_loop_start_changed_connection.disconnect();
- auto_loop_end_changed_connection.disconnect();
- auto_loop_changed_connection.disconnect();
+ loop_connections.drop_connections ();
- auto_loop_start_changed_connection = location->start_changed.connect (
- mem_fun (this, &Session::auto_loop_changed));
- auto_loop_end_changed_connection = location->end_changed.connect (
- mem_fun (this, &Session::auto_loop_changed));
- auto_loop_changed_connection = location->changed.connect (
- mem_fun (this, &Session::auto_loop_changed));
+ 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->set_auto_loop (true, this);
// FIXME: timestamp correct? [DR]
// FIXME FIXME FIXME: rt_context? this must be called in the process thread.
// does this /need/ to be sent in all cases?
- if (rt_context)
+ if (rt_context) {
deliver_mmc (MIDI::MachineControl::cmdRecordExit, _transport_frame);
+ }
if (Config->get_monitoring_model() == HardwareMonitoring && config.get_auto_input()) {
boost::shared_ptr<DiskstreamList> dsl = diskstreams.reader();
/* make a copy of the existing list of routes that feed r1 */
- set<shared_ptr<Route> > existing = r1->fed_by;
+ set<weak_ptr<Route> > existing = r1->fed_by;
/* for each route that feeds r1, recurse, marking it as feeding
rbase as well.
*/
- for (set<shared_ptr<Route> >::iterator i = existing.begin(); i != existing.end(); ++i) {
- r2 =* i;
-
+ for (set<weak_ptr<Route> >::iterator i = existing.begin(); i != existing.end(); ++i) {
+ if (!(r2 = (*i).lock ())) {
+ /* (*i) went away, ignore it */
+ continue;
+ }
+
/* r2 is a route that feeds r1 which somehow feeds base. mark
base as being fed by r2
*/
/* 2nd level feedback loop detection. if r1 feeds or is fed by r2,
stop here.
- */
+ */
if ((r1->fed_by.find (r2) != r1->fed_by.end()) && (r2->fed_by.find (r1) != r2->fed_by.end())) {
continue;
*/
track->midi_diskstream()->non_realtime_input_change();
- track->set_route_group (route_group, 0);
+ if (route_group) {
+ route_group->add (track);
+ }
- track->DiskstreamChanged.connect (mem_fun (this, &Session::resort_routes));
+ scoped_connect (track->DiskstreamChanged, boost::bind (&Session::resort_routes, this));
//track->set_remote_control_id (control_id);
new_routes.push_back (track);
shared_ptr<AudioTrack> track;
try {
- track = boost::shared_ptr<AudioTrack>((new AudioTrack (*this, track_name, Route::Flag (0), mode)));
+ AudioTrack* at = new AudioTrack (*this, track_name, Route::Flag (0), mode);
+ boost_debug_shared_ptr_mark_interesting (at, typeid (at).name());
+ track = boost::shared_ptr<AudioTrack>(at);
if (track->input()->ensure_io (ChanCount(DataType::AUDIO, input_channels), false, this)) {
error << string_compose (_("cannot configure %1 in/%2 out configuration for new audio track"),
channels_used += track->n_inputs ().n_audio();
- track->set_route_group (route_group, 0);
+ if (route_group) {
+ route_group->add (track);
+ }
track->audio_diskstream()->non_realtime_input_change();
- track->DiskstreamChanged.connect (mem_fun (this, &Session::resort_routes));
+ scoped_connect (track->DiskstreamChanged, boost::bind (&Session::resort_routes, this));
track->set_remote_control_id (control_id);
++control_id;
RouteList
-Session::new_audio_route (int input_channels, int output_channels, RouteGroup* route_group, uint32_t how_many)
+Session::new_audio_route (bool aux, int input_channels, int output_channels, RouteGroup* route_group, uint32_t how_many)
{
char bus_name[32];
uint32_t bus_id = 1;
} while (bus_id < (UINT_MAX-1));
try {
- shared_ptr<Route> bus (new Route (*this, bus_name, Route::Flag(0), DataType::AUDIO));
+ Route* rt = new Route (*this, bus_name, Route::Flag(0), DataType::AUDIO);
+ boost_debug_shared_ptr_mark_interesting (rt, typeid (rt).name());
+ shared_ptr<Route> bus (rt);
if (bus->input()->ensure_io (ChanCount(DataType::AUDIO, input_channels), false, this)) {
error << string_compose (_("cannot configure %1 in/%2 out configuration for new audio track"),
channels_used += bus->n_inputs ().n_audio();
- bus->set_route_group (route_group, 0);
+ if (route_group) {
+ route_group->add (bus);
+ }
bus->set_remote_control_id (control_id);
++control_id;
+ if (aux) {
+ bus->add_internal_return ();
+ }
+
ret.push_back (bus);
}
boost::weak_ptr<Route> wpr (*x);
- (*x)->listen_changed.connect (sigc::bind (mem_fun (*this, &Session::route_listen_changed), wpr));
- (*x)->solo_changed.connect (sigc::bind (mem_fun (*this, &Session::route_solo_changed), wpr));
- (*x)->mute_changed.connect (mem_fun (*this, &Session::route_mute_changed));
- (*x)->output()->changed.connect (mem_fun (*this, &Session::set_worst_io_latencies_x));
- (*x)->processors_changed.connect (bind (mem_fun (*this, &Session::update_latency_compensation), false, false));
- (*x)->route_group_changed.connect (hide (mem_fun (*this, &Session::route_group_changed)));
+ 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));
if ((*x)->is_master()) {
_master_out = (*x);
add_internal_sends (dest, p, t);
}
-
void
Session::add_internal_sends (boost::shared_ptr<Route> dest, Placement p, boost::shared_ptr<RouteList> senders)
{
(*i)->listen_via (dest, p, true, true);
}
+
+ graph_reordered ();
}
void
/* writer goes out of scope, copies ds back to main */
}
- dstream->PlaylistChanged.connect (sigc::bind (mem_fun (*this, &Session::diskstream_playlist_changed), boost::weak_ptr<Diskstream> (dstream)));
+ scoped_connect (dstream->PlaylistChanged, 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));
- dstream->RecordEnableChanged.connect (mem_fun (*this, &Session::update_have_rec_enabled_diskstream));
+ scoped_connect (dstream->RecordEnableChanged, boost::bind (&Session::update_have_rec_enabled_diskstream, this));
dstream->prepare ();
route->input()->disconnect (0);
route->output()->disconnect (0);
+ /* if the route had internal sends sending to it, remove them */
+ if (route->internal_return()) {
+
+ boost::shared_ptr<RouteList> r = routes.reader ();
+ for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
+ boost::shared_ptr<Send> s = (*i)->internal_send_for (route);
+ if (s) {
+ (*i)->remove_processor (s);
+ }
+ }
+ }
+
update_latency_compensation (false, false);
set_dirty();
shared_ptr<RouteList> r = routes.reader ();
int32_t delta;
- if (route->soloed()) {
+ if (route->self_soloed()) {
delta = 1;
} else {
delta = -1;
*/
solo_update_disabled = true;
+
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
bool via_sends_only;
- if ((*i)->feeds (route, &via_sends_only) && !(*i)->is_hidden() && !(*i)->is_master() && !(*i)->is_control()) {
+
+ if ((*i) == route || !(*i)->solo_isolated() || !(*i)->is_master() || !(*i)->is_control() || (*i)->is_hidden()) {
+ continue;
+ } else if ((*i)->feeds (route, &via_sends_only)) {
if (!via_sends_only) {
- /* do it */
- (*i)->mod_solo_level (delta);
+ (*i)->mod_solo_by_others (delta);
}
- }
+ }
}
/* make sure master is never muted by solo */
- if (_master_out && route != _master_out && _master_out->solo_level() == 0 && !_master_out->soloed()) {
- _master_out->mod_solo_level (1);
- }
-
+ if (_master_out && route != _master_out && _master_out->soloed_by_others() == 0 && !_master_out->soloed()) {
+ _master_out->mod_solo_by_others (1);
+ }
+
/* ditto for control outs make sure master is never muted by solo */
- if (_control_out && route != _control_out && _control_out && _control_out->solo_level() == 0) {
- _control_out->mod_solo_level (1);
+ if (_control_out && route != _control_out && _control_out && _control_out->soloed_by_others() == 0) {
+ _control_out->mod_solo_by_others (1);
}
solo_update_disabled = false;
}
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
- if (!(*i)->is_master() && !(*i)->is_control() && !(*i)->is_hidden() && (*i)->soloed()) {
+ if (!(*i)->is_master() && !(*i)->is_control() && !(*i)->is_hidden() && (*i)->self_soloed()) {
something_soloed = true;
break;
}
}
}
+boost::shared_ptr<RouteList>
+Session::get_routes_with_internal_returns() const
+{
+ shared_ptr<RouteList> r = routes.reader ();
+ boost::shared_ptr<RouteList> rl (new RouteList);
+
+ for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
+ if ((*i)->internal_return ()) {
+ rl->push_back (*i);
+ }
+ }
+ return rl;
+}
+
shared_ptr<Route>
Session::route_by_name (string name)
{
}
}
- region->StateChanged.connect (sigc::bind (mem_fun (*this, &Session::region_changed), boost::weak_ptr<Region>(region)));
- region->GoingAway.connect (sigc::bind (mem_fun (*this, &Session::remove_region), boost::weak_ptr<Region>(region)));
+ 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)));
update_region_name_map (region);
}
return boost::shared_ptr<Region> ();
}
-void
-Session::find_equivalent_playlist_regions (boost::shared_ptr<Region> region, vector<boost::shared_ptr<Region> >& result)
-{
- for (PlaylistList::iterator i = playlists.begin(); i != playlists.end(); ++i)
- (*i)->get_region_list_equivalent_regions (region, result);
-}
-
int
Session::destroy_region (boost::shared_ptr<Region> region)
{
}
if (result.second) {
- source->GoingAway.connect (sigc::bind (mem_fun (this, &Session::remove_source), boost::weak_ptr<Source> (source)));
+ scoped_connect (source->GoingAway, boost::bind (&Session::remove_source, this, boost::weak_ptr<Source> (source)));
set_dirty();
}
}
}
-/** Return the number of playlists (not regions) that contain @a src */
-uint32_t
-Session::source_use_count (boost::shared_ptr<const Source> src) const
-{
- uint32_t count = 0;
- for (PlaylistList::const_iterator p = playlists.begin(); p != playlists.end(); ++p) {
- for (Playlist::RegionList::const_iterator r = (*p)->region_list().begin();
- r != (*p)->region_list().end(); ++r) {
- if ((*r)->uses_source(src)) {
- ++count;
- break;
- }
- }
- }
- return count;
-}
-
boost::shared_ptr<Source>
Session::source_by_id (const PBD::ID& id)
{
return path;
}
-/** Return the full path (in some session directory) for a new embedded source.
+/** Return the full path (in some session directory) for a new within-session source.
* \a name must be a session-unique name that does not contain slashes
* (e.g. as returned by new_*_source_name)
*/
return Glib::path_get_basename(buf);
}
-/** Create a new embedded audio source */
+/** Create a new within-session audio source */
boost::shared_ptr<AudioFileSource>
Session::create_audio_source_for_session (AudioDiskstream& ds, uint32_t chan, bool destructive)
{
const size_t n_chans = ds.n_channels().n_audio();
const string name = new_audio_source_name (ds.name(), n_chans, chan, destructive);
const string path = new_source_path_from_name(DataType::AUDIO, name);
+
return boost::dynamic_pointer_cast<AudioFileSource> (
- SourceFactory::createWritable (
- DataType::AUDIO, *this, path, true, destructive, frame_rate()));
+ SourceFactory::createWritable (DataType::AUDIO, *this, path, destructive, frame_rate()));
}
/** Return a unique name based on \a base for a new internal MIDI source */
}
-/** Create a new embedded MIDI source */
+/** Create a new within-session MIDI source */
boost::shared_ptr<MidiSource>
Session::create_midi_source_for_session (MidiDiskstream& ds)
{
return boost::dynamic_pointer_cast<SMFSource> (
SourceFactory::createWritable (
- DataType::MIDI, *this, path, true, false, frame_rate()));
-}
-
-
-/* Playlist management */
-
-boost::shared_ptr<Playlist>
-Session::playlist_by_name (string name)
-{
- Glib::Mutex::Lock lm (playlist_lock);
- for (PlaylistList::iterator i = playlists.begin(); i != playlists.end(); ++i) {
- if ((*i)->name() == name) {
- return* i;
- }
- }
- for (PlaylistList::iterator i = unused_playlists.begin(); i != unused_playlists.end(); ++i) {
- if ((*i)->name() == name) {
- return* i;
- }
- }
-
- return boost::shared_ptr<Playlist>();
+ DataType::MIDI, *this, path, false, frame_rate()));
}
-void
-Session::unassigned_playlists (std::list<boost::shared_ptr<Playlist> > & list)
-{
- Glib::Mutex::Lock lm (playlist_lock);
- for (PlaylistList::iterator i = playlists.begin(); i != playlists.end(); ++i) {
- if (!(*i)->get_orig_diskstream_id().to_s().compare ("0")) {
- list.push_back (*i);
- }
- }
- for (PlaylistList::iterator i = unused_playlists.begin(); i != unused_playlists.end(); ++i) {
- if (!(*i)->get_orig_diskstream_id().to_s().compare ("0")) {
- list.push_back (*i);
- }
- }
-}
void
Session::add_playlist (boost::shared_ptr<Playlist> playlist, bool unused)
return;
}
- {
- Glib::Mutex::Lock lm (playlist_lock);
- if (find (playlists.begin(), playlists.end(), playlist) == playlists.end()) {
- playlists.insert (playlists.begin(), playlist);
- playlist->InUse.connect (sigc::bind (mem_fun (*this, &Session::track_playlist), boost::weak_ptr<Playlist>(playlist)));
- playlist->GoingAway.connect (sigc::bind (mem_fun (*this, &Session::remove_playlist), boost::weak_ptr<Playlist>(playlist)));
- }
+ bool existing = playlists->add (playlist);
+ if (!existing) {
+ scoped_connect (playlist->GoingAway, boost::bind (&Session::remove_playlist, this, boost::weak_ptr<Playlist>(playlist)));
}
if (unused) {
}
set_dirty();
-
- PlaylistAdded (playlist); /* EMIT SIGNAL */
-}
-
-void
-Session::get_playlists (vector<boost::shared_ptr<Playlist> >& s)
-{
- {
- Glib::Mutex::Lock lm (playlist_lock);
- for (PlaylistList::iterator i = playlists.begin(); i != playlists.end(); ++i) {
- s.push_back (*i);
- }
- for (PlaylistList::iterator i = unused_playlists.begin(); i != unused_playlists.end(); ++i) {
- s.push_back (*i);
- }
- }
-}
-
-void
-Session::track_playlist (bool inuse, boost::weak_ptr<Playlist> wpl)
-{
- boost::shared_ptr<Playlist> pl(wpl.lock());
-
- if (!pl) {
- return;
- }
-
- PlaylistList::iterator x;
-
- if (pl->hidden()) {
- /* its not supposed to be visible */
- return;
- }
-
- {
- Glib::Mutex::Lock lm (playlist_lock);
-
- if (!inuse) {
-
- unused_playlists.insert (pl);
-
- if ((x = playlists.find (pl)) != playlists.end()) {
- playlists.erase (x);
- }
-
-
- } else {
-
- playlists.insert (pl);
-
- if ((x = unused_playlists.find (pl)) != unused_playlists.end()) {
- unused_playlists.erase (x);
- }
- }
- }
}
void
return;
}
- {
- Glib::Mutex::Lock lm (playlist_lock);
-
- PlaylistList::iterator i;
-
- i = find (playlists.begin(), playlists.end(), playlist);
- if (i != playlists.end()) {
- playlists.erase (i);
- }
-
- i = find (unused_playlists.begin(), unused_playlists.end(), playlist);
- if (i != unused_playlists.end()) {
- unused_playlists.erase (i);
- }
-
- }
+ playlists->remove (playlist);
set_dirty();
-
- PlaylistRemoved (playlist); /* EMIT SIGNAL */
}
void
void
Session::audition_playlist ()
{
- Event* ev = new Event (Event::Audition, Event::Add, Event::Immediate, 0, 0.0);
+ SessionEvent* ev = new SessionEvent (SessionEvent::Audition, SessionEvent::Add, SessionEvent::Immediate, 0, 0.0);
ev->region.reset ();
queue_event (ev);
}
void
Session::audition_region (boost::shared_ptr<Region> r)
{
- Event* ev = new Event (Event::Audition, Event::Add, Event::Immediate, 0, 0.0);
+ SessionEvent* ev = new SessionEvent (SessionEvent::Audition, SessionEvent::Add, SessionEvent::Immediate, 0, 0.0);
ev->region = r;
queue_event (ev);
}
TapeFileMatcher tape_file_matcher;
remove_if (audio_filenames.begin(), audio_filenames.end(),
- sigc::mem_fun (tape_file_matcher, &TapeFileMatcher::matches));
-
+ boost::bind (&TapeFileMatcher::matches, &tape_file_matcher, _1));
+
for (vector<string>::iterator i = audio_filenames.begin(); i != audio_filenames.end(); ++i) {
sys::path audio_file_path (_session_dir->sound_path());
}
}
-void
-Session::set_all_solo (bool yn)
-{
- shared_ptr<RouteList> r = routes.reader ();
-
- for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
- if (!(*i)->is_hidden()) {
- (*i)->set_solo (yn, this);
- }
- }
-
- set_dirty();
-}
-
-void
-Session::set_all_listen (bool yn)
-{
- shared_ptr<RouteList> r = routes.reader ();
-
- for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
- if (!(*i)->is_hidden()) {
- (*i)->set_listen (yn, this);
- }
- }
-
- set_dirty();
-}
-
-void
-Session::set_all_mute (bool yn)
-{
- shared_ptr<RouteList> r = routes.reader ();
-
- for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
- if (!(*i)->is_hidden()) {
- (*i)->set_mute (yn, this);
- }
- }
-
- set_dirty();
-}
-
uint32_t
Session::n_diskstreams () const
{
Session::graph_reordered ()
{
/* don't do this stuff if we are setting up connections
- from a set_state() call or creating new tracks.
+ from a set_state() call or creating new tracks. Ditto for deletion.
*/
- if (_state_of_the_state & InitialConnecting) {
+ if (_state_of_the_state & (InitialConnecting|Deletion)) {
return;
}
}
}
-void
-Session::record_disenable_all ()
-{
- record_enable_change_all (false);
-}
-
-void
-Session::record_enable_all ()
-{
- record_enable_change_all (true);
-}
-
-void
-Session::record_enable_change_all (bool yn)
-{
- shared_ptr<RouteList> r = routes.reader ();
-
- for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
- boost::shared_ptr<Track> t;
-
- if ((t = boost::dynamic_pointer_cast<Track>(*i)) != 0) {
- t->set_record_enable (yn, this);
- }
- }
-
- /* since we don't keep rec-enable state, don't mark session dirty */
-}
-
void
Session::add_processor (Processor* processor)
{
- processor->GoingAway.connect (sigc::bind (mem_fun (*this, &Session::remove_processor), processor));
+ scoped_connect (processor->GoingAway, boost::bind (&Session::remove_processor, this, processor));
set_dirty();
}
} else if ((send = dynamic_cast<Send *> (processor)) != 0) {
send_bitset[send->bit_slot()] = false;
} else if ((retrn = dynamic_cast<Return *> (processor)) != 0) {
- return_bitset[send->bit_slot()] = false;
+ return_bitset[retrn->bit_slot()] = false;
}
set_dirty();
{
clear_clicks ();
- for (PlaylistList::iterator i = playlists.begin(); i != playlists.end(); ++i) {
- (*i)->update_after_tempo_map_change ();
- }
-
- for (PlaylistList::iterator i = unused_playlists.begin(); i != unused_playlists.end(); ++i) {
- (*i)->update_after_tempo_map_change ();
- }
+ playlists->update_after_tempo_map_change ();
set_dirty ();
}
return false;
}
-uint32_t
-Session::n_playlists () const
-{
- Glib::Mutex::Lock lm (playlist_lock);
- return playlists.size();
-}
-
void
Session::allocate_pan_automation_buffers (nframes_t nframes, uint32_t howmany, bool force)
{
return result;
}
- // any bigger than this seems to cause stack overflows in called functions
- const nframes_t chunk_size = (128 * 1024)/4;
+ const nframes_t chunk_size = (256 * 1024)/4;
// block all process callback handling
try {
fsource = boost::dynamic_pointer_cast<AudioFileSource> (
- SourceFactory::createWritable (DataType::AUDIO, *this, buf, true, false, frame_rate()));
+ SourceFactory::createWritable (DataType::AUDIO, *this, buf, false, frame_rate()));
}
catch (failed_constructor& err) {
/* cancel all solo or all listen when solo control mode changes */
if (Config->get_solo_control_is_listen_control()) {
- set_all_solo (false);
+ set_solo (routes.reader(), false);
} else {
- set_all_listen (false);
+ set_listen (routes.reader(), false);
}
}
return ret;
}
+
+boost::shared_ptr<RouteList>
+Session::get_routes_with_regions_at (nframes64_t const p) const
+{
+ shared_ptr<RouteList> r = routes.reader ();
+ shared_ptr<RouteList> rl (new RouteList);
+
+ for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
+ boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
+ if (!tr) {
+ continue;
+ }
+
+ boost::shared_ptr<Diskstream> ds = tr->diskstream ();
+ if (!ds) {
+ continue;
+ }
+
+ boost::shared_ptr<Playlist> pl = ds->playlist ();
+ if (!pl) {
+ continue;
+ }
+
+ if (pl->has_region_at (p)) {
+ rl->push_back (*i);
+ }
+ }
+
+ return rl;
+}