X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Faudio_diskstream.cc;h=60b21bbc22c1fa5c24a2acc1f9ca96d851a1ae0c;hb=c95c221493e03ee029223531d459c14b4d4d392d;hp=f4d10c2043041dc41e83926acb9aceed428a944e;hpb=d63e8ba0e8eeda4f53684bbd20f027c0cd6f7c89;p=ardour.git diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index f4d10c2043..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 */ @@ -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*/) { @@ -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; } @@ -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; +}