introduce the idea of an "unnamed" session

This commit is contained in:
Paul Davis
2020-03-24 10:38:03 -06:00
parent 23d72eedbf
commit 5766989319
3 changed files with 25 additions and 5 deletions

View File

@@ -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;

View File

@@ -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"));
}

View File

@@ -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);
}