Allow to uniquely identify sessions

This is in preparation to allow merging sessions, or importing
partial state, and particularly different versions of the same
session where PBD::Ids may match.
This commit is contained in:
Robin Gareus 2025-11-10 15:56:04 +01:00
parent b6cca7afce
commit f2a267675c
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
3 changed files with 14 additions and 0 deletions

View file

@ -60,6 +60,7 @@
#include "pbd/statefuldestructible.h" #include "pbd/statefuldestructible.h"
#include "pbd/signals.h" #include "pbd/signals.h"
#include "pbd/undo.h" #include "pbd/undo.h"
#include "pbd/uuid.h"
#ifdef USE_TLSF #ifdef USE_TLSF
# include "pbd/tlsf.h" # include "pbd/tlsf.h"
@ -233,6 +234,7 @@ public:
* internal, not user-visible IDs */ * internal, not user-visible IDs */
static unsigned int next_name_id (); static unsigned int next_name_id ();
std::string uuid() const { return _uuid.to_s(); }
std::string path() const { return _path; } std::string path() const { return _path; }
std::string name() const { return _name; } std::string name() const { return _name; }
std::string snap_name() const { return _current_snapshot_name; } std::string snap_name() const { return _current_snapshot_name; }
@ -1555,6 +1557,7 @@ private:
bool maybe_stop (samplepos_t limit); bool maybe_stop (samplepos_t limit);
bool maybe_sync_start (pframes_t &); bool maybe_sync_start (pframes_t &);
PBD::UUID _uuid;
std::string _path; std::string _path;
std::string _name; std::string _name;
bool _is_new; bool _is_new;

View file

@ -3136,6 +3136,7 @@ LuaBindings::common (lua_State* L)
.addFunction ("name", &Session::name) .addFunction ("name", &Session::name)
.addFunction ("path", &Session::path) .addFunction ("path", &Session::path)
.addFunction ("uuid", &Session::uuid)
.addFunction ("record_status", &Session::record_status) .addFunction ("record_status", &Session::record_status)
.addFunction ("maybe_enable_record", &Session::maybe_enable_record) .addFunction ("maybe_enable_record", &Session::maybe_enable_record)
.addFunction ("disable_record", &Session::disable_record) .addFunction ("disable_record", &Session::disable_record)

View file

@ -831,6 +831,8 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot
PBD::Unwinder<bool> uw (LV2Plugin::force_state_save, for_archive); PBD::Unwinder<bool> uw (LV2Plugin::force_state_save, for_archive);
PBD::Unwinder<PBD::UUID> uw2 (_uuid, fork_state != NormalSave ? PBD::UUID () : _uuid);
SessionSaveUnderway (); /* EMIT SIGNAL */ SessionSaveUnderway (); /* EMIT SIGNAL */
bool mark_as_clean = true; bool mark_as_clean = true;
@ -1235,6 +1237,7 @@ Session::state (bool save_template, snapshot_t snapshot_type, bool for_archive,
if (!save_template) { if (!save_template) {
node->set_property ("uuid", _uuid.to_s());
node->set_property ("name", _name); node->set_property ("name", _name);
node->set_property ("sample-rate", _base_sample_rate); node->set_property ("sample-rate", _base_sample_rate);
@ -1819,6 +1822,13 @@ Session::set_state (const XMLNode& node, int version)
#endif #endif
} }
{
std::string str;
if (node.get_property ("uuid", str)) {
_uuid = str;
}
}
setup_raid_path(_session_dir->root_path()); setup_raid_path(_session_dir->root_path());
node.get_property (X_("end-is-free"), _session_range_is_free); //deprecated, but use old values if they are in the config node.get_property (X_("end-is-free"), _session_range_is_free); //deprecated, but use old values if they are in the config