diff --git a/libs/ardour/ardour/disk_writer.h b/libs/ardour/ardour/disk_writer.h index 9144275ebe..4a63f9b764 100644 --- a/libs/ardour/ardour/disk_writer.h +++ b/libs/ardour/ardour/disk_writer.h @@ -74,7 +74,7 @@ public: std::string steal_write_source_name (); int use_new_write_source (DataType, uint32_t n = 0); - void reset_write_sources (); + void reset_write_sources (bool mark_write_complete); AlignStyle alignment_style () const { return _alignment_style; } void set_align_style (AlignStyle, bool force = false); diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index e2297fd0fd..51171f2367 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1982,7 +1982,7 @@ public: ARDOUR::CueMarkers pending_source_markers; // source markers created while recording private: - void reset_write_sources (); + void reset_write_sources (bool mark_write_complete); SourceMap sources; int load_sources (const XMLNode& node); diff --git a/libs/ardour/ardour/track.h b/libs/ardour/ardour/track.h index 46c0061ec6..855a78f841 100644 --- a/libs/ardour/ardour/track.h +++ b/libs/ardour/ardour/track.h @@ -145,7 +145,7 @@ public: void ensure_input_monitoring (bool); std::list > & last_capture_sources (); std::string steal_write_source_name (); - void reset_write_sources (); + void reset_write_sources (bool mark_write_complete); float playback_buffer_load () const; float capture_buffer_load () const; int do_refill (); diff --git a/libs/ardour/disk_writer.cc b/libs/ardour/disk_writer.cc index 8e5352b431..21493640a9 100644 --- a/libs/ardour/disk_writer.cc +++ b/libs/ardour/disk_writer.cc @@ -123,7 +123,7 @@ DiskWriter::set_write_source_name (string const & str) { _write_source_name = str; - reset_write_sources (); + reset_write_sources (false); return true; } @@ -390,7 +390,7 @@ DiskWriter::set_state (const XMLNode& node, int version) node.get_property (X_("record-safe"), rec_safe); _record_safe.store (rec_safe); - reset_write_sources (); + reset_write_sources (false); return 0; } @@ -1072,7 +1072,7 @@ DiskWriter::do_flush (RunContext ctxt, bool force_flush) } void -DiskWriter::reset_write_sources () +DiskWriter::reset_write_sources (bool mark_write_complete) { std::shared_ptr c = channels.reader(); uint32_t n = 0; @@ -1085,6 +1085,16 @@ DiskWriter::reset_write_sources () for (auto const chan : *c) { + if (mark_write_complete) { + Source::WriterLock lock(chan->write_source->mutex()); + /* we're iterating over channels, so we know this is an + audio source and the duration argument makes no + difference + */ + chan->write_source->mark_streaming_write_completed (lock, timecnt_t()); + chan->write_source->done_with_peakfile_writes (); + } + if (chan->write_source) { if (chan->write_source->removable()) { @@ -1173,6 +1183,7 @@ DiskWriter::transport_stopped_wallclock (struct tm& when, time_t twhen, bool abo ChannelList::const_iterator chan; std::shared_ptr c = channels.reader(); uint32_t n = 0; + bool mark_write_completed = false; finish_capture (c); @@ -1315,8 +1326,10 @@ DiskWriter::transport_stopped_wallclock (struct tm& when, time_t twhen, bool abo _track.use_captured_sources (audio_srcs, capture_info); _track.use_captured_sources (midi_srcs, capture_info); + mark_write_completed = true; + out: - reset_write_sources (); + reset_write_sources (mark_write_completed); for (vector::iterator ci = capture_info.begin(); ci != capture_info.end(); ++ci) { delete *ci; @@ -1429,6 +1442,7 @@ bool DiskWriter::configure_io (ChanCount in, ChanCount out) { bool changed = false; + { std::shared_ptr c = channels.reader(); if (in.n_audio() != c->size()) { @@ -1445,7 +1459,7 @@ DiskWriter::configure_io (ChanCount in, ChanCount out) } if (record_enabled() || changed) { - reset_write_sources (); + reset_write_sources (false); } return true; @@ -1460,7 +1474,7 @@ DiskWriter::use_playlist (DataType dt, std::shared_ptr playlist) return -1; } if (reset_ws) { - reset_write_sources (); + reset_write_sources (false); } return 0; } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 349a2ec327..31f282b108 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2412,7 +2412,7 @@ Session::set_sample_rate (samplecnt_t frames_per_second) sync_time_vars(); clear_clicks (); - reset_write_sources (); + reset_write_sources (false); DiskReader::alloc_loop_declick (nominal_sample_rate()); Location* loc = _locations->auto_loop_location (); @@ -6124,7 +6124,7 @@ Session::reset_native_file_format () if (tr) { /* don't save state as we do this, there's no point */ _state_of_the_state = StateOfTheState (_state_of_the_state | InCleanup); - tr->reset_write_sources (); + tr->reset_write_sources (false); _state_of_the_state = StateOfTheState (_state_of_the_state & ~InCleanup); } } diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index f3b41a480d..37e8b1ad0a 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -2687,14 +2687,14 @@ Session::get_sources_as_xml () } void -Session::reset_write_sources () +Session::reset_write_sources (bool mark_write_complete) { std::shared_ptr rl = routes.reader(); for (auto const& i : *rl) { std::shared_ptr tr = std::dynamic_pointer_cast (i); if (tr) { _state_of_the_state = StateOfTheState (_state_of_the_state | InCleanup); - tr->reset_write_sources (); + tr->reset_write_sources (mark_write_complete); _state_of_the_state = StateOfTheState (_state_of_the_state & ~InCleanup); } } @@ -5442,7 +5442,7 @@ Session::save_as (SaveAs& saveas) /* ensure that all existing tracks reset their current capture source paths */ - reset_write_sources (); + reset_write_sources (true); /* creating new write sources marks the session as dirty. If the new session is empty, then diff --git a/libs/ardour/track.cc b/libs/ardour/track.cc index 4fc20558f3..a4fd955624 100644 --- a/libs/ardour/track.cc +++ b/libs/ardour/track.cc @@ -592,9 +592,9 @@ Track::steal_write_source_name() } void -Track::reset_write_sources () +Track::reset_write_sources (bool mark_write_complete) { - _disk_writer->reset_write_sources (); + _disk_writer->reset_write_sources (mark_write_complete); } float