summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2020-03-24 10:38:03 -0600
committerPaul Davis <paul@linuxaudiosystems.com>2020-03-24 14:10:39 -0600
commit57669893198bd4c7bbf66b3a154fe14726ee62db (patch)
tree5b84aad487eb0d1b12d540ca4867b2f3a3206fcc /libs
parent23d72eedbf407af1c474360faa5ff86c103a6498 (diff)
introduce the idea of an "unnamed" session
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/session.h6
-rw-r--r--libs/ardour/session.cc5
-rw-r--r--libs/ardour/session_state.cc19
3 files changed, 25 insertions, 5 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 7f18857bff..0f27ac5029 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -207,7 +207,8 @@ public:
const std::string& fullpath,
const std::string& snapshot_name,
BusProfile const * bus_profile = 0,
- std::string mix_template = "");
+ std::string mix_template = "",
+ bool unnamed = false);
virtual ~Session ();
@@ -242,6 +243,7 @@ public:
bool cannot_save () const { return _state_of_the_state & CannotSave; }
bool in_cleanup () const { return _state_of_the_state & InCleanup; }
bool inital_connect_or_deletion_in_progress () { return _state_of_the_state & (InitialConnecting | Deletion); }
+ bool not_named() const;
PBD::Signal0<void> DirtyChanged;
@@ -1270,7 +1272,7 @@ protected:
void set_transport_speed (double speed, bool abort, bool clear_state, bool as_default);
private:
- int create (const std::string& mix_template, BusProfile const *);
+ int create (const std::string& mix_template, BusProfile const *, bool unnamed);
void destroy ();
static guint _name_id_counter;
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 9e4829666f..bb13cee49e 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -172,7 +172,8 @@ Session::Session (AudioEngine &eng,
const string& fullpath,
const string& snapshot_name,
BusProfile const * bus_profile,
- string mix_template)
+ string mix_template,
+ bool unnamed)
: _playlists (new SessionPlaylists)
, _engine (eng)
, process_function (&Session::process_with_events)
@@ -344,7 +345,7 @@ Session::Session (AudioEngine &eng,
Stateful::loading_state_version = CURRENT_SESSION_FILE_VERSION;
- if (create (mix_template, bus_profile)) {
+ if (create (mix_template, bus_profile, unnamed)) {
destroy ();
throw SessionException (_("Session initialization failed"));
}
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index 5098f5d62b..b44b42294c 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -44,6 +44,10 @@
#include <climits>
#include <signal.h>
#include <sys/time.h>
+/* for open(2) */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#ifdef HAVE_SYS_VFS_H
#include <sys/vfs.h>
@@ -80,6 +84,7 @@
#include "pbd/file_utils.h"
#include "pbd/pathexpand.h"
#include "pbd/pthread_utils.h"
+#include "pbd/scoped_file_descriptor.h"
#include "pbd/stacktrace.h"
#include "pbd/types_convert.h"
#include "pbd/localtime_r.h"
@@ -154,6 +159,8 @@ using namespace PBD;
#define DEBUG_UNDO_HISTORY(msg) DEBUG_TRACE (PBD::DEBUG::UndoHistory, string_compose ("%1: %2\n", __LINE__, msg));
+static const char* unnamed_file_name = X_(".unnamed");
+
void
Session::pre_engine_init (string fullpath)
{
@@ -569,13 +576,17 @@ Session::ensure_subdirs ()
* Caller must not hold process lock.
*/
int
-Session::create (const string& session_template, BusProfile const * bus_profile)
+Session::create (const string& session_template, BusProfile const * bus_profile, bool unnamed)
{
if (g_mkdir_with_parents (_path.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session folder \"%1\" (%2)"), _path, strerror (errno)) << endmsg;
return -1;
}
+ if (unnamed) {
+ PBD::ScopedFileDescriptor fd = g_open (Glib::build_filename (_path, unnamed_file_name).c_str(), O_CREAT|O_TRUNC|O_RDWR, 0666);
+ }
+
if (ensure_subdirs ()) {
return -1;
}
@@ -5637,3 +5648,9 @@ Session::redo (uint32_t n)
StateProtector stp (this);
_history.redo (n);
}
+
+bool
+Session::not_named() const
+{
+ return Glib::file_test (Glib::build_filename (_path, unnamed_file_name), Glib::FILE_TEST_EXISTS);
+}