playlists.reset ();
delete _locations;
- delete _speakers;
DEBUG_TRACE (DEBUG::Destruction, "Session::destroy() done\n");
BootMessage (_("Connect to engine"));
_engine.set_session (this);
+ _engine.update_total_latencies ();
}
void
_state_of_the_state = StateOfTheState (_state_of_the_state | InitialConnecting);
-
if (!auditioner) {
/* we delay creating the auditioner till now because
*/
try {
- Auditioner* a = new Auditioner (*this);
+ boost::shared_ptr<Auditioner> a (new Auditioner (*this));
if (a->init()) {
- delete a;
- throw failed_constructor();
+ throw failed_constructor ();
}
a->use_new_diskstream ();
- auditioner.reset (a);
+ auditioner = a;
}
catch (failed_constructor& err) {
/* relax */
} else {
-
- (*x)->listen_via (_monitor_out,
- (Config->get_listen_position() == AfterFaderListen ? PostFader : PreFader),
- false, false);
+
+ (*x)->listen_via_monitor ();
}
}
}
}
}
-void
-Session::set_default_fade (float /*steepness*/, float /*fade_msecs*/)
-{
-#if 0
- framecnt_t fade_frames;
-
- /* Don't allow fade of less 1 frame */
-
- if (fade_msecs < (1000.0 * (1.0/_current_frame_rate))) {
-
- fade_msecs = 0;
- fade_frames = 0;
-
- } else {
-
- fade_frames = (framecnt_t) floor (fade_msecs * _current_frame_rate * 0.001);
-
- }
-
- default_fade_msecs = fade_msecs;
- default_fade_steepness = steepness;
-
- {
- // jlc, WTF is this!
- Glib::RWLock::ReaderLock lm (route_lock);
- AudioRegion::set_default_fade (steepness, fade_frames);
- }
-
- set_dirty();
-
- /* XXX have to do this at some point */
- /* foreach region using default fade, reset, then
- refill_all_diskstream_buffers ();
- */
-#endif
-}
-
struct RouteSorter {
/** @return true to run r1 before r2, otherwise false */
bool operator() (boost::shared_ptr<Route> r1, boost::shared_ptr<Route> r2) {
}
-/** Find the route name starting with \a base with the lowest \a id.
+/** Find a route name starting with \a base, maybe followed by the
+ * lowest \a id. \a id will always be added if \a definitely_add_number
+ * is true on entry; otherwise it will only be added if required
+ * to make the name unique.
*
- * Names are constructed like e.g. "Audio 3" for base="Audio" and id=3.
- * The available route name with the lowest ID will be used, and \a id
- * will be set to the ID.
+ * Names are constructed like e.g. "Audio 3" for base="Audio" and id=3.
+ * The available route name with the lowest ID will be used, and \a id
+ * will be set to the ID.
*
- * \return false if a route name could not be found, and \a track_name
- * and \a id do not reflect a free route name.
+ * \return false if a route name could not be found, and \a track_name
+ * and \a id do not reflect a free route name.
*/
bool
-Session::find_route_name (const char* base, uint32_t& id, char* name, size_t name_len)
+Session::find_route_name (string const & base, uint32_t& id, char* name, size_t name_len, bool definitely_add_number)
{
+ if (!definitely_add_number && route_by_name (base) == 0) {
+ /* juse use the base */
+ snprintf (name, name_len, "%s", base.c_str());
+ return true;
+ }
+
do {
- snprintf (name, name_len, "%s %" PRIu32, base, id);
+ snprintf (name, name_len, "%s %" PRIu32, base.c_str(), id);
if (route_by_name (name) == 0) {
return true;
}
}
-/** Caller must not hold process lock */
+/** Caller must not hold process lock
+ * @param name_template string to use for the start of the name, or "" to use "Midi".
+ */
list<boost::shared_ptr<MidiTrack> >
-Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_many)
+Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_many, string name_template)
{
char track_name[32];
uint32_t track_id = 0;
control_id = ntracks() + nbusses();
while (how_many) {
- if (!find_route_name ("Midi", ++track_id, track_name, sizeof(track_name))) {
+ if (!find_route_name (name_template.empty() ? _("Midi") : name_template, ++track_id, track_name, sizeof(track_name), false)) {
error << "cannot find name for new midi track" << endmsg;
goto failed;
}
boost::shared_ptr<MidiTrack> track;
try {
- MidiTrack* mt = new MidiTrack (*this, track_name, Route::Flag (0), mode);
+ track.reset (new MidiTrack (*this, track_name, Route::Flag (0), mode));
- if (mt->init ()) {
- delete mt;
+ if (track->init ()) {
goto failed;
}
- mt->use_new_diskstream();
+ track->use_new_diskstream();
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
- boost_debug_shared_ptr_mark_interesting (mt, "Track");
+ boost_debug_shared_ptr_mark_interesting (track.get(), "Track");
#endif
- track = boost::shared_ptr<MidiTrack>(mt);
-
{
Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
if (track->input()->ensure_io (ChanCount(DataType::MIDI, 1), false, this)) {
existing_outputs += route->n_outputs();
}
-/** Caller must not hold process lock */
+/** Caller must not hold process lock
+ * @param name_template string to use for the start of the name, or "" to use "Audio".
+ */
list< boost::shared_ptr<AudioTrack> >
-Session::new_audio_track (int input_channels, int output_channels, TrackMode mode, RouteGroup* route_group, uint32_t how_many)
+Session::new_audio_track (
+ int input_channels, int output_channels, TrackMode mode, RouteGroup* route_group, uint32_t how_many, string name_template
+ )
{
char track_name[32];
uint32_t track_id = 0;
control_id = ntracks() + nbusses() + 1;
while (how_many) {
- if (!find_route_name ("Audio", ++track_id, track_name, sizeof(track_name))) {
+ if (!find_route_name (name_template.empty() ? _("Audio") : name_template, ++track_id, track_name, sizeof(track_name), false)) {
error << "cannot find name for new audio track" << endmsg;
goto failed;
}
boost::shared_ptr<AudioTrack> track;
try {
- AudioTrack* at = new AudioTrack (*this, track_name, Route::Flag (0), mode);
+ track.reset (new AudioTrack (*this, track_name, Route::Flag (0), mode));
- if (at->init ()) {
- delete at;
+ if (track->init ()) {
goto failed;
}
- at->use_new_diskstream();
+ track->use_new_diskstream();
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
- boost_debug_shared_ptr_mark_interesting (at, "Track");
+ boost_debug_shared_ptr_mark_interesting (track.get(), "Track");
#endif
- track = boost::shared_ptr<AudioTrack>(at);
-
{
Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
}
}
-/** Caller must not hold process lock */
+/** Caller must not hold process lock.
+ * @param name_template string to use for the start of the name, or "" to use "Bus".
+ */
RouteList
-Session::new_audio_route (int input_channels, int output_channels, RouteGroup* route_group, uint32_t how_many)
+Session::new_audio_route (int input_channels, int output_channels, RouteGroup* route_group, uint32_t how_many, string name_template)
{
char bus_name[32];
uint32_t bus_id = 0;
control_id = ntracks() + nbusses() + 1;
while (how_many) {
- if (!find_route_name ("Bus", ++bus_id, bus_name, sizeof(bus_name))) {
+ if (!find_route_name (name_template.empty () ? _("Bus") : name_template, ++bus_id, bus_name, sizeof(bus_name), false)) {
error << "cannot find name for new audio bus" << endmsg;
goto failure;
}
try {
- Route* rt = new Route (*this, bus_name, Route::Flag(0), DataType::AUDIO);
+ boost::shared_ptr<Route> bus (new Route (*this, bus_name, Route::Flag(0), DataType::AUDIO));
- if (rt->init ()) {
- delete rt;
+ if (bus->init ()) {
goto failure;
}
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
- boost_debug_shared_ptr_mark_interesting (rt, "Route");
+ boost_debug_shared_ptr_mark_interesting (bus.get(), "Route");
#endif
- boost::shared_ptr<Route> bus (rt);
-
{
Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
std::string node_name = IO::name_from_state (*node_copy.children().front());
/* generate a new name by adding a number to the end of the template name */
- if (!find_route_name (node_name.c_str(), ++number, name, sizeof(name))) {
+ if (!find_route_name (node_name.c_str(), ++number, name, sizeof(name), true)) {
fatal << _("Session: UINT_MAX routes? impossible!") << endmsg;
/*NOTREACHED*/
}
} else if ((*x)->is_master()) {
/* relax */
} else {
- (*x)->listen_via (_monitor_out,
- (Config->get_listen_position() == AfterFaderListen ? PostFader : PreFader),
- false, false);
+ (*x)->listen_via_monitor ();
}
}
continue;
}
- (*i)->listen_via (dest, p, true, true);
+ (*i)->listen_via (dest, p);
}
graph_reordered ();
return;
}
- if (route->listening()) {
+ if (route->listening_via_monitor ()) {
if (Config->get_exclusive_solo()) {
/* new listen: disable all other listen */
_listen_cnt--;
}
+
+ update_route_solo_state ();
}
void
Session::route_solo_isolated_changed (void* /*src*/, boost::weak_ptr<Route> wpr)
something_soloed = true;
}
- if (!(*i)->is_hidden() && (*i)->listening()) {
+ if (!(*i)->is_hidden() && (*i)->listening_via_monitor()) {
if (Config->get_solo_control_is_listen_control()) {
listeners++;
} else {
void
Session::listen_position_changed ()
{
- Placement p;
-
- switch (Config->get_listen_position()) {
- case AfterFaderListen:
- p = PostFader;
- break;
-
- case PreFaderListen:
- p = PreFader;
- break;
- }
-
boost::shared_ptr<RouteList> r = routes.reader ();
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
- (*i)->put_monitor_send_at (p);
+ (*i)->listen_position_changed ();
}
}
}
}
-Speakers&
+boost::shared_ptr<Speakers>
Session::get_speakers()
{
- return *_speakers;
+ return _speakers;
}
list<string>
Session::update_latency (bool playback)
{
DEBUG_TRACE (DEBUG::Latency, "JACK latency callback\n");
+
+ boost::shared_ptr<RouteList> r = routes.reader ();
+
+ if (playback) {
+ /* reverse the list so that we work backwards from the last route to run to the first */
+ reverse (r->begin(), r->end());
+ }
+
+ for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
+ DEBUG_TRACE (DEBUG::Latency, string_compose ("------------- Working on latency for %1\n", (*i)->name()));
+ (*i)->set_latency_ranges (playback);
+ DEBUG_TRACE (DEBUG::Latency, string_compose ("------------- Done working on latency for %1\n\n", (*i)->name()));
+ }
}
#endif