X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fsession.cc;h=759495351a8fbc9cf40743b574b5ee29f86b3584;hb=34b9883537769758c46b050cb5c1ced63d566c0f;hp=63f5dc8e4362ecf9122872a1cf5eba2b7e8ac76d;hpb=35ea41228023b3070ad2b12feca79e6d2fcfc4db;p=ardour.git diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 63f5dc8e43..759495351a 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -238,10 +238,6 @@ Session::destroy () delete state_tree; - /* remove all stubfiles that might still be lurking */ - - cleanup_stubfiles (); - /* reset dynamic state version back to default */ Stateful::loading_state_version = 0; @@ -302,15 +298,9 @@ Session::destroy () routes.flush (); DEBUG_TRACE (DEBUG::Destruction, "delete sources\n"); - for (SourceMap::iterator i = sources.begin(); i != sources.end(); ) { - - SourceMap::iterator j = i; - ++j; - + 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 = j; } sources.clear (); @@ -338,6 +328,10 @@ Session::destroy () void Session::set_worst_io_latencies () { + if (_state_of_the_state & InitialConnecting) { + return; + } + _worst_output_latency = 0; _worst_input_latency = 0; @@ -351,6 +345,9 @@ Session::set_worst_io_latencies () _worst_output_latency = max (_worst_output_latency, (*i)->output()->latency()); _worst_input_latency = max (_worst_input_latency, (*i)->input()->latency()); } + + DEBUG_TRACE (DEBUG::Latency, string_compose ("Worst output latency: %1 Worst input latency: %2\n", + _worst_output_latency, _worst_input_latency)); } void @@ -439,8 +436,6 @@ Session::when_engine_running () BootMessage (_("Compute I/O Latencies")); - set_worst_io_latencies (); - if (_clicking) { // XXX HOW TO ALERT UI TO THIS ? DO WE NEED TO? } @@ -654,7 +649,7 @@ Session::when_engine_running () } } - /* catch up on send+insert cnts */ + set_worst_io_latencies (); _state_of_the_state = StateOfTheState (_state_of_the_state & ~(CannotSave|Dirty)); @@ -787,30 +782,26 @@ Session::record_enabling_legal () const return true; } +void +Session::set_track_monitor_input_status (bool yn) +{ + boost::shared_ptr rl = routes.reader (); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && tr->record_enabled ()) { + //cerr << "switching to input = " << !auto_input << __FILE__ << __LINE__ << endl << endl; + tr->monitor_input (yn); + } + } +} + void Session::reset_input_monitor_state () { if (transport_rolling()) { - - boost::shared_ptr rl = routes.reader (); - for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { - boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); - if (tr && tr->record_enabled ()) { - //cerr << "switching to input = " << !auto_input << __FILE__ << __LINE__ << endl << endl; - tr->monitor_input (Config->get_monitoring_model() == HardwareMonitoring && !config.get_auto_input()); - } - } - + set_track_monitor_input_status (Config->get_monitoring_model() == HardwareMonitoring && !config.get_auto_input()); } else { - - boost::shared_ptr rl = routes.reader (); - for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { - boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); - if (tr && tr->record_enabled ()) { - //cerr << "switching to input = " << !Config->get_auto_input() << __FILE__ << __LINE__ << endl << endl; - tr->monitor_input (Config->get_monitoring_model() == HardwareMonitoring); - } - } + set_track_monitor_input_status (Config->get_monitoring_model() == HardwareMonitoring); } } @@ -1021,14 +1012,7 @@ Session::enable_record () MIDI::Manager::instance()->mmc()->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordStrobe)); if (Config->get_monitoring_model() == HardwareMonitoring && config.get_auto_input()) { - - boost::shared_ptr rl = routes.reader (); - for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { - boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); - if (tr && tr->record_enabled ()) { - tr->monitor_input (true); - } - } + set_track_monitor_input_status (true); } RecordStateChanged (); @@ -1054,14 +1038,7 @@ Session::disable_record (bool rt_context, bool force) } if (Config->get_monitoring_model() == HardwareMonitoring && config.get_auto_input()) { - - boost::shared_ptr rl = routes.reader (); - for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { - boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); - if (tr && tr->record_enabled ()) { - tr->monitor_input (false); - } - } + set_track_monitor_input_status (false); } RecordStateChanged (); /* emit signal */ @@ -1078,14 +1055,7 @@ Session::step_back_from_record () if (g_atomic_int_compare_and_exchange (&_record_status, Recording, Enabled)) { if (Config->get_monitoring_model() == HardwareMonitoring && config.get_auto_input()) { - boost::shared_ptr rl = routes.reader (); - for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { - boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); - if (tr && tr->record_enabled ()) { - //cerr << "switching from input" << __FILE__ << __LINE__ << endl << endl; - tr->monitor_input (false); - } - } + set_track_monitor_input_status (false); } } } @@ -2697,6 +2667,10 @@ Session::add_source (boost::shared_ptr source) void Session::remove_source (boost::weak_ptr src) { + if (_state_of_the_state & Deletion) { + return; + } + SourceMap::iterator i; boost::shared_ptr source = src.lock(); @@ -2708,7 +2682,6 @@ Session::remove_source (boost::weak_ptr src) Glib::Mutex::Lock lm (source_lock); if ((i = sources.find (source->id())) != sources.end()) { - cerr << "Removing source " << source->name() << endl; sources.erase (i); } } @@ -2881,7 +2854,7 @@ Session::change_source_path_by_name (string path, string oldname, string newname * (e.g. as returned by new_*_source_name) */ string -Session::new_source_path_from_name (DataType type, const string& name, bool as_stub) +Session::new_source_path_from_name (DataType type, const string& name) { assert(name.find("/") == string::npos); @@ -2889,9 +2862,9 @@ Session::new_source_path_from_name (DataType type, const string& name, bool as_s sys::path p; if (type == DataType::AUDIO) { - p = (as_stub ? sdir.sound_stub_path() : sdir.sound_path()); + p = sdir.sound_path(); } else if (type == DataType::MIDI) { - p = (as_stub ? sdir.midi_stub_path() : sdir.midi_path()); + p = sdir.midi_path(); } else { error << "Unknown source type, unable to create file path" << endmsg; return ""; @@ -2971,7 +2944,6 @@ Session::new_audio_source_name (const string& base, uint32_t nchan, uint32_t cha SessionDirectory sdir((*i).path); string spath = sdir.sound_path().to_string(); - string spath_stubs = sdir.sound_stub_path().to_string(); /* note that we search *without* the extension so that we don't end up both "Audio 1-1.wav" and "Audio 1-1.caf" @@ -2979,8 +2951,7 @@ Session::new_audio_source_name (const string& base, uint32_t nchan, uint32_t cha a file format change. */ - if (matching_unsuffixed_filename_exists_in (spath, buf) || - matching_unsuffixed_filename_exists_in (spath_stubs, buf)) { + if (matching_unsuffixed_filename_exists_in (spath, buf)) { existing++; break; } @@ -3004,10 +2975,10 @@ Session::new_audio_source_name (const string& base, uint32_t nchan, uint32_t cha /** Create a new within-session audio source */ boost::shared_ptr -Session::create_audio_source_for_session (size_t n_chans, string const & n, uint32_t chan, bool destructive, bool as_stub) +Session::create_audio_source_for_session (size_t n_chans, string const & n, uint32_t chan, bool destructive) { const string name = new_audio_source_name (n, n_chans, chan, destructive); - const string path = new_source_path_from_name(DataType::AUDIO, name, as_stub); + const string path = new_source_path_from_name(DataType::AUDIO, name); return boost::dynamic_pointer_cast ( SourceFactory::createWritable (DataType::AUDIO, *this, path, string(), destructive, frame_rate())); @@ -3064,7 +3035,7 @@ Session::new_midi_source_name (const string& base) /** Create a new within-session MIDI source */ boost::shared_ptr -Session::create_midi_source_for_session (Track* track, string const & n, bool as_stub) +Session::create_midi_source_for_session (Track* track, string const & n) { /* try to use the existing write source for the track, to keep numbering sane */ @@ -3083,7 +3054,7 @@ Session::create_midi_source_for_session (Track* track, string const & n, bool as } const string name = new_midi_source_name (n); - const string path = new_source_path_from_name (DataType::MIDI, name, as_stub); + const string path = new_source_path_from_name (DataType::MIDI, name); return boost::dynamic_pointer_cast ( SourceFactory::createWritable ( @@ -3779,45 +3750,18 @@ BufferSet& Session::get_silent_buffers (ChanCount count) { return ProcessThread::get_silent_buffers (count); -#if 0 - assert(_silent_buffers->available() >= count); - _silent_buffers->set_count(count); - - for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { - for (size_t i= 0; i < count.get(*t); ++i) { - _silent_buffers->get(*t, i).clear(); - } - } - - return *_silent_buffers; -#endif } BufferSet& Session::get_scratch_buffers (ChanCount count) { return ProcessThread::get_scratch_buffers (count); -#if 0 - if (count != ChanCount::ZERO) { - assert(_scratch_buffers->available() >= count); - _scratch_buffers->set_count(count); - } else { - _scratch_buffers->set_count (_scratch_buffers->available()); - } - - return *_scratch_buffers; -#endif } BufferSet& Session::get_mix_buffers (ChanCount count) { return ProcessThread::get_mix_buffers (count); -#if 0 - assert(_mix_buffers->available() >= count); - _mix_buffers->set_count(count); - return *_mix_buffers; -#endif } uint32_t