summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorSampo Savolainen <v2@iki.fi>2006-10-27 22:48:19 +0000
committerSampo Savolainen <v2@iki.fi>2006-10-27 22:48:19 +0000
commit674e73ae77480ef851374dae79e7c5c023f04635 (patch)
treeb77ee49f186601e5d3184474fcc56f826f67a83f /libs
parent1bd4c5b3a212460eed1773f6b049d18c89625565 (diff)
Embedded files / embedding files now work.
git-svn-id: svn://localhost/ardour2/trunk@1032 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/audiofilesource.h5
-rw-r--r--libs/ardour/ardour/coreaudiosource.h2
-rw-r--r--libs/ardour/ardour/sndfilesource.h2
-rw-r--r--libs/ardour/audiofilesource.cc25
-rw-r--r--libs/ardour/coreaudiosource.cc2
-rw-r--r--libs/ardour/sndfilesource.cc14
6 files changed, 43 insertions, 7 deletions
diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h
index 53e27b1df9..ac63941a8c 100644
--- a/libs/ardour/ardour/audiofilesource.h
+++ b/libs/ardour/ardour/audiofilesource.h
@@ -81,6 +81,8 @@ class AudioFileSource : public AudioSource {
void mark_take (string);
string take_id() const { return _take_id; }
+ bool is_embedded() const { return _is_embedded; }
+
static void set_bwf_serial_number (int);
static void set_search_path (string);
@@ -124,6 +126,9 @@ class AudioFileSource : public AudioSource {
uint64_t timeline_position;
bool file_is_new;
+ bool _is_embedded;
+ static bool determine_embeddedness(string path);
+
static string peak_dir;
static string search_path;
diff --git a/libs/ardour/ardour/coreaudiosource.h b/libs/ardour/ardour/coreaudiosource.h
index 668fe61102..5f54d01f5d 100644
--- a/libs/ardour/ardour/coreaudiosource.h
+++ b/libs/ardour/ardour/coreaudiosource.h
@@ -50,7 +50,7 @@ class CoreAudioSource : public AudioFileSource {
mutable nframes_t tmpbufsize;
mutable Glib::Mutex _tmpbuf_lock;
- void init (const string &str);
+ void init (string str);
};
}; /* namespace ARDOUR */
diff --git a/libs/ardour/ardour/sndfilesource.h b/libs/ardour/ardour/sndfilesource.h
index 50fd5e6839..6302d88967 100644
--- a/libs/ardour/ardour/sndfilesource.h
+++ b/libs/ardour/ardour/sndfilesource.h
@@ -69,7 +69,7 @@ class SndFileSource : public AudioFileSource {
mutable float *interleave_buf;
mutable nframes_t interleave_bufsize;
- void init (const string &str);
+ void init (string str);
int open();
void close();
int setup_broadcast_info (nframes_t when, struct tm&, time_t);
diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc
index 77709e3a3c..8fe6c845c0 100644
--- a/libs/ardour/audiofilesource.cc
+++ b/libs/ardour/audiofilesource.cc
@@ -66,6 +66,7 @@ AudioFileSource::AudioFileSource (Session& s, string idstr, Flag flags)
: AudioSource (s, idstr), _flags (flags)
{
/* constructor used for existing external to session files. file must exist already */
+ _is_embedded = AudioFileSource::determine_embeddedness (idstr);
if (init (idstr, true)) {
throw failed_constructor ();
@@ -77,6 +78,7 @@ AudioFileSource::AudioFileSource (Session& s, std::string path, Flag flags, Samp
: AudioSource (s, path), _flags (flags)
{
/* constructor used for new internal-to-session files. file cannot exist */
+ _is_embedded = false;
if (init (path, false)) {
throw failed_constructor ();
@@ -106,6 +108,12 @@ AudioFileSource::~AudioFileSource ()
}
bool
+AudioFileSource::determine_embeddedness (std::string path)
+{
+ return (path.find("/") == 0);
+}
+
+bool
AudioFileSource::removable () const
{
return (_flags & Removable) && ((_flags & RemoveAtDestroy) || ((_flags & RemovableIfEmpty) && length() == 0));
@@ -277,6 +285,12 @@ AudioFileSource::set_state (const XMLNode& node)
}
+ if ((prop = node.property (X_("name"))) != 0) {
+ _is_embedded = AudioFileSource::determine_embeddedness (prop->value());
+ } else {
+ _is_embedded = false;
+ }
+
return 0;
}
@@ -318,6 +332,11 @@ AudioFileSource::mark_take (string id)
int
AudioFileSource::move_to_trash (const string trash_dir_name)
{
+ if (is_embedded()) {
+ cerr << "tried to move an embedded region to trash" << endl;
+ return -1;
+ }
+
string newpath;
if (!writable()) {
@@ -465,7 +484,11 @@ AudioFileSource::find (string pathstr, bool must_exist, bool& isnew)
/* external files and/or very very old style sessions include full paths */
_path = pathstr;
- _name = pathstr.substr (pathstr.find_last_of ('/') + 1);
+ if (is_embedded()) {
+ _name = pathstr;
+ } else {
+ _name = pathstr.substr (pathstr.find_last_of ('/') + 1);
+ }
if (access (_path.c_str(), R_OK) != 0) {
diff --git a/libs/ardour/coreaudiosource.cc b/libs/ardour/coreaudiosource.cc
index c8cbb7a40d..a5d195172c 100644
--- a/libs/ardour/coreaudiosource.cc
+++ b/libs/ardour/coreaudiosource.cc
@@ -43,7 +43,7 @@ CoreAudioSource::CoreAudioSource (Session& s, const string& idstr, Flag flags)
}
void
-CoreAudioSource::init (const string& idstr)
+CoreAudioSource::init (string idstr)
{
string::size_type pos;
diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc
index 1e408e12bc..df8eb3a32f 100644
--- a/libs/ardour/sndfilesource.cc
+++ b/libs/ardour/sndfilesource.cc
@@ -164,7 +164,7 @@ SndFileSource::SndFileSource (Session& s, string idstr, SampleFormat sfmt, Heade
}
void
-SndFileSource::init (const string& idstr)
+SndFileSource::init (string idstr)
{
string::size_type pos;
string file;
@@ -174,12 +174,20 @@ SndFileSource::init (const string& idstr)
sf = 0;
_broadcast_info = 0;
+ string tmp_name;
+
if ((pos = idstr.find_last_of (':')) == string::npos) {
channel = 0;
- _name = Glib::path_get_basename (idstr);
+ tmp_name = idstr;
} else {
channel = atoi (idstr.substr (pos+1).c_str());
- _name = Glib::path_get_basename (idstr.substr (0, pos));
+ tmp_name = idstr.substr (0, pos);
+ }
+
+ if (is_embedded()) {
+ _name = tmp_name;
+ } else {
+ _name = Glib::path_get_basename (tmp_name);
}
/* although libsndfile says we don't need to set this,