Add API to unset last capture source(s)
This is in preparation to clear the list when switching snapshots to prevent destroying references. https://discourse.ardour.org/t/discard-last-take-impacts-previous-snapshots-is-this-wanted-behaviour/111420/6?u=x42
This commit is contained in:
@@ -84,6 +84,7 @@ public:
|
||||
bool configure_io (ChanCount in, ChanCount out);
|
||||
|
||||
std::list<std::shared_ptr<Source> >& last_capture_sources () { return _last_capture_sources; }
|
||||
void reset_last_capture_sources ();
|
||||
|
||||
bool record_enabled () const { return _record_enabled.load(); }
|
||||
bool record_safe () const { return _record_safe.load(); }
|
||||
@@ -192,6 +193,7 @@ private:
|
||||
std::atomic<int> _record_safe;
|
||||
std::atomic<int> _samples_pending_write;
|
||||
std::atomic<int> _num_captured_loops;
|
||||
std::atomic<int> _reset_last_capture_sources;
|
||||
|
||||
std::shared_ptr<SMFSource> _midi_write_source;
|
||||
|
||||
|
||||
@@ -872,6 +872,7 @@ public:
|
||||
|
||||
int remove_last_capture ();
|
||||
void get_last_capture_sources (std::list<std::shared_ptr<Source> >&);
|
||||
void reset_last_capture_sources ();
|
||||
|
||||
/** handlers should return -1 for "stop cleanup",
|
||||
0 for "yes, delete this playlist",
|
||||
|
||||
@@ -144,6 +144,7 @@ public:
|
||||
void request_input_monitoring (bool);
|
||||
void ensure_input_monitoring (bool);
|
||||
std::list<std::shared_ptr<Source> > & last_capture_sources ();
|
||||
void reset_last_capture_sources ();
|
||||
std::string steal_write_source_name ();
|
||||
void reset_write_sources (bool mark_write_complete);
|
||||
float playback_buffer_load () const;
|
||||
|
||||
@@ -69,6 +69,7 @@ DiskWriter::DiskWriter (Session& s, Track& t, string const & str, DiskIOProcesso
|
||||
_record_safe.store (0);
|
||||
_samples_pending_write.store (0);
|
||||
_num_captured_loops.store (0);
|
||||
_reset_last_capture_sources.store (0);
|
||||
}
|
||||
|
||||
DiskWriter::~DiskWriter ()
|
||||
@@ -281,6 +282,12 @@ DiskWriter::calculate_record_range (Temporal::OverlapType ot, samplepos_t transp
|
||||
_first_recordable_sample, _last_recordable_sample, rec_nframes, rec_offset));
|
||||
}
|
||||
|
||||
void
|
||||
DiskWriter::reset_last_capture_sources ()
|
||||
{
|
||||
_reset_last_capture_sources.store (1);
|
||||
}
|
||||
|
||||
void
|
||||
DiskWriter::engage_record_enable ()
|
||||
{
|
||||
@@ -561,7 +568,9 @@ DiskWriter::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
||||
|
||||
}
|
||||
|
||||
if (can_record && !_last_capture_sources.empty ()) {
|
||||
int canderef (1);
|
||||
const bool reset_capture_src = _reset_last_capture_sources.compare_exchange_strong (canderef, 0);
|
||||
if ((reset_capture_src || can_record) && !_last_capture_sources.empty ()) {
|
||||
_last_capture_sources.clear ();
|
||||
}
|
||||
|
||||
|
||||
@@ -4856,6 +4856,20 @@ Session::get_last_capture_sources (std::list<std::shared_ptr<Source> >& srcs)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Session::reset_last_capture_sources ()
|
||||
{
|
||||
std::shared_ptr<RouteList const> rl = routes.reader ();
|
||||
for (auto const& i : *rl) {
|
||||
std::shared_ptr<Track> tr = std::dynamic_pointer_cast<Track> (i);
|
||||
if (!tr) {
|
||||
continue;
|
||||
}
|
||||
tr->reset_last_capture_sources ();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Source Management */
|
||||
|
||||
void
|
||||
|
||||
@@ -585,6 +585,12 @@ Track::last_capture_sources ()
|
||||
return _disk_writer->last_capture_sources ();
|
||||
}
|
||||
|
||||
void
|
||||
Track::reset_last_capture_sources ()
|
||||
{
|
||||
_disk_writer->reset_last_capture_sources ();
|
||||
}
|
||||
|
||||
std::string
|
||||
Track::steal_write_source_name()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user