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 destroy_sources (std::list<std::shared_ptr<Source> > const&);
|
||||||
|
|
||||||
int remove_last_capture ();
|
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 ();
|
void reset_last_capture_sources ();
|
||||||
|
|
||||||
/** handlers should return -1 for "stop cleanup",
|
/** handlers should return -1 for "stop cleanup",
|
||||||
|
|
|
||||||
|
|
@ -4810,26 +4810,14 @@ int
|
||||||
Session::remove_last_capture ()
|
Session::remove_last_capture ()
|
||||||
{
|
{
|
||||||
list<std::shared_ptr<Source>> srcs;
|
list<std::shared_ptr<Source>> srcs;
|
||||||
|
last_capture_sources (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 ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
destroy_sources (srcs);
|
destroy_sources (srcs);
|
||||||
|
|
||||||
/* save state so we don't end up with a session file
|
/* save state so we don't end up with a session file
|
||||||
* referring to non-existent sources.
|
* referring to non-existent sources.
|
||||||
|
*
|
||||||
|
* Note: save_state calls reset_last_capture_sources ();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
save_state ();
|
save_state ();
|
||||||
|
|
@ -4838,7 +4826,7 @@ Session::remove_last_capture ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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 ();
|
std::shared_ptr<RouteList const> rl = routes.reader ();
|
||||||
for (auto const& i : *rl) {
|
for (auto const& i : *rl) {
|
||||||
|
|
@ -4847,13 +4835,32 @@ Session::get_last_capture_sources (std::list<std::shared_ptr<Source> >& srcs)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
list<std::shared_ptr<Source> >& l = tr->last_capture_sources();
|
list<std::shared_ptr<Source>> const& l = tr->last_capture_sources();
|
||||||
|
|
||||||
if (!l.empty()) {
|
|
||||||
srcs.insert (srcs.end(), l.begin(), l.end());
|
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
|
void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue