summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-09-19 03:29:16 +0000
committerDavid Robillard <d@drobilla.net>2006-09-19 03:29:16 +0000
commit7bd41538d951c3e476655df741adfbebbb990bde (patch)
treef9988f959571c75535341ab1de463b7cfc5209e3 /libs/ardour
parentc7307c09b8584b15610f0b29a40f839d9183419a (diff)
Merged with trunk R920.
git-svn-id: svn://localhost/ardour2/branches/midi@921 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/SConscript28
-rw-r--r--libs/ardour/ardour/audio_diskstream.h2
-rw-r--r--libs/ardour/ardour/audiofilesource.h9
-rw-r--r--libs/ardour/ardour/audioplaylist.h2
-rw-r--r--libs/ardour/ardour/audioregion.h1
-rw-r--r--libs/ardour/ardour/audiosource.h4
-rw-r--r--libs/ardour/ardour/automation_event.h4
-rw-r--r--libs/ardour/ardour/coreaudiosource.h9
-rw-r--r--libs/ardour/ardour/destructive_filesource.h6
-rw-r--r--libs/ardour/ardour/diskstream.h2
-rw-r--r--libs/ardour/ardour/io.h3
-rw-r--r--libs/ardour/ardour/location.h6
-rw-r--r--libs/ardour/ardour/midi_source.h4
-rw-r--r--libs/ardour/ardour/playlist.h3
-rw-r--r--libs/ardour/ardour/port.h2
-rw-r--r--libs/ardour/ardour/region.h3
-rw-r--r--libs/ardour/ardour/session.h9
-rw-r--r--libs/ardour/ardour/smf_source.h4
-rw-r--r--libs/ardour/ardour/sndfilesource.h6
-rw-r--r--libs/ardour/ardour/source.h11
-rw-r--r--libs/ardour/ardour/source_factory.h9
-rw-r--r--libs/ardour/ardour/tempo.h3
-rw-r--r--libs/ardour/audio_diskstream.cc7
-rw-r--r--libs/ardour/audio_playlist.cc1
-rw-r--r--libs/ardour/audioengine.cc5
-rw-r--r--libs/ardour/audiofilesource.cc24
-rw-r--r--libs/ardour/audiofilter.cc2
-rw-r--r--libs/ardour/audioregion.cc23
-rw-r--r--libs/ardour/audiosource.cc8
-rw-r--r--libs/ardour/coreaudiosource.cc157
-rw-r--r--libs/ardour/destructive_filesource.cc12
-rw-r--r--libs/ardour/globals.cc4
-rw-r--r--libs/ardour/import.cc2
-rw-r--r--libs/ardour/io.cc5
-rw-r--r--libs/ardour/location.cc5
-rw-r--r--libs/ardour/midi_source.cc8
-rw-r--r--libs/ardour/panner.cc2
-rw-r--r--libs/ardour/plugin.cc4
-rw-r--r--libs/ardour/route.cc14
-rw-r--r--libs/ardour/session.cc74
-rw-r--r--libs/ardour/session_state.cc175
-rw-r--r--libs/ardour/session_time.cc4
-rw-r--r--libs/ardour/session_timefx.cc3
-rw-r--r--libs/ardour/smf_source.cc8
-rw-r--r--libs/ardour/sndfilesource.cc16
-rw-r--r--libs/ardour/source.cc13
-rw-r--r--libs/ardour/source_factory.cc81
-rw-r--r--libs/ardour/tempo.cc30
-rw-r--r--libs/ardour/utils.cc2
-rw-r--r--libs/ardour/vst_plugin.cc4
50 files changed, 422 insertions, 401 deletions
diff --git a/libs/ardour/SConscript b/libs/ardour/SConscript
index c15897d8be..2e5253ec25 100644
--- a/libs/ardour/SConscript
+++ b/libs/ardour/SConscript
@@ -171,9 +171,27 @@ def CheckJackRecomputeLatencies(context):
context.Result(result)
return result
+jack_video_frame_offset_test = """
+#include <jack/transport.h>
+int main(int argc, char** argv)
+{
+ jack_position_t pos;
+
+ pos.valid & JackVideoFrameOffset;
+ return 0;
+}
+"""
+
+def CheckJackVideoFrameOffset(context):
+ context.Message('Checking for JackVideoFrameOffset in jack_position_bits_t enum...')
+ result = context.TryLink(jack_video_frame_offset_test, '.c')
+ context.Result(result)
+ return result
+
conf = Configure(ardour, custom_tests = {
'CheckJackClientOpen' : CheckJackClientOpen,
- 'CheckJackRecomputeLatencies' : CheckJackRecomputeLatencies
+ 'CheckJackRecomputeLatencies' : CheckJackRecomputeLatencies,
+ 'CheckJackVideoFrameOffset' : CheckJackVideoFrameOffset
})
if conf.CheckJackClientOpen():
@@ -182,6 +200,14 @@ if conf.CheckJackClientOpen():
if conf.CheckJackRecomputeLatencies():
ardour.Append(CXXFLAGS="-DHAVE_JACK_RECOMPUTE_LATENCIES")
+if conf.CheckJackVideoFrameOffset():
+ ardour.Append(CXXFLAGS="-DHAVE_JACK_VIDEO_SUPPORT")
+
+if conf.CheckFunc('jack_port_ensure_monitor'):
+ env.Append(CCFLAGS='-DHAVE_JACK_PORT_ENSURE_MONITOR')
+else:
+ print '\nWARNING: You need at least svn revision 985 of jack for hardware monitoring to work correctly.\n'
+
#
# Optional header files
#
diff --git a/libs/ardour/ardour/audio_diskstream.h b/libs/ardour/ardour/audio_diskstream.h
index 8588c9660d..81206f2bb0 100644
--- a/libs/ardour/ardour/audio_diskstream.h
+++ b/libs/ardour/ardour/audio_diskstream.h
@@ -61,8 +61,6 @@ class AudioDiskstream : public Diskstream
AudioDiskstream (Session &, const XMLNode&);
~AudioDiskstream();
- const PBD::ID& id() const { return _id; }
-
float playback_buffer_load() const;
float capture_buffer_load() const;
diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h
index b1ffab0944..0cab328fba 100644
--- a/libs/ardour/ardour/audiofilesource.h
+++ b/libs/ardour/ardour/audiofilesource.h
@@ -75,7 +75,7 @@ class AudioFileSource : public AudioSource {
int move_to_trash (const string trash_dir_name);
- static bool is_empty (string path);
+ static bool is_empty (Session&, string path);
void mark_streaming_write_completed ();
void mark_take (string);
@@ -104,16 +104,16 @@ class AudioFileSource : public AudioSource {
/* constructor to be called for existing external-to-session files */
- AudioFileSource (std::string path, Flag flags);
+ AudioFileSource (Session&, std::string path, Flag flags);
/* constructor to be called for new in-session files */
- AudioFileSource (std::string path, Flag flags,
+ AudioFileSource (Session&, std::string path, Flag flags,
SampleFormat samp_format, HeaderFormat hdr_format);
/* constructor to be called for existing in-session files */
- AudioFileSource (const XMLNode&);
+ AudioFileSource (Session&, const XMLNode&);
int init (string idstr, bool must_exist);
@@ -121,7 +121,6 @@ class AudioFileSource : public AudioSource {
string _path;
Flag _flags;
string _take_id;
- bool allow_remove_if_empty;
uint64_t timeline_position;
static string peak_dir;
diff --git a/libs/ardour/ardour/audioplaylist.h b/libs/ardour/ardour/audioplaylist.h
index 0426208ba1..6a52f1c16f 100644
--- a/libs/ardour/ardour/audioplaylist.h
+++ b/libs/ardour/ardour/audioplaylist.h
@@ -111,6 +111,8 @@ class AudioPlaylist : public ARDOUR::Playlist
bool region_changed (Change, boost::shared_ptr<Region>);
void crossfade_changed (Change);
void add_crossfade (Crossfade&);
+
+ void source_offset_changed (boost::shared_ptr<AudioRegion> region);
};
} /* namespace ARDOUR */
diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h
index 9b97a88bc0..71a66e52a0 100644
--- a/libs/ardour/ardour/audioregion.h
+++ b/libs/ardour/ardour/audioregion.h
@@ -174,6 +174,7 @@ class AudioRegion : public Region
void recompute_at_end ();
void envelope_changed (Change);
+ void source_offset_changed ();
mutable Curve _fade_in;
FadeShape _fade_in_shape;
diff --git a/libs/ardour/ardour/audiosource.h b/libs/ardour/ardour/audiosource.h
index 751213ee8e..6a0a20d4b8 100644
--- a/libs/ardour/ardour/audiosource.h
+++ b/libs/ardour/ardour/audiosource.h
@@ -47,8 +47,8 @@ const jack_nframes_t frames_per_peak = 256;
class AudioSource : public Source
{
public:
- AudioSource (string name);
- AudioSource (const XMLNode&);
+ AudioSource (Session&, string name);
+ AudioSource (Session&, const XMLNode&);
virtual ~AudioSource ();
virtual jack_nframes_t available_peaks (double zoom) const;
diff --git a/libs/ardour/ardour/automation_event.h b/libs/ardour/ardour/automation_event.h
index a3b84289c1..22ab706f82 100644
--- a/libs/ardour/ardour/automation_event.h
+++ b/libs/ardour/ardour/automation_event.h
@@ -159,8 +159,6 @@ struct ControlEvent {
XMLNode &get_state(void);
int set_state (const XMLNode &s);
- PBD::ID id() { return _id; }
-
void set_max_xval (double);
double get_max_xval() const { return max_xval; }
@@ -189,7 +187,7 @@ struct ControlEvent {
static sigc::signal<void, AutomationList*> AutomationListCreated;
protected:
- PBD::ID _id;
+
struct State : public ARDOUR::StateManager::State {
AutomationEventList events;
diff --git a/libs/ardour/ardour/coreaudiosource.h b/libs/ardour/ardour/coreaudiosource.h
index cf25c466ee..49009caf53 100644
--- a/libs/ardour/ardour/coreaudiosource.h
+++ b/libs/ardour/ardour/coreaudiosource.h
@@ -20,15 +20,16 @@
#ifndef __coreaudio_source_h__
#define __coreaudio_source_h__
+#include <appleutility/CAAudioFile.h>
+
#include <ardour/audiofilesource.h>
-#include <AudioToolbox/ExtendedAudioFile.h>
namespace ARDOUR {
class CoreAudioSource : public AudioFileSource {
public:
- CoreAudioSource (const XMLNode&);
- CoreAudioSource (const string& path_plus_channel, Flag);
+ CoreAudioSource (ARDOUR::Session&, const XMLNode&);
+ CoreAudioSource (ARDOUR::Session&, const string& path_plus_channel, Flag);
~CoreAudioSource ();
float sample_rate() const;
@@ -45,7 +46,7 @@ class CoreAudioSource : public AudioFileSource {
private:
- ExtAudioFileRef af;
+ mutable CAAudioFile af;
uint16_t n_channels;
mutable float *tmpbuf;
diff --git a/libs/ardour/ardour/destructive_filesource.h b/libs/ardour/ardour/destructive_filesource.h
index fb2a3be47b..fed84217e7 100644
--- a/libs/ardour/ardour/destructive_filesource.h
+++ b/libs/ardour/ardour/destructive_filesource.h
@@ -31,12 +31,12 @@ namespace ARDOUR {
class DestructiveFileSource : public SndFileSource {
public:
- DestructiveFileSource (std::string path, SampleFormat samp_format, HeaderFormat hdr_format, jack_nframes_t rate,
+ DestructiveFileSource (Session&, std::string path, SampleFormat samp_format, HeaderFormat hdr_format, jack_nframes_t rate,
Flag flags = AudioFileSource::Flag (AudioFileSource::Writable));
- DestructiveFileSource (std::string path, Flag flags);
+ DestructiveFileSource (Session&, std::string path, Flag flags);
- DestructiveFileSource (const XMLNode&);
+ DestructiveFileSource (Session&, const XMLNode&);
~DestructiveFileSource ();
jack_nframes_t last_capture_start_frame() const;
diff --git a/libs/ardour/ardour/diskstream.h b/libs/ardour/ardour/diskstream.h
index 2bce6a424f..048e9df90f 100644
--- a/libs/ardour/ardour/diskstream.h
+++ b/libs/ardour/ardour/diskstream.h
@@ -92,7 +92,6 @@ class IO;
bool destructive() const { return _flags & Destructive; }
virtual void set_destructive (bool yn);
- const PBD::ID& id() const { return _id; }
bool hidden() const { return _flags & Hidden; }
bool recordable() const { return _flags & Recordable; }
bool reversed() const { return _actual_speed < 0.0f; }
@@ -243,7 +242,6 @@ class IO;
ARDOUR::Session& _session;
ARDOUR::IO* _io;
ChanCount _n_channels;
- PBD::ID _id;
Playlist* _playlist;
mutable gint _record_enabled;
diff --git a/libs/ardour/ardour/io.h b/libs/ardour/ardour/io.h
index ef0ab6c465..6074376291 100644
--- a/libs/ardour/ardour/io.h
+++ b/libs/ardour/ardour/io.h
@@ -263,8 +263,6 @@ public:
void start_pan_touch (uint32_t which);
void end_pan_touch (uint32_t which);
- const PBD::ID& id() const { return _id; }
-
void defer_pan_reset ();
void allow_pan_reset ();
@@ -292,7 +290,6 @@ public:
string _name;
Connection* _input_connection;
Connection* _output_connection;
- PBD::ID _id;
bool no_panner_reset;
bool _phase_invert;
XMLNode* deferred_state;
diff --git a/libs/ardour/ardour/location.h b/libs/ardour/ardour/location.h
index 1052b74bd4..96fb1b1bcf 100644
--- a/libs/ardour/ardour/location.h
+++ b/libs/ardour/ardour/location.h
@@ -121,10 +121,7 @@ class Location : public sigc::trackable, public PBD::StatefulDestructible
XMLNode& get_state (void);
int set_state (const XMLNode&);
- PBD::ID id() { return _id; }
-
private:
- PBD::ID _id;
string _name;
jack_nframes_t _start;
jack_nframes_t _end;
@@ -150,7 +147,6 @@ class Locations : public StateManager, public PBD::StatefulDestructible
XMLNode& get_state (void);
int set_state (const XMLNode&);
- PBD::ID id() { return _id; }
Location *get_location_by_id(PBD::ID);
Location* auto_loop_location () const;
@@ -204,8 +200,6 @@ class Locations : public StateManager, public PBD::StatefulDestructible
Change restore_state (StateManager::State&);
StateManager::State* state_factory (std::string why) const;
-
- PBD::ID _id;
};
} // namespace ARDOUR
diff --git a/libs/ardour/ardour/midi_source.h b/libs/ardour/ardour/midi_source.h
index 757e33f70e..a035bf683e 100644
--- a/libs/ardour/ardour/midi_source.h
+++ b/libs/ardour/ardour/midi_source.h
@@ -43,8 +43,8 @@ class MidiRingBuffer;
class MidiSource : public Source
{
public:
- MidiSource (string name);
- MidiSource (const XMLNode&);
+ MidiSource (Session& session, string name);
+ MidiSource (Session& session, const XMLNode&);
virtual ~MidiSource ();
virtual jack_nframes_t read (MidiRingBuffer& dst, jack_nframes_t start, jack_nframes_t cnt, jack_nframes_t stamp_offset) const;
diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h
index c04b59286f..4249007fff 100644
--- a/libs/ardour/ardour/playlist.h
+++ b/libs/ardour/ardour/playlist.h
@@ -81,7 +81,6 @@ class Playlist : public StateManager, public PBD::StatefulDestructible {
EditMode get_edit_mode() const { return _edit_mode; }
void set_edit_mode (EditMode);
- PBD::ID id() { return _id; }
/* Editing operations */
void add_region (boost::shared_ptr<Region>, jack_nframes_t position, float times = 1, bool with_save = true);
@@ -279,8 +278,6 @@ class Playlist : public StateManager, public PBD::StatefulDestructible {
void unset_freeze_child (Playlist*);
void timestamp_layer_op (boost::shared_ptr<Region>);
-
- PBD::ID _id;
};
} /* namespace ARDOUR */
diff --git a/libs/ardour/ardour/port.h b/libs/ardour/ardour/port.h
index 2a99bdcc16..d6dcd55645 100644
--- a/libs/ardour/ardour/port.h
+++ b/libs/ardour/ardour/port.h
@@ -103,7 +103,7 @@ class Port : public sigc::trackable {
void ensure_monitor_input (bool yn) {
-#ifdef WITH_JACK_PORT_ENSURE_MONITOR
+#ifdef HAVE_JACK_PORT_ENSURE_MONITOR
jack_port_ensure_monitor (_port, yn);
#else
jack_port_request_monitor(_port, yn);
diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h
index c3e93fc7ae..821927f8c2 100644
--- a/libs/ardour/ardour/region.h
+++ b/libs/ardour/ardour/region.h
@@ -37,7 +37,6 @@ class XMLNode;
namespace ARDOUR {
class Playlist;
-class Source;
enum RegionEditState {
EditChangesNothing = 0,
@@ -99,8 +98,6 @@ class Region : public PBD::StatefulDestructible, public StateManager, public boo
virtual ~Region();
- const PBD::ID& id() const { return _id; }
-
/* Note: changing the name of a Region does not constitute an edit */
string name() const { return _name; }
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 09fd01baec..99616f9729 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -267,8 +267,7 @@ class Session : public sigc::trackable, public PBD::StatefulDestructible
bool dirty() const { return _state_of_the_state & Dirty; }
sigc::signal<void> DirtyChanged;
- std::string sound_dir () const;
- std::string tape_dir () const;
+ std::string sound_dir (bool with_path = true) const;
std::string peak_dir () const;
std::string dead_sound_dir () const;
std::string automation_dir () const;
@@ -281,7 +280,8 @@ class Session : public sigc::trackable, public PBD::StatefulDestructible
static string change_audio_path_by_name (string oldpath, string oldname, string newname, bool destructive);
static string change_midi_path_by_name (string oldpath, string oldname, string newname, bool destructive);
- static string peak_path_from_audio_path (string);
+
+ string peak_path_from_audio_path (string) const;
string audio_path_from_name (string, uint32_t nchans, uint32_t chan, bool destructive);
string midi_path_from_name (string);
@@ -1713,9 +1713,10 @@ class Session : public sigc::trackable, public PBD::StatefulDestructible
uint32_t _total_free_4k_blocks;
Glib::Mutex space_lock;
+ static const char* old_sound_dir_name;
static const char* sound_dir_name;
- static const char* tape_dir_name;
static const char* dead_sound_dir_name;
+ static const char* interchange_dir_name;
static const char* peak_dir_name;
string discover_best_sound_dir (bool destructive = false);
diff --git a/libs/ardour/ardour/smf_source.h b/libs/ardour/ardour/smf_source.h
index 5c3fdcfec9..98e78e3802 100644
--- a/libs/ardour/ardour/smf_source.h
+++ b/libs/ardour/ardour/smf_source.h
@@ -44,10 +44,10 @@ class SMFSource : public MidiSource {
};
/** Constructor for existing external-to-session files */
- SMFSource (std::string path, Flag flags = Flag(0));
+ SMFSource (Session& session, std::string path, Flag flags = Flag(0));
/* Constructor for existing in-session files */
- SMFSource (const XMLNode&);
+ SMFSource (Session& session, const XMLNode&);
virtual ~SMFSource ();
diff --git a/libs/ardour/ardour/sndfilesource.h b/libs/ardour/ardour/sndfilesource.h
index ab3e61eb29..cb6bd2e920 100644
--- a/libs/ardour/ardour/sndfilesource.h
+++ b/libs/ardour/ardour/sndfilesource.h
@@ -31,11 +31,11 @@ class SndFileSource : public AudioFileSource {
public:
/* constructor to be called for existing external-to-session files */
- SndFileSource (std::string path, Flag flags);
+ SndFileSource (Session&, std::string path, Flag flags);
/* constructor to be called for new in-session files */
- SndFileSource (std::string path, SampleFormat samp_format, HeaderFormat hdr_format, jack_nframes_t rate,
+ SndFileSource (Session&, std::string path, SampleFormat samp_format, HeaderFormat hdr_format, jack_nframes_t rate,
Flag flags = AudioFileSource::Flag (AudioFileSource::Writable|
AudioFileSource::Removable|
AudioFileSource::RemovableIfEmpty|
@@ -43,7 +43,7 @@ class SndFileSource : public AudioFileSource {
/* constructor to be called for existing in-session files */
- SndFileSource (const XMLNode&);
+ SndFileSource (Session&, const XMLNode&);
~SndFileSource ();
diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h
index a18250fff2..591e7181a1 100644
--- a/libs/ardour/ardour/source.h
+++ b/libs/ardour/ardour/source.h
@@ -32,11 +32,14 @@
namespace ARDOUR {
+class Session;
+
class Source : public PBD::StatefulDestructible, public sigc::trackable
{
public:
- Source (std::string name, DataType type);
- Source (const XMLNode&);
+ Source (Session&, std::string name, DataType type);
+ Source (Session&, const XMLNode&);
+
virtual ~Source ();
std::string name() const { return _name; }
@@ -44,8 +47,6 @@ class Source : public PBD::StatefulDestructible, public sigc::trackable
DataType type() { return _type; }
- const PBD::ID& id() const { return _id; }
-
time_t timestamp() const { return _timestamp; }
void stamp (time_t when) { _timestamp = when; }
@@ -65,13 +66,13 @@ class Source : public PBD::StatefulDestructible, public sigc::trackable
protected:
void update_length (jack_nframes_t pos, jack_nframes_t cnt);
+ Session& _session;
string _name;
DataType _type;
time_t _timestamp;
jack_nframes_t _length;
private:
- PBD::ID _id;
};
}
diff --git a/libs/ardour/ardour/source_factory.h b/libs/ardour/ardour/source_factory.h
index 2b25752a0d..073532c6ab 100644
--- a/libs/ardour/ardour/source_factory.h
+++ b/libs/ardour/ardour/source_factory.h
@@ -13,14 +13,17 @@ class XMLNode;
namespace ARDOUR {
+class Session;
+
class SourceFactory {
public:
static sigc::signal<void,boost::shared_ptr<Source> > SourceCreated;
- static boost::shared_ptr<Source> create (const XMLNode& node);
+ static boost::shared_ptr<Source> create (Session&, const XMLNode& node);
- static boost::shared_ptr<Source> createReadable (DataType type, std::string idstr, AudioFileSource::Flag flags, bool announce = true);
- static boost::shared_ptr<Source> createWritable (DataType type, std::string name, bool destructive, jack_nframes_t rate, bool announce = true);
+ // MIDI sources will have to be hacked in here somehow
+ static boost::shared_ptr<Source> createReadable (DataType type, Session&, std::string idstr, AudioFileSource::Flag flags, bool announce = true);
+ static boost::shared_ptr<Source> createWritable (DataType type, Session&, std::string name, bool destructive, jack_nframes_t rate, bool announce = true);
};
}
diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h
index 9111aeba68..0b37579ecb 100644
--- a/libs/ardour/ardour/tempo.h
+++ b/libs/ardour/ardour/tempo.h
@@ -242,7 +242,6 @@ class TempoMap : public StateManager, public PBD::StatefulDestructible
XMLNode& get_state (void);
int set_state (const XMLNode&);
- PBD::ID id() { return _id; }
void dump (std::ostream&) const;
void clear ();
@@ -320,8 +319,6 @@ class TempoMap : public StateManager, public PBD::StatefulDestructible
void save_state (std::string why);
- PBD::ID _id;
-
};
}; /* namespace ARDOUR */
diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc
index 7b77aad8f5..9572297ac5 100644
--- a/libs/ardour/audio_diskstream.cc
+++ b/libs/ardour/audio_diskstream.cc
@@ -1590,7 +1590,7 @@ AudioDiskstream::transport_stopped (struct tm& when, time_t twhen, bool abort_ca
string region_name;
_session.region_name (region_name, channels[0].write_source->name(), false);
- cerr << _name << ": based on ci of " << (*ci)->start << " for " << (*ci)->frames << " add region " << region_name << endl;
+ // cerr << _name << ": based on ci of " << (*ci)->start << " for " << (*ci)->frames << " add region " << region_name << endl;
try {
boost::shared_ptr<Region> rx (RegionFactory::create (srcs, buffer_position, (*ci)->frames, region_name));
@@ -1948,7 +1948,7 @@ AudioDiskstream::use_new_write_source (uint32_t n)
if (chan.write_source) {
- if (AudioFileSource::is_empty (chan.write_source->path())) {
+ if (AudioFileSource::is_empty (_session, chan.write_source->path())) {
chan.write_source->mark_for_remove ();
chan.write_source.reset ();
} else {
@@ -2185,7 +2185,8 @@ AudioDiskstream::use_pending_capture_data (XMLNode& node)
}
try {
- fs = boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createWritable (DataType::AUDIO, prop->value(), false, _session.frame_rate()));
+ fs = boost::dynamic_pointer_cast<AudioFileSource> (
+ SourceFactory::createWritable (DataType::AUDIO, _session, prop->value(), false, _session.frame_rate()));
}
catch (failed_constructor& err) {
diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc
index 7fc29f84b8..bd09b1e6b3 100644
--- a/libs/ardour/audio_playlist.cc
+++ b/libs/ardour/audio_playlist.cc
@@ -899,3 +899,4 @@ AudioPlaylist::crossfades_at (jack_nframes_t frame, Crossfades& clist)
}
}
}
+
diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc
index ddb835c78f..b2a1fb6a0f 100644
--- a/libs/ardour/audioengine.cc
+++ b/libs/ardour/audioengine.cc
@@ -167,6 +167,9 @@ AudioEngine::stop ()
bool
AudioEngine::get_sync_offset (jack_nframes_t& offset) const
{
+
+#ifdef HAVE_JACK_VIDEO_SUPPORT
+
jack_position_t pos;
(void) jack_transport_query (_jack, &pos);
@@ -176,6 +179,8 @@ AudioEngine::get_sync_offset (jack_nframes_t& offset) const
return true;
}
+#endif
+
return false;
}
diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc
index 963a2274df..adfd352d12 100644
--- a/libs/ardour/audiofilesource.cc
+++ b/libs/ardour/audiofilesource.cc
@@ -63,8 +63,8 @@ char AudioFileSource::bwf_country_code[3] = "US";
char AudioFileSource::bwf_organization_code[4] = "LAS";
char AudioFileSource::bwf_serial_number[13] = "000000000000";
-AudioFileSource::AudioFileSource (string idstr, Flag flags)
- : AudioSource (idstr), _flags (flags)
+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 */
@@ -74,8 +74,8 @@ AudioFileSource::AudioFileSource (string idstr, Flag flags)
}
-AudioFileSource::AudioFileSource (std::string path, Flag flags, SampleFormat samp_format, HeaderFormat hdr_format)
- : AudioSource (path), _flags (flags)
+AudioFileSource::AudioFileSource (Session& s, std::string path, Flag flags, SampleFormat samp_format, HeaderFormat hdr_format)
+ : AudioSource (s, path), _flags (flags)
{
/* constructor used for new internal-to-session files. file cannot exist */
@@ -84,8 +84,8 @@ AudioFileSource::AudioFileSource (std::string path, Flag flags, SampleFormat sam
}
}
-AudioFileSource::AudioFileSource (const XMLNode& node)
- : AudioSource (node), _flags (Flag (Writable|CanRename))
+AudioFileSource::AudioFileSource (Session& s, const XMLNode& node)
+ : AudioSource (s, node), _flags (Flag (Writable|CanRename))
{
/* constructor used for existing internal-to-session files. file must exist */
@@ -101,6 +101,7 @@ AudioFileSource::AudioFileSource (const XMLNode& node)
AudioFileSource::~AudioFileSource ()
{
if (removable()) {
+ cerr << "Removing file " << _path << " because its removable\n";
unlink (_path.c_str());
unlink (peakpath.c_str());
}
@@ -109,7 +110,7 @@ AudioFileSource::~AudioFileSource ()
bool
AudioFileSource::removable () const
{
- return (_flags & Removable) && ((_flags & RemoveAtDestroy) || ((_flags & RemovableIfEmpty) && is_empty (_path)));
+ return (_flags & Removable) && ((_flags & RemoveAtDestroy) || ((_flags & RemovableIfEmpty) && length() == 0));
}
int
@@ -135,7 +136,7 @@ AudioFileSource::init (string pathstr, bool must_exist)
string
AudioFileSource::peak_path (string audio_path)
{
- return Session::peak_path_from_audio_path (audio_path);
+ return _session.peak_path_from_audio_path (audio_path);
}
string
@@ -527,7 +528,7 @@ void
AudioFileSource::set_allow_remove_if_empty (bool yn)
{
if (writable()) {
- allow_remove_if_empty = yn;
+ _flags = Flag (_flags | RemovableIfEmpty);
}
}
@@ -561,11 +562,12 @@ AudioFileSource::set_name (string newname, bool destructive)
}
bool
-AudioFileSource::is_empty (string path)
+AudioFileSource::is_empty (Session& s, string path)
{
bool ret = false;
+
boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (
- SourceFactory::createReadable (DataType::AUDIO, path, NoPeakFile, false));
+ SourceFactory::createReadable (DataType::AUDIO, s, path, NoPeakFile, false));
if (afs) {
ret = (afs->length() == 0);
diff --git a/libs/ardour/audiofilter.cc b/libs/ardour/audiofilter.cc
index 0a630f1e25..4c38ecec20 100644
--- a/libs/ardour/audiofilter.cc
+++ b/libs/ardour/audiofilter.cc
@@ -51,7 +51,7 @@ AudioFilter::make_new_sources (boost::shared_ptr<AudioRegion> region, SourceList
try {
nsrcs.push_back (boost::dynamic_pointer_cast<AudioSource> (
- SourceFactory::createWritable (DataType::AUDIO, path, false, session.frame_rate())));
+ SourceFactory::createWritable (DataType::AUDIO, session, path, false, session.frame_rate())));
}
catch (failed_constructor& err) {
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc
index 362ab305db..959177d0cf 100644
--- a/libs/ardour/audioregion.cc
+++ b/libs/ardour/audioregion.cc
@@ -38,7 +38,7 @@
#include <ardour/dB.h>
#include <ardour/playlist.h>
#include <ardour/audiofilter.h>
-#include <ardour/audiosource.h>
+#include <ardour/audiofilesource.h>
#include "i18n.h"
#include <locale.h>
@@ -71,6 +71,11 @@ AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, jack_nframes_t sta
_fade_out (0.0, 2.0, 1.0, false),
_envelope (0.0, 2.0, 1.0, false)
{
+ boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (src);
+ if (afs) {
+ afs->HeaderPositionOffsetChanged.connect (mem_fun (*this, &AudioRegion::source_offset_changed));
+ }
+
_scale_amplitude = 1.0;
set_default_fades ();
@@ -88,6 +93,11 @@ AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, jack_nframes_t sta
, _fade_out (0.0, 2.0, 1.0, false)
, _envelope (0.0, 2.0, 1.0, false)
{
+ boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (src);
+ if (afs) {
+ afs->HeaderPositionOffsetChanged.connect (mem_fun (*this, &AudioRegion::source_offset_changed));
+ }
+
_scale_amplitude = 1.0;
set_default_fades ();
@@ -180,6 +190,11 @@ AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, const XMLNode& nod
, _fade_out (0.0, 2.0, 1.0, false)
, _envelope (0.0, 2.0, 1.0, false)
{
+ boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (src);
+ if (afs) {
+ afs->HeaderPositionOffsetChanged.connect (mem_fun (*this, &AudioRegion::source_offset_changed));
+ }
+
set_default_fades ();
if (set_state (node)) {
@@ -1165,6 +1180,12 @@ AudioRegion::speed_mismatch (float sr) const
return fsr != sr;
}
+void
+AudioRegion::source_offset_changed ()
+{
+ set_position (source()->natural_position() + start(), this);
+}
+
boost::shared_ptr<AudioSource>
AudioRegion::audio_source (uint32_t n) const
{
diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc
index d74a38097c..a8fe2a7c73 100644
--- a/libs/ardour/audiosource.cc
+++ b/libs/ardour/audiosource.cc
@@ -50,8 +50,8 @@ int AudioSource::peak_request_pipe[2];
bool AudioSource::_build_missing_peakfiles = false;
bool AudioSource::_build_peakfiles = false;
-AudioSource::AudioSource (string name)
- : Source (name, DataType::AUDIO)
+AudioSource::AudioSource (Session& s, string name)
+ : Source (s, name, DataType::AUDIO)
{
if (pending_peak_sources_lock == 0) {
pending_peak_sources_lock = new Glib::Mutex;
@@ -63,8 +63,8 @@ AudioSource::AudioSource (string name)
_write_data_count = 0;
}
-AudioSource::AudioSource (const XMLNode& node)
- : Source (node)
+AudioSource::AudioSource (Session& s, const XMLNode& node)
+ : Source (s, node)
{
if (pending_peak_sources_lock == 0) {
pending_peak_sources_lock = new Glib::Mutex;
diff --git a/libs/ardour/coreaudiosource.cc b/libs/ardour/coreaudiosource.cc
index 0d7e690a25..049b5aabbe 100644
--- a/libs/ardour/coreaudiosource.cc
+++ b/libs/ardour/coreaudiosource.cc
@@ -20,6 +20,9 @@
#include <pbd/error.h>
#include <ardour/coreaudiosource.h>
+#include <appleutility/CAAudioFile.h>
+#include <appleutility/CAStreamBasicDescription.h>
+
#include "i18n.h"
#include <AudioToolbox/AudioFormat.h>
@@ -27,14 +30,14 @@
using namespace ARDOUR;
using namespace PBD;
-CoreAudioSource::CoreAudioSource (const XMLNode& node)
- : AudioFileSource (node)
+CoreAudioSource::CoreAudioSource (Session& s, const XMLNode& node)
+ : AudioFileSource (s, node)
{
init (_name);
}
-CoreAudioSource::CoreAudioSource (const string& idstr, Flag flags)
- : AudioFileSource(idstr, flags)
+CoreAudioSource::CoreAudioSource (Session& s, const string& idstr, Flag flags)
+ : AudioFileSource(s, idstr, flags)
{
init (idstr);
}
@@ -43,93 +46,48 @@ void
CoreAudioSource::init (const string& idstr)
{
string::size_type pos;
- string file;
tmpbuf = 0;
tmpbufsize = 0;
- af = 0;
- OSStatus err = noErr;
_name = idstr;
if ((pos = idstr.find_last_of (':')) == string::npos) {
channel = 0;
- file = idstr;
+ _path = idstr;
} else {
channel = atoi (idstr.substr (pos+1).c_str());
- file = idstr.substr (0, pos);
- }
-
- /* note that we temporarily truncated _id at the colon */
- FSRef fsr;
- err = FSPathMakeRef ((UInt8*)file.c_str(), &fsr, 0);
- if (err != noErr) {
- error << string_compose (_("Could not make reference to file: %1"), name()) << endmsg;
- throw failed_constructor();
- }
-
- err = ExtAudioFileOpen (&fsr, &af);
- if (err != noErr) {
- error << string_compose (_("Could not open file: %1"), name()) << endmsg;
- ExtAudioFileDispose (af);
- throw failed_constructor();
+ _path = idstr.substr (0, pos);
}
- AudioStreamBasicDescription file_asbd;
- memset(&file_asbd, 0, sizeof(AudioStreamBasicDescription));
- size_t asbd_size = sizeof(AudioStreamBasicDescription);
- err = ExtAudioFileGetProperty(af,
- kExtAudioFileProperty_FileDataFormat, &asbd_size, &file_asbd);
- if (err != noErr) {
- error << string_compose (_("Could not get file data format for file: %1"), name()) << endmsg;
- ExtAudioFileDispose (af);
- throw failed_constructor();
- }
- n_channels = file_asbd.mChannelsPerFrame;
-
- cerr << "number of channels: " << n_channels << endl;
+ cerr << "CoreAudioSource::init() " << name() << endl;
- if (channel >= n_channels) {
- error << string_compose(_("CoreAudioSource: file only contains %1 channels; %2 is invalid as a channel number"), n_channels, channel) << endmsg;
- ExtAudioFileDispose (af);
- throw failed_constructor();
- }
+ /* note that we temporarily truncated _id at the colon */
+ try {
+ af.Open(_path.c_str());
- int64_t ca_frames;
- size_t prop_size = sizeof(int64_t);
+ CAStreamBasicDescription file_asbd (af.GetFileDataFormat());
+ n_channels = file_asbd.NumberChannels();
+ cerr << "number of channels: " << n_channels << endl;
+
+ if (channel >= n_channels) {
+ error << string_compose("CoreAudioSource: file only contains %1 channels; %2 is invalid as a channel number (%3)", n_channels, channel, name()) << endmsg;
+ throw failed_constructor();
+ }
- err = ExtAudioFileGetProperty(af, kExtAudioFileProperty_FileLengthFrames, &prop_size, &ca_frames);
- if (err != noErr) {
- error << string_compose (_("Could not get file length for file: %1"), name()) << endmsg;
- ExtAudioFileDispose (af);
- throw failed_constructor();
- }
+ _length = af.GetNumberFrames();
- _length = ca_frames;
- _path = file;
-
- AudioStreamBasicDescription client_asbd;
- memset(&client_asbd, 0, sizeof(AudioStreamBasicDescription));
- client_asbd.mSampleRate = file_asbd.mSampleRate;
- client_asbd.mFormatID = kAudioFormatLinearPCM;
- client_asbd.mFormatFlags = kLinearPCMFormatFlagIsFloat;
- client_asbd.mBytesPerPacket = file_asbd.mChannelsPerFrame * 4;
- client_asbd.mFramesPerPacket = 1;
- client_asbd.mBytesPerFrame = client_asbd.mBytesPerPacket;
- client_asbd.mChannelsPerFrame = file_asbd.mChannelsPerFrame;
- client_asbd.mBitsPerChannel = 32;
-
- err = ExtAudioFileSetProperty (af, kExtAudioFileProperty_ClientDataFormat, asbd_size, &client_asbd);
- if (err != noErr) {
- error << string_compose (_("Could not set client data format for file: %1"), name()) << endmsg;
- ExtAudioFileDispose (af);
+ CAStreamBasicDescription client_asbd(file_asbd);
+ client_asbd.SetCanonical(client_asbd.NumberChannels(), false);
+ af.SetClientFormat (client_asbd);
+ } catch (CAXException& cax) {
+ error << string_compose ("CoreAudioSource: %1 (%2)", cax.mOperation, name()) << endmsg;
throw failed_constructor ();
}
if (_build_peakfiles) {
- if (initialize_peakfile (false, file)) {
- error << string_compose(_("initialize peakfile failed for file %1"), name()) << endmsg;
- ExtAudioFileDispose (af);
+ if (initialize_peakfile (false, _path)) {
+ error << string_compose("CoreAudioSource: initialize peakfile failed (%1)", name()) << endmsg;
throw failed_constructor ();
}
}
@@ -137,41 +95,44 @@ CoreAudioSource::init (const string& idstr)
CoreAudioSource::~CoreAudioSource ()
{
+ cerr << "CoreAudioSource::~CoreAudioSource() " << name() << endl;
GoingAway (); /* EMIT SIGNAL */
- if (af) {
- ExtAudioFileDispose (af);
- }
-
if (tmpbuf) {
delete [] tmpbuf;
}
+
+ cerr << "deletion done" << endl;
}
jack_nframes_t
CoreAudioSource::read_unlocked (Sample *dst, jack_nframes_t start, jack_nframes_t cnt) const
{
- OSStatus err = noErr;
-
- err = ExtAudioFileSeek(af, start);
- if (err != noErr) {
- error << string_compose(_("CoreAudioSource: could not seek to frame %1 within %2 (%3)"), start, _name.substr (1), err) << endmsg;
+ try {
+ af.Seek (start);
+ } catch (CAXException& cax) {
+ error << string_compose("CoreAudioSource: %1 to %2 (%3)", cax.mOperation, start, _name.substr (1)) << endmsg;
return 0;
}
AudioBufferList abl;
abl.mNumberBuffers = 1;
abl.mBuffers[0].mNumberChannels = n_channels;
- abl.mBuffers[0].mDataByteSize = cnt * sizeof(Sample);
- abl.mBuffers[0].mData = dst;
+ UInt32 new_cnt = cnt;
if (n_channels == 1) {
- err = ExtAudioFileRead(af, (UInt32*) &cnt, &abl);
- _read_data_count = cnt * sizeof(float);
- return cnt;
+ abl.mBuffers[0].mDataByteSize = cnt * sizeof(Sample);
+ abl.mBuffers[0].mData = dst;
+ try {
+ af.Read (new_cnt, &abl);
+ } catch (CAXException& cax) {
+ error << string_compose("CoreAudioSource: %1 (%2)", cax.mOperation, _name);
+ }
+ _read_data_count = new_cnt * sizeof(float);
+ return new_cnt;
}
- uint32_t real_cnt = cnt * n_channels;
+ UInt32 real_cnt = cnt * n_channels;
{
Glib::Mutex::Lock lm (_tmpbuf_lock);
@@ -185,10 +146,16 @@ CoreAudioSource::read_unlocked (Sample *dst, jack_nframes_t start, jack_nframes_
tmpbuf = new float[tmpbufsize];
}
- abl.mBuffers[0].mDataByteSize = real_cnt * sizeof(Sample);
+ abl.mBuffers[0].mDataByteSize = tmpbufsize * sizeof(Sample);
abl.mBuffers[0].mData = tmpbuf;
+
+ cerr << "channel: " << channel << endl;
- err = ExtAudioFileRead(af, (UInt32*) &real_cnt, &abl);
+ try {
+ af.Read (real_cnt, &abl);
+ } catch (CAXException& cax) {
+ error << string_compose("CoreAudioSource: %1 (%2)", cax.mOperation, _name);
+ }
float *ptr = tmpbuf + channel;
real_cnt /= n_channels;
@@ -208,15 +175,12 @@ CoreAudioSource::read_unlocked (Sample *dst, jack_nframes_t start, jack_nframes_
float
CoreAudioSource::sample_rate() const
{
- AudioStreamBasicDescription client_asbd;
- memset(&client_asbd, 0, sizeof(AudioStreamBasicDescription));
+ CAStreamBasicDescription client_asbd;
- OSStatus err = noErr;
- size_t asbd_size = sizeof(AudioStreamBasicDescription);
-
- err = ExtAudioFileSetProperty (af, kExtAudioFileProperty_ClientDataFormat, asbd_size, &client_asbd);
- if (err != noErr) {
- error << string_compose(_("Could not detect samplerate for: %1"), name()) << endmsg;
+ try {
+ client_asbd = af.GetClientDataFormat ();
+ } catch (CAXException& cax) {
+ error << string_compose("CoreAudioSource: %1 (%2)", cax.mOperation, _name);
return 0.0;
}
@@ -228,4 +192,3 @@ CoreAudioSource::update_header (jack_nframes_t when, struct tm&, time_t)
{
return 0;
}
-
diff --git a/libs/ardour/destructive_filesource.cc b/libs/ardour/destructive_filesource.cc
index bf16b40005..1e57d88d70 100644
--- a/libs/ardour/destructive_filesource.cc
+++ b/libs/ardour/destructive_filesource.cc
@@ -68,21 +68,21 @@ gain_t* DestructiveFileSource::out_coefficient = 0;
gain_t* DestructiveFileSource::in_coefficient = 0;
jack_nframes_t DestructiveFileSource::xfade_frames = 64;
-DestructiveFileSource::DestructiveFileSource (string path, SampleFormat samp_format, HeaderFormat hdr_format, jack_nframes_t rate, Flag flags)
- : SndFileSource (path, samp_format, hdr_format, rate, flags)
+DestructiveFileSource::DestructiveFileSource (Session& s, string path, SampleFormat samp_format, HeaderFormat hdr_format, jack_nframes_t rate, Flag flags)
+ : SndFileSource (s, path, samp_format, hdr_format, rate, flags)
{
init ();
}
-DestructiveFileSource::DestructiveFileSource (string path, Flag flags)
- : SndFileSource (path, flags)
+DestructiveFileSource::DestructiveFileSource (Session& s, string path, Flag flags)
+ : SndFileSource (s, path, flags)
{
init ();
}
-DestructiveFileSource::DestructiveFileSource (const XMLNode& node)
- : SndFileSource (node)
+DestructiveFileSource::DestructiveFileSource (Session& s, const XMLNode& node)
+ : SndFileSource (s, node)
{
init ();
}
diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc
index 6f3b772ece..cc92529d88 100644
--- a/libs/ardour/globals.cc
+++ b/libs/ardour/globals.cc
@@ -375,7 +375,9 @@ ARDOUR::get_user_ardour_path ()
/* create it if necessary */
- mkdir (path.c_str (), 0755);
+ if (g_mkdir_with_parents (path.c_str (), 0755)) {
+ throw exception ();
+ }
return path;
}
diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc
index 01c7182e14..b10f76424b 100644
--- a/libs/ardour/import.cc
+++ b/libs/ardour/import.cc
@@ -140,7 +140,7 @@ Session::import_audiofile (import_status& status)
try {
newfiles[n] = boost::dynamic_pointer_cast<AudioFileSource> (
- SourceFactory::createWritable (DataType::AUDIO, buf, false, frame_rate()));
+ SourceFactory::createWritable (DataType::AUDIO, *this, buf, false, frame_rate()));
}
catch (failed_constructor& err) {
diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc
index a30881b4da..57a89b2310 100644
--- a/libs/ardour/io.cc
+++ b/libs/ardour/io.cc
@@ -20,6 +20,7 @@
#include <algorithm>
#include <unistd.h>
#include <locale.h>
+#include <errno.h>
#include <sigc++/bind.h>
@@ -2143,8 +2144,8 @@ IO::load_automation (const string& path)
fullpath += path;
in.open (fullpath.c_str());
if (!in) {
- error << string_compose(_("%1: cannot open automation event file \"%2\""), _name, fullpath) << endmsg;
- return -1;
+ error << string_compose(_("%1: cannot open automation event file \"%2\" (%2)"), _name, fullpath, strerror (errno)) << endmsg;
+ return -1;
}
}
diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc
index 30b28c6abe..6b3ea6f220 100644
--- a/libs/ardour/location.cc
+++ b/libs/ardour/location.cc
@@ -81,13 +81,18 @@ Location::set_start (jack_nframes_t s)
{
if (is_mark()) {
if (_start != s) {
+
_start = s;
_end = s;
+
start_changed(this); /* EMIT SIGNAL */
+
if ( is_start() ) {
+
Session::StartTimeChanged (); /* EMIT SIGNAL */
AudioFileSource::set_header_position_offset ( s );
}
+
if ( is_end() ) {
Session::EndTimeChanged (); /* EMIT SIGNAL */
}
diff --git a/libs/ardour/midi_source.cc b/libs/ardour/midi_source.cc
index c4cfe3c71d..de2f6b1c5d 100644
--- a/libs/ardour/midi_source.cc
+++ b/libs/ardour/midi_source.cc
@@ -42,15 +42,15 @@ using namespace PBD;
sigc::signal<void,MidiSource *> MidiSource::MidiSourceCreated;
-MidiSource::MidiSource (string name)
- : Source (name, DataType::MIDI)
+MidiSource::MidiSource (Session& s, string name)
+ : Source (s, name, DataType::MIDI)
{
_read_data_count = 0;
_write_data_count = 0;
}
-MidiSource::MidiSource (const XMLNode& node)
- : Source (node)
+MidiSource::MidiSource (Session& s, const XMLNode& node)
+ : Source (s, node)
{
_read_data_count = 0;
_write_data_count = 0;
diff --git a/libs/ardour/panner.cc b/libs/ardour/panner.cc
index 1ced0faf89..0c3b0a291f 100644
--- a/libs/ardour/panner.cc
+++ b/libs/ardour/panner.cc
@@ -1090,7 +1090,7 @@ Panner::save () const
ofstream out (automation_path.c_str());
if (!out) {
- error << string_compose (_("cannot open pan automation file \"%1\" for saving (%s)"), automation_path, strerror (errno))
+ error << string_compose (_("cannot open pan automation file \"%1\" for saving (%2)"), automation_path, strerror (errno))
<< endmsg;
return -1;
}
diff --git a/libs/ardour/plugin.cc b/libs/ardour/plugin.cc
index 8d200b0ee4..9a82c3bbab 100644
--- a/libs/ardour/plugin.cc
+++ b/libs/ardour/plugin.cc
@@ -224,13 +224,13 @@ Plugin::save_preset (string name, string domain)
free(lrdf_add_preset(source.c_str(), name.c_str(), unique_id(), &defaults));
string path = string_compose("%1/.%2", envvar, domain);
- if (mkdir(path.c_str(), 0775) && errno != EEXIST) {
+ if (g_mkdir_with_parents (path.c_str(), 0775)) {
warning << string_compose(_("Could not create %1. Preset not saved. (%2)"), path, strerror(errno)) << endmsg;
return false;
}
path += "/rdf";
- if (mkdir(path.c_str(), 0775) && errno != EEXIST) {
+ if (g_mkdir_with_parents (path.c_str(), 0775)) {
warning << string_compose(_("Could not create %1. Preset not saved. (%2)"), path, strerror(errno)) << endmsg;
return false;
}
diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc
index 672e0692cb..398df02179 100644
--- a/libs/ardour/route.cc
+++ b/libs/ardour/route.cc
@@ -277,17 +277,17 @@ Route::process_output_buffers (BufferSet& bufs,
-------------------------------------------------------------------------------------------------- */
if (declick > 0) {
- Amp::run (bufs, nframes, 0.0, 1.0, _phase_invert);
+ Amp::run (bufs, nframes, 0.0, 1.0, false);
_pending_declick = 0;
} else if (declick < 0) {
- Amp::run (bufs, nframes, 1.0, 0.0, _phase_invert);
+ Amp::run (bufs, nframes, 1.0, 0.0, false);
_pending_declick = 0;
} else {
/* no global declick */
if (solo_gain != dsg) {
- Amp::run (bufs, nframes, solo_gain, dsg, _phase_invert);
+ Amp::run (bufs, nframes, solo_gain, dsg, false);
solo_gain = dsg;
}
}
@@ -302,7 +302,7 @@ Route::process_output_buffers (BufferSet& bufs,
}
if (!_soloed && _mute_affects_pre_fader && (mute_gain != dmg)) {
- Amp::run (bufs, nframes, mute_gain, dmg, _phase_invert);
+ Amp::run (bufs, nframes, mute_gain, dmg, false);
mute_gain = dmg;
mute_declick_applied = true;
}
@@ -379,7 +379,7 @@ Route::process_output_buffers (BufferSet& bufs,
if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_post_fader) {
- Amp::run (bufs, nframes, mute_gain, dmg, _phase_invert);
+ Amp::run (bufs, nframes, mute_gain, dmg, false);
mute_gain = dmg;
mute_declick_applied = true;
}
@@ -543,7 +543,7 @@ Route::process_output_buffers (BufferSet& bufs,
}
if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_control_outs) {
- Amp::run (bufs, nframes, mute_gain, dmg, _phase_invert);
+ Amp::run (bufs, nframes, mute_gain, dmg, false);
mute_gain = dmg;
mute_declick_applied = true;
}
@@ -588,7 +588,7 @@ Route::process_output_buffers (BufferSet& bufs,
----------------------------------------------------------------------*/
if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_main_outs) {
- Amp::run (bufs, nframes, mute_gain, dmg, _phase_invert);
+ Amp::run (bufs, nframes, mute_gain, dmg, false);
mute_gain = dmg;
mute_declick_applied = true;
}
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index ebdbea1fc4..b670afb1ba 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -87,10 +87,11 @@ using boost::shared_ptr;
const char* Session::_template_suffix = X_(".template");
const char* Session::_statefile_suffix = X_(".ardour");
const char* Session::_pending_suffix = X_(".pending");
-const char* Session::sound_dir_name = X_("sounds");
-const char* Session::tape_dir_name = X_("tapes");
+const char* Session::old_sound_dir_name = X_("sounds");
+const char* Session::sound_dir_name = X_("audiofiles");
const char* Session::peak_dir_name = X_("peaks");
const char* Session::dead_sound_dir_name = X_("dead_sounds");
+const char* Session::interchange_dir_name = X_("interchange");
Session::compute_peak_t Session::compute_peak = 0;
Session::apply_gain_to_buffer_t Session::apply_gain_to_buffer = 0;
@@ -2836,17 +2837,11 @@ Session::source_by_id (const PBD::ID& id)
}
string
-Session::peak_path_from_audio_path (string audio_path)
+Session::peak_path_from_audio_path (string audio_path) const
{
- /* XXX hardly bombproof! fix me */
-
string res;
- res = Glib::path_get_dirname (audio_path);
- res = Glib::path_get_dirname (res);
- res += '/';
- res += peak_dir_name;
- res += '/';
+ res = peak_dir ();
res += PBD::basename_nosuffix (audio_path);
res += ".peak";
@@ -2992,11 +2987,7 @@ Session::audio_path_from_name (string name, uint32_t nchan, uint32_t chan, bool
spath = (*i).path;
- if (destructive) {
- spath += tape_dir_name;
- } else {
- spath += sound_dir_name;
- }
+ spath += sound_dir (false);
if (destructive) {
if (nchan < 2) {
@@ -3032,9 +3023,10 @@ Session::audio_path_from_name (string name, uint32_t nchan, uint32_t chan, bool
}
}
- if (access (buf, F_OK) == 0) {
+ if (g_file_test (buf, G_FILE_TEST_EXISTS)) {
existing++;
- }
+ }
+
}
if (existing == 0) {
@@ -3053,11 +3045,7 @@ Session::audio_path_from_name (string name, uint32_t nchan, uint32_t chan, bool
string foo = buf;
- if (destructive) {
- spath = tape_dir ();
- } else {
- spath = discover_best_sound_dir ();
- }
+ spath = discover_best_sound_dir ();
string::size_type pos = foo.find_last_of ('/');
@@ -3074,7 +3062,8 @@ boost::shared_ptr<AudioFileSource>
Session::create_audio_source_for_session (AudioDiskstream& ds, uint32_t chan, bool destructive)
{
string spath = audio_path_from_name (ds.name(), ds.n_channels().get(DataType::AUDIO), chan, destructive);
- return boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createWritable (DataType::AUDIO, spath, destructive, frame_rate()));
+ return boost::dynamic_pointer_cast<AudioFileSource> (
+ SourceFactory::createWritable (DataType::AUDIO, *this, spath, destructive, frame_rate()));
}
// FIXME: _terrible_ code duplication
@@ -3260,7 +3249,7 @@ Session::create_midi_source_for_session (MidiDiskstream& ds)
{
string spath = midi_path_from_name (ds.name());
- return boost::dynamic_pointer_cast<SMFSource> (SourceFactory::createWritable (DataType::MIDI, spath, false, frame_rate()));
+ return boost::dynamic_pointer_cast<SMFSource> (SourceFactory::createWritable (DataType::MIDI, *this, spath, false, frame_rate()));
}
@@ -3420,17 +3409,35 @@ Session::RoutePublicOrderSorter::operator() (boost::shared_ptr<Route> a, boost::
void
Session::remove_empty_sounds ()
{
-
PathScanner scanner;
- string dir;
-
- dir = sound_dir ();
- vector<string *>* possible_audiofiles = scanner (dir, "\\.wav$", false, true);
+ vector<string *>* possible_audiofiles = scanner (sound_dir(), "\\.(wav|aiff|caf|w64)$", false, true);
+ Glib::Mutex::Lock lm (source_lock);
+
+ regex_t compiled_tape_track_pattern;
+ int err;
+
+ if ((err = regcomp (&compiled_tape_track_pattern, "/T[0-9][0-9][0-9][0-9]-", REG_EXTENDED|REG_NOSUB))) {
+
+ char msg[256];
+
+ regerror (err, &compiled_tape_track_pattern, msg, sizeof (msg));
+
+ error << string_compose (_("Cannot compile tape track regexp for use (%1)"), msg) << endmsg;
+ return;
+ }
+
for (vector<string *>::iterator i = possible_audiofiles->begin(); i != possible_audiofiles->end(); ++i) {
+
+ /* never remove files that appear to be a tape track */
- if (AudioFileSource::is_empty (*(*i))) {
+ if (regexec (&compiled_tape_track_pattern, (*i)->c_str(), 0, 0, 0) == 0) {
+ delete *i;
+ continue;
+ }
+
+ if (AudioFileSource::is_empty (*this, *(*i))) {
unlink ((*i)->c_str());
@@ -3610,7 +3617,7 @@ jack_nframes_t
Session::available_capture_duration ()
{
const double scale = 4096.0 / sizeof (Sample);
-
+
if (_total_free_4k_blocks * scale > (double) max_frames) {
return max_frames;
}
@@ -3914,7 +3921,8 @@ Session::write_one_audio_track (AudioTrack& track, jack_nframes_t start, jack_nf
}
try {
- fsource = boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createWritable (DataType::AUDIO, buf, false, frame_rate()));
+ fsource = boost::dynamic_pointer_cast<AudioFileSource> (
+ SourceFactory::createWritable (DataType::AUDIO, *this, buf, false, frame_rate()));
}
catch (failed_constructor& err) {
@@ -3931,7 +3939,7 @@ Session::write_one_audio_track (AudioTrack& track, jack_nframes_t start, jack_nf
to_do = len;
/* create a set of reasonably-sized buffers */
- buffers.ensure_buffers(nchans, chunk_size);
+buffers.ensure_buffers(nchans, chunk_size);
buffers.set_count(nchans);
while (to_do && !itt.cancel) {
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index eaaa723a0c..a8b2804ff0 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -309,7 +309,6 @@ Session::second_stage_init (bool new_session)
if (!new_session) {
if (load_state (_current_snapshot_name)) {
- cerr << "load state failed\n";
return -1;
}
remove_empty_sounds ();
@@ -371,7 +370,6 @@ Session::second_stage_init (bool new_session)
_end_location_is_free = false;
}
- restore_history(_current_snapshot_name);
return 0;
}
@@ -436,16 +434,7 @@ Session::setup_raid_path (string path)
if (fspath[fspath.length()-1] != '/') {
fspath += '/';
}
- fspath += sound_dir_name;
- fspath += ':';
-
- /* tape dir */
-
- fspath += sp.path;
- if (fspath[fspath.length()-1] != '/') {
- fspath += '/';
- }
- fspath += tape_dir_name;
+ fspath += sound_dir (false);
AudioFileSource::set_search_path (fspath);
SMFSource::set_search_path (fspath); // FIXME: should be different
@@ -467,16 +456,7 @@ Session::setup_raid_path (string path)
if (fspath[fspath.length()-1] != '/') {
fspath += '/';
}
- fspath += sound_dir_name;
- fspath += ':';
-
- /* add tape dir to file search path */
-
- fspath += sp.path;
- if (fspath[fspath.length()-1] != '/') {
- fspath += '/';
- }
- fspath += tape_dir_name;
+ fspath += sound_dir (false);
fspath += ':';
remaining = remaining.substr (colon+1);
@@ -492,15 +472,9 @@ Session::setup_raid_path (string path)
if (fspath[fspath.length()-1] != '/') {
fspath += '/';
}
- fspath += sound_dir_name;
+ fspath += sound_dir (false);
fspath += ':';
- fspath += sp.path;
- if (fspath[fspath.length()-1] != '/') {
- fspath += '/';
- }
- fspath += tape_dir_name;
-
session_dirs.push_back (sp);
}
@@ -518,61 +492,40 @@ int
Session::create (bool& new_session, string* mix_template, jack_nframes_t initial_length)
{
string dir;
+
+ new_session = !g_file_test (_path.c_str(), GFileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR));
- if (mkdir (_path.c_str(), 0755) < 0) {
- if (errno == EEXIST) {
- new_session = false;
- } else {
- error << string_compose(_("Session: cannot create session dir \"%1\" (%2)"), _path, strerror (errno)) << endmsg;
- return -1;
- }
- } else {
- new_session = true;
+ if (g_mkdir_with_parents (_path.c_str(), 0755) < 0) {
+ error << string_compose(_("Session: cannot create session dir \"%1\" (%2)"), _path, strerror (errno)) << endmsg;
+ return -1;
}
dir = peak_dir ();
- if (mkdir (dir.c_str(), 0755) < 0) {
- if (errno != EEXIST) {
- error << string_compose(_("Session: cannot create session peakfile dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
- return -1;
- }
+ if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
+ error << string_compose(_("Session: cannot create session peakfile dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
+ return -1;
}
dir = sound_dir ();
- if (mkdir (dir.c_str(), 0755) < 0) {
- if (errno != EEXIST) {
- error << string_compose(_("Session: cannot create session sounds dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
- return -1;
- }
- }
-
- dir = tape_dir ();
-
- if (mkdir (dir.c_str(), 0755) < 0) {
- if (errno != EEXIST) {
- error << string_compose(_("Session: cannot create session tape dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
- return -1;
- }
+ if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
+ error << string_compose(_("Session: cannot create session sounds dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
+ return -1;
}
dir = dead_sound_dir ();
- if (mkdir (dir.c_str(), 0755) < 0) {
- if (errno != EEXIST) {
- error << string_compose(_("Session: cannot create session dead sounds dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
- return -1;
- }
+ if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
+ error << string_compose(_("Session: cannot create session dead sounds dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
+ return -1;
}
dir = automation_dir ();
- if (mkdir (dir.c_str(), 0755) < 0) {
- if (errno != EEXIST) {
- error << string_compose(_("Session: cannot create session automation dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
- return -1;
- }
+ if (g_mkdir_with_parents (dir.c_str(), 0755) < 0) {
+ error << string_compose(_("Session: cannot create session automation dir \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
+ return -1;
}
@@ -725,6 +678,8 @@ Session::save_state (string snapshot_name, bool pending)
}
+ cerr << "actually writing state\n";
+
if (!tree.write (xml_path)) {
error << string_compose (_("state could not be saved to %1"), xml_path) << endmsg;
@@ -2031,13 +1986,12 @@ Session::load_sources (const XMLNode& node)
boost::shared_ptr<Source>
Session::XMLSourceFactory (const XMLNode& node)
{
-
if (node.name() != "Source") {
return boost::shared_ptr<Source>();
}
try {
- return SourceFactory::create (node);
+ return SourceFactory::create (*this, node);
}
catch (failed_constructor& err) {
@@ -2062,7 +2016,7 @@ Session::save_template (string template_name)
if ((dp = opendir (dir.c_str()))) {
closedir (dp);
} else {
- if (mkdir (dir.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)<0) {
+ if (g_mkdir_with_parents (dir.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
error << string_compose(_("Could not create mix templates directory \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
return -1;
}
@@ -2142,11 +2096,9 @@ Session::ensure_sound_dir (string path, string& result)
/* Ensure that the parent directory exists */
- if (mkdir (path.c_str(), 0775)) {
- if (errno != EEXIST) {
- error << string_compose(_("cannot create session directory \"%1\"; ignored"), path) << endmsg;
- return -1;
- }
+ if (g_mkdir_with_parents (path.c_str(), 0775)) {
+ error << string_compose(_("cannot create session directory \"%1\"; ignored"), path) << endmsg;
+ return -1;
}
/* Ensure that the sounds directory exists */
@@ -2155,33 +2107,27 @@ Session::ensure_sound_dir (string path, string& result)
result += '/';
result += sound_dir_name;
- if (mkdir (result.c_str(), 0775)) {
- if (errno != EEXIST) {
- error << string_compose(_("cannot create sounds directory \"%1\"; ignored"), result) << endmsg;
- return -1;
- }
+ if (g_mkdir_with_parents (result.c_str(), 0775)) {
+ error << string_compose(_("cannot create sounds directory \"%1\"; ignored"), result) << endmsg;
+ return -1;
}
dead = path;
dead += '/';
dead += dead_sound_dir_name;
- if (mkdir (dead.c_str(), 0775)) {
- if (errno != EEXIST) {
- error << string_compose(_("cannot create dead sounds directory \"%1\"; ignored"), dead) << endmsg;
- return -1;
- }
+ if (g_mkdir_with_parents (dead.c_str(), 0775)) {
+ error << string_compose(_("cannot create dead sounds directory \"%1\"; ignored"), dead) << endmsg;
+ return -1;
}
peak = path;
peak += '/';
peak += peak_dir_name;
- if (mkdir (peak.c_str(), 0775)) {
- if (errno != EEXIST) {
- error << string_compose(_("cannot create peak file directory \"%1\"; ignored"), peak) << endmsg;
- return -1;
- }
+ if (g_mkdir_with_parents (peak.c_str(), 0775)) {
+ error << string_compose(_("cannot create peak file directory \"%1\"; ignored"), peak) << endmsg;
+ return -1;
}
/* callers expect this to be terminated ... */
@@ -2196,12 +2142,6 @@ Session::discover_best_sound_dir (bool destructive)
vector<space_and_path>::iterator i;
string result;
- /* destructive files all go into the same place */
-
- if (destructive) {
- return tape_dir();
- }
-
/* handle common case without system calls */
if (session_dirs.size() == 1) {
@@ -2418,20 +2358,37 @@ Session::dead_sound_dir () const
}
string
-Session::sound_dir () const
+Session::sound_dir (bool with_path) const
{
- string res = _path;
+ /* support old session structure */
+
+ struct stat statbuf;
+ string old;
+
+ if (with_path) {
+ old = _path;
+ }
+
+ old += sound_dir_name;
+ old += '/';
+
+ if (stat (old.c_str(), &statbuf) == 0) {
+ return old;
+ }
+
+ string res;
+
+ if (with_path) {
+ res = _path;
+ }
+
+ res += interchange_dir_name;
+ res += '/';
+ res += legalize_for_path (_name);
+ res += '/';
res += sound_dir_name;
res += '/';
- return res;
-}
-string
-Session::tape_dir () const
-{
- string res = _path;
- res += tape_dir_name;
- res += '/';
return res;
}
@@ -3427,8 +3384,7 @@ Session::save_history (string snapshot_name)
XMLTree tree;
string xml_path;
string bak_path;
-
-
+
tree.set_root (&history.get_state());
if (snapshot_name.empty()) {
@@ -3436,7 +3392,6 @@ Session::save_history (string snapshot_name)
}
xml_path = _path + snapshot_name + ".history";
- cerr << "Saving history to " << xml_path << endmsg;
bak_path = xml_path + ".bak";
@@ -3447,6 +3402,8 @@ Session::save_history (string snapshot_name)
return -1;
}
+ cerr << "actually writing history\n";
+
if (!tree.write (xml_path))
{
error << string_compose (_("history could not be saved to %1"), xml_path) << endmsg;
diff --git a/libs/ardour/session_time.cc b/libs/ardour/session_time.cc
index c74d3021cb..887a9fa6c4 100644
--- a/libs/ardour/session_time.cc
+++ b/libs/ardour/session_time.cc
@@ -51,7 +51,7 @@ Session::bbt_time (jack_nframes_t when, BBT_Time& bbt)
void
Session::sync_time_vars ()
{
- _current_frame_rate = _base_frame_rate * (1.0 + (video_pullup/100.0) );
+ _current_frame_rate = (jack_nframes_t) round (_base_frame_rate * (1.0 + (video_pullup/100.0)));
_frames_per_hour = _current_frame_rate * 3600;
_frames_per_smpte_frame = (double) _current_frame_rate / (double) smpte_frames_per_second;
_smpte_frames_per_hour = (unsigned long) (smpte_frames_per_second * 3600.0);
@@ -432,9 +432,11 @@ Session::jack_timebase_callback (jack_transport_state_t state,
pos->valid = jack_position_bits_t (pos->valid | JackPositionBBT);
}
+#ifdef HAVE_JACK_VIDEO_SUPPORT
//poke audio video ratio so Ardour can track Video Sync
pos->audio_frames_per_video_frame = frame_rate() / smpte_frames_per_second;
pos->valid = jack_position_bits_t (pos->valid | JackAudioVideoRatio);
+#endif
#if 0
/* SMPTE info */
diff --git a/libs/ardour/session_timefx.cc b/libs/ardour/session_timefx.cc
index 4ba8d42d9e..b5b143514c 100644
--- a/libs/ardour/session_timefx.cc
+++ b/libs/ardour/session_timefx.cc
@@ -82,8 +82,7 @@ Session::tempoize_region (TimeStretchRequest& tsr)
}
try {
- sources.push_back (boost::dynamic_pointer_cast<AudioFileSource> (
- SourceFactory::createWritable (DataType::AUDIO, path, false, frame_rate())));
+ sources.push_back (boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createWritable (DataType::AUDIO, *this, path, false, frame_rate())));
} catch (failed_constructor& err) {
error << string_compose (_("tempoize: error creating new audio file %1 (%2)"), path, strerror (errno)) << endmsg;
diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc
index e1845a009f..0e3064503a 100644
--- a/libs/ardour/smf_source.cc
+++ b/libs/ardour/smf_source.cc
@@ -48,8 +48,8 @@ bool SMFSource::header_position_negative;
uint64_t SMFSource::header_position_offset;
*/
-SMFSource::SMFSource (std::string path, Flag flags)
- : MidiSource (region_name_from_path(path))
+SMFSource::SMFSource (Session& s, std::string path, Flag flags)
+ : MidiSource (s, region_name_from_path(path))
, _channel(0)
, _flags (Flag(flags | Writable)) // FIXME: this needs to be writable for now
, _allow_remove_if_empty(true)
@@ -72,8 +72,8 @@ SMFSource::SMFSource (std::string path, Flag flags)
assert(_name.find("/") == string::npos);
}
-SMFSource::SMFSource (const XMLNode& node)
- : MidiSource (node)
+SMFSource::SMFSource (Session& s, const XMLNode& node)
+ : MidiSource (s, node)
, _channel(0)
, _flags (Flag (Writable|CanRename))
, _allow_remove_if_empty(true)
diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc
index b6ded6d617..0e80dee714 100644
--- a/libs/ardour/sndfilesource.cc
+++ b/libs/ardour/sndfilesource.cc
@@ -34,8 +34,8 @@ using namespace std;
using namespace ARDOUR;
using namespace PBD;
-SndFileSource::SndFileSource (const XMLNode& node)
- : AudioFileSource (node)
+SndFileSource::SndFileSource (Session& s, const XMLNode& node)
+ : AudioFileSource (s, node)
{
init (_name);
@@ -52,9 +52,9 @@ SndFileSource::SndFileSource (const XMLNode& node)
}
}
-SndFileSource::SndFileSource (string idstr, Flag flags)
+SndFileSource::SndFileSource (Session& s, string idstr, Flag flags)
/* files created this way are never writable or removable */
- : AudioFileSource (idstr, Flag (flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy)))
+ : AudioFileSource (s, idstr, Flag (flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy)))
{
init (idstr);
@@ -71,8 +71,8 @@ SndFileSource::SndFileSource (string idstr, Flag flags)
}
}
-SndFileSource::SndFileSource (string idstr, SampleFormat sfmt, HeaderFormat hf, jack_nframes_t rate, Flag flags)
- : AudioFileSource(idstr, flags, sfmt, hf)
+SndFileSource::SndFileSource (Session& s, string idstr, SampleFormat sfmt, HeaderFormat hf, jack_nframes_t rate, Flag flags)
+ : AudioFileSource (s, idstr, flags, sfmt, hf)
{
int fmt = 0;
@@ -226,7 +226,6 @@ SndFileSource::open ()
_length = _info.frames;
-
_broadcast_info = new SF_BROADCAST_INFO;
memset (_broadcast_info, 0, sizeof (*_broadcast_info));
@@ -507,6 +506,9 @@ SndFileSource::set_header_timeline_position ()
delete _broadcast_info;
_broadcast_info = 0;
}
+
+
+
}
jack_nframes_t
diff --git a/libs/ardour/source.cc b/libs/ardour/source.cc
index d218e2cf94..977aea6efd 100644
--- a/libs/ardour/source.cc
+++ b/libs/ardour/source.cc
@@ -42,11 +42,9 @@ using std::max;
using namespace ARDOUR;
-sigc::signal<void,Source*> Source::SourceCreated;
-
-
-Source::Source (string name, DataType type)
- : _type(type)
+Source::Source (Session& s, string name, DataType type)
+ : _session (s)
+ , _type(type)
{
assert(_name.find("/") == string::npos);
@@ -55,8 +53,9 @@ Source::Source (string name, DataType type)
_length = 0;
}
-Source::Source (const XMLNode& node)
- : _type(DataType::AUDIO)
+Source::Source (Session& s, const XMLNode& node)
+ : _session (s)
+ , _type(DataType::AUDIO)
{
_timestamp = 0;
_length = 0;
diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc
index 61a7659a5e..29cd5166ff 100644
--- a/libs/ardour/source_factory.cc
+++ b/libs/ardour/source_factory.cc
@@ -37,7 +37,7 @@ sigc::signal<void,boost::shared_ptr<Source> > SourceFactory::SourceCreated;
#ifdef HAVE_COREAUDIO
boost::shared_ptr<Source>
-SourceFactory::create (const XMLNode& node)
+SourceFactory::create (Session& s, const XMLNode& node)
{
DataType type = DataType::AUDIO;
const XMLProperty* prop = node.property("type");
@@ -49,11 +49,18 @@ SourceFactory::create (const XMLNode& node)
if (node.property (X_("destructive")) != 0) {
- boost::shared_ptr<Source> ret (new DestructiveFileSource (node));
+ boost::shared_ptr<Source> ret (new DestructiveFileSource (s, node));
SourceCreated (ret);
return ret;
} else {
+
+ try {
+ boost::shared_ptr<Source> ret (new CoreAudioSource (s, node));
+ SourceCreated (ret);
+ return ret;
+
+ } catch (failed_constructor& err) {
try {
boost::shared_ptr<Source> ret (new CoreAudioSource (node));
@@ -83,7 +90,7 @@ SourceFactory::create (const XMLNode& node)
#else
boost::shared_ptr<Source>
-SourceFactory::create (const XMLNode& node)
+SourceFactory::create (Session& s, const XMLNode& node)
{
DataType type = DataType::AUDIO;
const XMLProperty* prop = node.property("type");
@@ -95,20 +102,20 @@ SourceFactory::create (const XMLNode& node)
if (node.property (X_("destructive")) != 0) {
- boost::shared_ptr<Source> ret (new DestructiveFileSource (node));
+ boost::shared_ptr<Source> ret (new DestructiveFileSource (s, node));
SourceCreated (ret);
return ret;
} else {
- boost::shared_ptr<Source> ret (new SndFileSource (node));
+ boost::shared_ptr<Source> ret (new SndFileSource (s, node));
SourceCreated (ret);
return ret;
}
} else if (type == DataType::MIDI) {
-
- boost::shared_ptr<Source> ret (new SMFSource (node));
+
+ boost::shared_ptr<Source> ret (new SMFSource (s, node));
SourceCreated (ret);
return ret;
@@ -121,35 +128,34 @@ SourceFactory::create (const XMLNode& node)
#ifdef HAVE_COREAUDIO
boost::shared_ptr<Source>
-SourceFactory::createReadable (string idstr, AudioFileSource::Flag flags, bool announce)
+SourceFactory::createReadable (DataType type, Session& s, string idstr, AudioFileSource::Flag flags, bool announce)
{
if (type == DataType::AUDIO) {
if (flags & Destructive) {
- boost::shared_ptr<Source> ret (new DestructiveFileSource (idstr, flags));
+ boost::shared_ptr<Source> ret (new DestructiveFileSource (s, idstr, flags));
if (announce) {
SourceCreated (ret);
}
return ret;
- }
-
- try {
- boost::shared_ptr<Source> ret (new CoreAudioSource (idstr, flags));
- if (announce) {
- SourceCreated (ret);
+
+ try {
+ boost::shared_ptr<Source> ret (new CoreAudioSource (s, idstr, flags));
+ if (announce) {
+ SourceCreated (ret);
+ }
+ return ret;
+
+ } catch (failed_constructor& err) {
+ boost::shared_ptr<Source> ret (new SndFileSource (s, idstr, flags));
+ if (announce) {
+ SourceCreated (ret);
+ }
+ return ret;
}
- return ret;
- }
- catch (failed_constructor& err) {
- boost::shared_ptr<Source> ret (new SndFileSource (idstr, flags));
- if (announce) {
- SourceCreated (ret);
- }
- return ret;
- }
} else if (type == DataType::MIDI) {
- boost::shared_ptr<Source> ret (new SMFSource (node));
+ boost::shared_ptr<Source> ret (new SMFSource (s, node));
SourceCreated (ret);
return ret;
@@ -161,10 +167,11 @@ SourceFactory::createReadable (string idstr, AudioFileSource::Flag flags, bool a
#else
boost::shared_ptr<Source>
-SourceFactory::createReadable (DataType type, string idstr, AudioFileSource::Flag flags, bool announce)
+SourceFactory::createReadable (DataType type, Session& s, string idstr, AudioFileSource::Flag flags, bool announce)
{
if (type == DataType::AUDIO) {
- boost::shared_ptr<Source> ret (new SndFileSource (idstr, flags));
+
+ boost::shared_ptr<Source> ret (new SndFileSource (s, idstr, flags));
if (announce) {
SourceCreated (ret);
}
@@ -172,8 +179,10 @@ SourceFactory::createReadable (DataType type, string idstr, AudioFileSource::Fla
} else if (type == DataType::MIDI) {
- boost::shared_ptr<Source> ret (new SMFSource (idstr, SMFSource::Flag(0))); // FIXME: flags?
- SourceCreated (ret);
+ boost::shared_ptr<Source> ret (new SMFSource (s, idstr, SMFSource::Flag(0))); // FIXME: flags?
+ if (announce) {
+ SourceCreated (ret);
+ }
return ret;
}
@@ -184,13 +193,14 @@ SourceFactory::createReadable (DataType type, string idstr, AudioFileSource::Fla
#endif // HAVE_COREAUDIO
boost::shared_ptr<Source>
-SourceFactory::createWritable (DataType type, std::string path, bool destructive, jack_nframes_t rate, bool announce)
+SourceFactory::createWritable (DataType type, Session& s, std::string path, bool destructive, jack_nframes_t rate, bool announce)
{
/* this might throw failed_constructor(), which is OK */
if (type == DataType::AUDIO) {
if (destructive) {
- boost::shared_ptr<Source> ret (new DestructiveFileSource (path,
+
+ boost::shared_ptr<Source> ret (new DestructiveFileSource (s, path,
Config->get_native_file_data_format(),
Config->get_native_file_header_format(),
rate));
@@ -200,7 +210,8 @@ SourceFactory::createWritable (DataType type, std::string path, bool destructive
return ret;
} else {
- boost::shared_ptr<Source> ret (new SndFileSource (path,
+
+ boost::shared_ptr<Source> ret (new SndFileSource (s, path,
Config->get_native_file_data_format(),
Config->get_native_file_header_format(),
rate));
@@ -208,13 +219,15 @@ SourceFactory::createWritable (DataType type, std::string path, bool destructive
SourceCreated (ret);
}
return ret;
+
}
+
} else if (type == DataType::MIDI) {
- boost::shared_ptr<Source> ret (new SMFSource (path));
+ boost::shared_ptr<Source> ret (new SMFSource (s, path));
SourceCreated (ret);
return ret;
-
+
}
return boost::shared_ptr<Source> ();
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index 02884f062b..c2ff4f9a3a 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -919,6 +919,33 @@ jack_nframes_t
TempoMap::round_to_beat_subdivision (jack_nframes_t fr, int sub_num)
{
+
+ BBT_Time the_beat;
+ uint32_t ticks_one_half_subdivisions_worth;
+ uint32_t ticks_one_subdivisions_worth;
+
+ bbt_time(fr, the_beat);
+
+ ticks_one_subdivisions_worth = (uint32_t)Meter::ticks_per_beat / sub_num;
+ ticks_one_half_subdivisions_worth = ticks_one_subdivisions_worth / 2;
+
+ if (the_beat.ticks % ticks_one_subdivisions_worth > ticks_one_half_subdivisions_worth) {
+ uint32_t difference = ticks_one_subdivisions_worth - (the_beat.ticks % ticks_one_subdivisions_worth);
+ if (the_beat.ticks + difference >= (uint32_t)Meter::ticks_per_beat) {
+ the_beat.beats++;
+ the_beat.ticks += difference;
+ the_beat.ticks -= (uint32_t)Meter::ticks_per_beat;
+ } else {
+ the_beat.ticks += difference;
+ }
+ } else {
+ the_beat.ticks -= the_beat.ticks % ticks_one_subdivisions_worth;
+ }
+
+ return frame_time (the_beat);
+
+ /* XXX just keeping this for reference
+
TempoMap::BBTPointList::iterator i;
TempoMap::BBTPointList *more_zoomed_bbt_points;
jack_nframes_t frame_one_beats_worth;
@@ -970,6 +997,9 @@ TempoMap::round_to_beat_subdivision (jack_nframes_t fr, int sub_num)
delete more_zoomed_bbt_points;
return fr ;
+
+ */
+
}
jack_nframes_t
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc
index 8d9d799a44..ce4f4accd3 100644
--- a/libs/ardour/utils.cc
+++ b/libs/ardour/utils.cc
@@ -287,7 +287,7 @@ compute_equal_power_fades (jack_nframes_t nframes, float* in, float* out)
in[0] = 0.0f;
- for (int i = 1; i < nframes - 1; ++i) {
+ for (jack_nframes_t i = 1; i < nframes - 1; ++i) {
in[i] = in[i-1] + step;
}
diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc
index dbb7547052..5dd32f2d51 100644
--- a/libs/ardour/vst_plugin.cc
+++ b/libs/ardour/vst_plugin.cc
@@ -174,9 +174,9 @@ VSTPlugin::get_state()
if (stat (path.c_str(), &sbuf)) {
if (errno == ENOENT) {
- if (mkdir (path.c_str(), 0600)) {
+ if (g_mkdir_with_parents (path.c_str(), 0600)) {
error << string_compose (_("cannot create VST chunk directory: %1"),
- strerror (errno))
+ strerror (errno))
<< endmsg;
return *root;
}