Using new basetoolkit function for unique naming

applied to source and snapshot names
This commit is contained in:
Bruno
2021-04-25 23:59:18 +02:00
parent 055f5c4c4e
commit 0e3575c1ca
7 changed files with 68 additions and 32 deletions

View File

@@ -185,10 +185,12 @@ void Action::restore(uint target)
void Action::snapshot(const std::string &label)
{
// ignore if locked or if no label is given
if (locked_ || label.empty())
// ignore if locked
if (locked_)
return;
std::string snap_label = BaseToolkit::uniqueName(label, labels());
// create snapshot id
u_int64_t id = BaseToolkit::uniqueId();
@@ -197,10 +199,10 @@ void Action::snapshot(const std::string &label)
se->snapshots()->keys_.push_back(id);
// threaded capture state of current session
std::thread(captureMixerSession, se->snapshots()->xmlDoc_, SNAPSHOT_NODE(id), label).detach();
std::thread(captureMixerSession, se->snapshots()->xmlDoc_, SNAPSHOT_NODE(id), snap_label).detach();
#ifdef ACTION_DEBUG
Log::Info("Snapshot stored %d '%s'", id, label.c_str());
Log::Info("Snapshot stored %d '%s'", id, snap_label.c_str());
#endif
}
@@ -252,6 +254,17 @@ std::list<uint64_t> Action::snapshots() const
return Mixer::manager().session()->snapshots()->keys_;
}
std::list<std::string> Action::labels() const
{
std::list<std::string> names;
tinyxml2::XMLDocument *doc = Mixer::manager().session()->snapshots()->xmlDoc_;
for ( XMLElement *snap = doc->FirstChildElement(); snap ; snap = snap->NextSiblingElement() )
names.push_back( snap->Attribute("label"));
return names;
}
std::string Action::label(uint64_t snapshotid) const
{
std::string label = "";