X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Faudio_diskstream.cc;h=60b21bbc22c1fa5c24a2acc1f9ca96d851a1ae0c;hb=c95c221493e03ee029223531d459c14b4d4d392d;hp=622a42edf2e935765cfa4714ab87da02125bbd36;hpb=8c5cff60912c7e0a7256f635641399500d8d00d9;p=ardour.git diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index 622a42edf2..60b21bbc22 100644 --- a/libs/ardour/audio_diskstream.cc +++ b/libs/ardour/audio_diskstream.cc @@ -148,6 +148,8 @@ AudioDiskstream::free_working_buffers() void AudioDiskstream::non_realtime_input_change () { + bool need_write_sources = false; + { Glib::Threads::Mutex::Lock lm (state_lock); @@ -155,6 +157,11 @@ AudioDiskstream::non_realtime_input_change () return; } + boost::shared_ptr cr = channels.reader(); + if (!cr->empty() && !cr->front()->write_source) { + need_write_sources = true; + } + if (input_change_pending.type == IOChange::ConfigurationChanged) { RCUWriter writer (channels); boost::shared_ptr c = writer.get_copy(); @@ -166,6 +173,8 @@ AudioDiskstream::non_realtime_input_change () } else if (_io->n_ports().n_audio() < _n_channels.n_audio()) { remove_channel_from (c, _n_channels.n_audio() - _io->n_ports().n_audio()); } + + need_write_sources = true; } if (input_change_pending.type & IOChange::ConnectionsChanged) { @@ -179,9 +188,9 @@ AudioDiskstream::non_realtime_input_change () /* implicit unlock */ } - /* reset capture files */ - - reset_write_sources (false); + if (need_write_sources) { + reset_write_sources (false); + } /* now refill channel buffers */ @@ -1752,7 +1761,7 @@ AudioDiskstream::prep_record_enable () if (Config->get_monitoring_model() == HardwareMonitoring) { for (ChannelList::iterator chan = c->begin(); chan != c->end(); ++chan) { - (*chan)->source.request_jack_monitors_input (!(_session.config.get_auto_input() && rolling)); + (*chan)->source.request_input_monitoring (!(_session.config.get_auto_input() && rolling)); capturing_sources.push_back ((*chan)->write_source); (*chan)->write_source->mark_streaming_write_started (); } @@ -1773,7 +1782,7 @@ AudioDiskstream::prep_record_disable () boost::shared_ptr c = channels.reader(); if (Config->get_monitoring_model() == HardwareMonitoring) { for (ChannelList::iterator chan = c->begin(); chan != c->end(); ++chan) { - (*chan)->source.request_jack_monitors_input (false); + (*chan)->source.request_input_monitoring (false); } } capturing_sources.clear (); @@ -1789,7 +1798,7 @@ AudioDiskstream::get_state () LocaleGuard lg (X_("POSIX")); boost::shared_ptr c = channels.reader(); - snprintf (buf, sizeof(buf), "%zd", c->size()); + snprintf (buf, sizeof(buf), "%u", (unsigned int) c->size()); node.add_property ("channels", buf); if (!capturing_sources.empty() && _session.get_record_enabled()) { @@ -1908,7 +1917,7 @@ AudioDiskstream::use_new_write_source (uint32_t n) try { if ((chan->write_source = _session.create_audio_source_for_session ( - n_channels().n_audio(), name(), n, destructive())) == 0) { + n_channels().n_audio(), write_source_name(), n, destructive())) == 0) { throw failed_constructor(); } } @@ -1926,14 +1935,6 @@ AudioDiskstream::use_new_write_source (uint32_t n) return 0; } -list > -AudioDiskstream::steal_write_sources() -{ - /* not possible to steal audio write sources */ - list > ret; - return ret; -} - void AudioDiskstream::reset_write_sources (bool mark_write_complete, bool /*force*/) { @@ -2039,12 +2040,12 @@ AudioDiskstream::allocate_temporary_buffers () } void -AudioDiskstream::request_jack_monitors_input (bool yn) +AudioDiskstream::request_input_monitoring (bool yn) { boost::shared_ptr c = channels.reader(); for (ChannelList::iterator chan = c->begin(); chan != c->end(); ++chan) { - (*chan)->source.request_jack_monitors_input (yn); + (*chan)->source.request_input_monitoring (yn); } } @@ -2187,11 +2188,16 @@ AudioDiskstream::use_pending_capture_data (XMLNode& node) continue; } + /* XXX as of June 2014, we always record to mono + files. Since this Source is being created as part of + crash recovery, we know that we need the first + channel (the final argument to the SourceFactory + call below). If we ever support non-mono files for + capture, this will need rethinking. + */ + try { - fs = boost::dynamic_pointer_cast ( - SourceFactory::createWritable ( - DataType::AUDIO, _session, - prop->value(), false, _session.frame_rate())); + fs = boost::dynamic_pointer_cast (SourceFactory::createForRecovery (DataType::AUDIO, _session, prop->value(), 0)); } catch (failed_constructor& err) { @@ -2222,21 +2228,31 @@ AudioDiskstream::use_pending_capture_data (XMLNode& node) return -1; } - boost::shared_ptr region; - try { - PropertyList plist; + boost::shared_ptr wf_region; + boost::shared_ptr region; + + /* First create the whole file region */ + PropertyList plist; + plist.add (Properties::start, 0); plist.add (Properties::length, first_fs->length (first_fs->timeline_position())); plist.add (Properties::name, region_name_from_path (first_fs->name(), true)); - region = boost::dynamic_pointer_cast (RegionFactory::create (pending_sources, plist)); + wf_region = boost::dynamic_pointer_cast (RegionFactory::create (pending_sources, plist)); + + wf_region->set_automatic (true); + wf_region->set_whole_file (true); + wf_region->special_set_position (position); + + /* Now create a region that isn't the whole file for adding to + * the playlist */ - region->set_automatic (true); - region->set_whole_file (true); - region->special_set_position (0); + region = boost::dynamic_pointer_cast (RegionFactory::create (pending_sources, plist)); + + _playlist->add_region (region, position); } catch (failed_constructor& err) { @@ -2247,7 +2263,6 @@ AudioDiskstream::use_pending_capture_data (XMLNode& node) return -1; } - _playlist->add_region (region, position); return 0; } @@ -2367,13 +2382,13 @@ AudioDiskstream::ChannelSource::is_physical () const } void -AudioDiskstream::ChannelSource::request_jack_monitors_input (bool yn) const +AudioDiskstream::ChannelSource::request_input_monitoring (bool yn) const { if (name.empty()) { return; } - return AudioEngine::instance()->request_jack_monitors_input (name, yn); + return AudioEngine::instance()->request_input_monitoring (name, yn); } AudioDiskstream::ChannelInfo::ChannelInfo (framecnt_t playback_bufsize, framecnt_t capture_bufsize, framecnt_t speed_size, framecnt_t wrap_size) @@ -2445,6 +2460,9 @@ AudioDiskstream::ChannelInfo::~ChannelInfo () bool AudioDiskstream::set_name (string const & name) { + if (_name == name) { + return true; + } Diskstream::set_name (name); /* get a new write source so that its name reflects the new diskstream name */ @@ -2459,3 +2477,24 @@ AudioDiskstream::set_name (string const & name) return true; } + +bool +AudioDiskstream::set_write_source_name (const std::string& str) { + if (_write_source_name == str) { + return true; + } + + Diskstream::set_write_source_name (str); + + if (_write_source_name == name()) { + return true; + } + boost::shared_ptr c = channels.reader(); + ChannelList::iterator i; + int n = 0; + + for (n = 0, i = c->begin(); i != c->end(); ++i, ++n) { + use_new_write_source (n); + } + return true; +}