mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 08:36:32 +01:00
Overhaul [get]last_capture API
* Fix copy/edit bug: `get_last_capture_sources` cleared last capture sources. tagging a take made its removal impossible. * `remove_last_capture` also directly modified capture sources by reference in calling thread. * get_ prefix violates styleguide #12
This commit is contained in:
parent
a47a78d15a
commit
aafb2c8904
2 changed files with 31 additions and 22 deletions
|
|
@ -874,7 +874,9 @@ public:
|
|||
int destroy_sources (std::list<std::shared_ptr<Source> > const&);
|
||||
|
||||
int remove_last_capture ();
|
||||
void get_last_capture_sources (std::list<std::shared_ptr<Source> >&);
|
||||
void get_last_capture_sources (std::list<std::shared_ptr<Source> >&); // deprecated
|
||||
bool have_last_capture_sources () const;
|
||||
void last_capture_sources (std::list<std::shared_ptr<Source> >&) const;
|
||||
void reset_last_capture_sources ();
|
||||
|
||||
/** handlers should return -1 for "stop cleanup",
|
||||
|
|
|
|||
|
|
@ -4809,27 +4809,15 @@ Session::destroy_sources (list<std::shared_ptr<Source> > const& srcs)
|
|||
int
|
||||
Session::remove_last_capture ()
|
||||
{
|
||||
list<std::shared_ptr<Source> > srcs;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
list<std::shared_ptr<Source> >& l = tr->last_capture_sources();
|
||||
|
||||
if (!l.empty()) {
|
||||
srcs.insert (srcs.end(), l.begin(), l.end());
|
||||
l.clear ();
|
||||
}
|
||||
}
|
||||
list<std::shared_ptr<Source>> srcs;
|
||||
last_capture_sources (srcs);
|
||||
|
||||
destroy_sources (srcs);
|
||||
|
||||
/* save state so we don't end up with a session file
|
||||
* referring to non-existent sources.
|
||||
*
|
||||
* Note: save_state calls reset_last_capture_sources ();
|
||||
*/
|
||||
|
||||
save_state ();
|
||||
|
|
@ -4838,7 +4826,7 @@ Session::remove_last_capture ()
|
|||
}
|
||||
|
||||
void
|
||||
Session::get_last_capture_sources (std::list<std::shared_ptr<Source> >& srcs)
|
||||
Session::last_capture_sources (std::list<std::shared_ptr<Source>>& srcs) const
|
||||
{
|
||||
std::shared_ptr<RouteList const> rl = routes.reader ();
|
||||
for (auto const& i : *rl) {
|
||||
|
|
@ -4847,13 +4835,32 @@ Session::get_last_capture_sources (std::list<std::shared_ptr<Source> >& srcs)
|
|||
continue;
|
||||
}
|
||||
|
||||
list<std::shared_ptr<Source> >& l = tr->last_capture_sources();
|
||||
list<std::shared_ptr<Source>> const& l = tr->last_capture_sources();
|
||||
srcs.insert (srcs.end(), l.begin(), l.end());
|
||||
}
|
||||
}
|
||||
|
||||
if (!l.empty()) {
|
||||
srcs.insert (srcs.end(), l.begin(), l.end());
|
||||
l.clear ();
|
||||
bool
|
||||
Session::have_last_capture_sources () const
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
if (!tr->last_capture_sources().empty ()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
Session::get_last_capture_sources (std::list<std::shared_ptr<Source>>& srcs)
|
||||
{
|
||||
last_capture_sources (srcs);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue