summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-08-29 21:21:48 +0000
committerDavid Robillard <d@drobilla.net>2006-08-29 21:21:48 +0000
commit82232f06ba3eea4a2b4342ad91fab552f4044402 (patch)
treed517cb47c017f51e2ecd9450624b86eb70d9f97b /libs/ardour/ardour
parent25d1670a61d19e795227b939a98be9cf5a050c67 (diff)
Merged with trunk R861
Possible new bugs - not very thoroughly tested, but at least functional at first glance git-svn-id: svn://localhost/ardour2/branches/midi@870 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r--libs/ardour/ardour/audio_diskstream.h14
-rw-r--r--libs/ardour/ardour/audiofilesource.h10
-rw-r--r--libs/ardour/ardour/audiofilter.h8
-rw-r--r--libs/ardour/ardour/audioplaylist.h14
-rw-r--r--libs/ardour/ardour/audioregion.h20
-rw-r--r--libs/ardour/ardour/audiosource.h4
-rw-r--r--libs/ardour/ardour/auditioner.h4
-rw-r--r--libs/ardour/ardour/automation_event.h5
-rw-r--r--libs/ardour/ardour/crossfade.h29
-rw-r--r--libs/ardour/ardour/diskstream.h10
-rw-r--r--libs/ardour/ardour/io.h6
-rw-r--r--libs/ardour/ardour/location.h6
-rw-r--r--libs/ardour/ardour/midi_diskstream.h4
-rw-r--r--libs/ardour/ardour/midi_playlist.h17
-rw-r--r--libs/ardour/ardour/midi_region.h20
-rw-r--r--libs/ardour/ardour/playlist.h75
-rw-r--r--libs/ardour/ardour/playlist_templates.h4
-rw-r--r--libs/ardour/ardour/plugin.h6
-rw-r--r--libs/ardour/ardour/redirect.h1
-rw-r--r--libs/ardour/ardour/region.h59
-rw-r--r--libs/ardour/ardour/region_factory.h30
-rw-r--r--libs/ardour/ardour/reverse.h2
-rw-r--r--libs/ardour/ardour/route.h2
-rw-r--r--libs/ardour/ardour/session.h134
-rw-r--r--libs/ardour/ardour/session_region.h4
-rw-r--r--libs/ardour/ardour/source.h20
-rw-r--r--libs/ardour/ardour/source_factory.h28
-rw-r--r--libs/ardour/ardour/tempo.h6
-rw-r--r--libs/ardour/ardour/types.h4
29 files changed, 294 insertions, 252 deletions
diff --git a/libs/ardour/ardour/audio_diskstream.h b/libs/ardour/ardour/audio_diskstream.h
index 18f8328cfd..8588c9660d 100644
--- a/libs/ardour/ardour/audio_diskstream.h
+++ b/libs/ardour/ardour/audio_diskstream.h
@@ -108,10 +108,10 @@ class AudioDiskstream : public Diskstream
return 0;
}
- AudioFileSource *write_source (uint32_t n=0) {
+ boost::shared_ptr<AudioFileSource> write_source (uint32_t n=0) {
if (n < channels.size())
return channels[n].write_source;
- return 0;
+ return boost::shared_ptr<AudioFileSource>();
}
int add_channel ();
@@ -141,8 +141,6 @@ class AudioDiskstream : public Diskstream
}
}
- std::list<Region*>& last_capture_regions () { return _last_capture_regions; }
-
XMLNode* deprecated_io_node;
protected:
@@ -181,9 +179,9 @@ class AudioDiskstream : public Diskstream
Sample *speed_buffer;
float peak_power;
-
- AudioFileSource *fades_source;
- AudioFileSource *write_source;
+
+ boost::shared_ptr<AudioFileSource> fades_source;
+ boost::shared_ptr<AudioFileSource> write_source;
Port *source;
Sample *current_capture_buffer;
@@ -251,7 +249,7 @@ class AudioDiskstream : public Diskstream
int _do_refill (Sample *mixdown_buffer, float *gain_buffer);
- std::vector<AudioFileSource*> capturing_sources;
+ std::vector<boost::shared_ptr<AudioFileSource> > capturing_sources;
typedef vector<ChannelInfo> ChannelList;
ChannelList channels;
diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h
index 3e0d4c45ae..b1ffab0944 100644
--- a/libs/ardour/ardour/audiofilesource.h
+++ b/libs/ardour/ardour/audiofilesource.h
@@ -56,16 +56,6 @@ class AudioFileSource : public AudioSource {
static void set_peak_dir (string dir) { peak_dir = dir; }
- /* factory for an existing but not-used-in-session audio file. this exists
- because there maybe multiple back-end derivations of AudioFileSource,
- some of which can handle formats that cannot be handled by others.
- For example, CoreAudioFileSource can handle MP3 files, which SndFileSource
- cannot.
- */
-
- static AudioFileSource* create (const string& path_plus_channel, Flag flags = Flag (0));
- static AudioFileSource* create (const XMLNode&);
-
static bool get_soundfile_info (string path, SoundFileInfo& _info, string& error);
void set_allow_remove_if_empty (bool yn);
diff --git a/libs/ardour/ardour/audiofilter.h b/libs/ardour/ardour/audiofilter.h
index 02e5e6f061..c8762dbf69 100644
--- a/libs/ardour/ardour/audiofilter.h
+++ b/libs/ardour/ardour/audiofilter.h
@@ -36,14 +36,14 @@ class AudioFilter {
: session (s){}
virtual ~AudioFilter() {}
- virtual int run (ARDOUR::AudioRegion&) = 0;
- std::vector<ARDOUR::AudioRegion*> results;
+ virtual int run (boost::shared_ptr<ARDOUR::AudioRegion>) = 0;
+ std::vector<boost::shared_ptr<ARDOUR::AudioRegion> > results;
protected:
ARDOUR::Session& session;
- int make_new_sources (ARDOUR::AudioRegion&, ARDOUR::AudioRegion::SourceList&);
- int finish (ARDOUR::AudioRegion&, ARDOUR::AudioRegion::SourceList&);
+ int make_new_sources (boost::shared_ptr<ARDOUR::AudioRegion>, ARDOUR::SourceList&);
+ int finish (boost::shared_ptr<ARDOUR::AudioRegion>, ARDOUR::SourceList&);
};
} /* namespace */
diff --git a/libs/ardour/ardour/audioplaylist.h b/libs/ardour/ardour/audioplaylist.h
index bd76c30289..0426208ba1 100644
--- a/libs/ardour/ardour/audioplaylist.h
+++ b/libs/ardour/ardour/audioplaylist.h
@@ -58,7 +58,7 @@ class AudioPlaylist : public ARDOUR::Playlist
AudioPlaylist (const AudioPlaylist&, string name, bool hidden = false);
AudioPlaylist (const AudioPlaylist&, jack_nframes_t start, jack_nframes_t cnt, string name, bool hidden = false);
- void clear (bool with_delete = false, bool with_save = true);
+ void clear (bool with_save = true);
jack_nframes_t read (Sample *dst, Sample *mixdown, float *gain_buffer, jack_nframes_t start, jack_nframes_t cnt, uint32_t chan_n=0);
@@ -75,7 +75,7 @@ class AudioPlaylist : public ARDOUR::Playlist
(obj.*method) (states, _current_state_id);
}
- bool destroy_region (Region*);
+ bool destroy_region (boost::shared_ptr<Region>);
void drop_all_states ();
@@ -91,11 +91,11 @@ class AudioPlaylist : public ARDOUR::Playlist
void notify_crossfade_added (Crossfade *);
void flush_notifications ();
- void finalize_split_region (Region *orig, Region *left, Region *right);
+ void finalize_split_region (boost::shared_ptr<Region> orig, boost::shared_ptr<Region> left, boost::shared_ptr<Region> right);
- void refresh_dependents (Region& region);
- void check_dependents (Region& region, bool norefresh);
- void remove_dependents (Region& region);
+ void refresh_dependents (boost::shared_ptr<Region> region);
+ void check_dependents (boost::shared_ptr<Region> region, bool norefresh);
+ void remove_dependents (boost::shared_ptr<Region> region);
protected:
~AudioPlaylist (); /* public should use unref() */
@@ -108,7 +108,7 @@ class AudioPlaylist : public ARDOUR::Playlist
XMLNode& state (bool full_state);
void dump () const;
- bool region_changed (Change, Region*);
+ bool region_changed (Change, boost::shared_ptr<Region>);
void crossfade_changed (Change);
void add_crossfade (Crossfade&);
};
diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h
index fd2cc8d2f1..9b97a88bc0 100644
--- a/libs/ardour/ardour/audioregion.h
+++ b/libs/ardour/ardour/audioregion.h
@@ -65,18 +65,11 @@ class AudioRegion : public Region
static Change ScaleAmplitudeChanged;
static Change EnvelopeChanged;
- AudioRegion (AudioSource&, jack_nframes_t start, jack_nframes_t length, bool announce = true);
- AudioRegion (AudioSource&, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
- AudioRegion (SourceList &, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
- AudioRegion (const AudioRegion&, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
- AudioRegion (const AudioRegion&);
- AudioRegion (AudioSource&, const XMLNode&);
- AudioRegion (SourceList &, const XMLNode&);
~AudioRegion();
bool speed_mismatch (float) const;
- AudioSource& audio_source (uint32_t n=0) const;
+ boost::shared_ptr<AudioSource> audio_source (uint32_t n=0) const;
void set_scale_amplitude (gain_t);
gain_t scale_amplitude() const { return _scale_amplitude; }
@@ -149,7 +142,15 @@ class AudioRegion : public Region
void resume_fade_out ();
private:
- friend class Playlist;
+ friend class RegionFactory;
+
+ AudioRegion (boost::shared_ptr<AudioSource>, jack_nframes_t start, jack_nframes_t length);
+ AudioRegion (boost::shared_ptr<AudioSource>, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
+ AudioRegion (SourceList &, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
+ AudioRegion (boost::shared_ptr<const AudioRegion>, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
+ AudioRegion (boost::shared_ptr<const AudioRegion>);
+ AudioRegion (boost::shared_ptr<AudioSource>, const XMLNode&);
+ AudioRegion (SourceList &, const XMLNode&);
private:
void set_default_fades ();
@@ -174,7 +175,6 @@ class AudioRegion : public Region
void envelope_changed (Change);
-
mutable Curve _fade_in;
FadeShape _fade_in_shape;
mutable Curve _fade_out;
diff --git a/libs/ardour/ardour/audiosource.h b/libs/ardour/ardour/audiosource.h
index c3c2f9bb9a..751213ee8e 100644
--- a/libs/ardour/ardour/audiosource.h
+++ b/libs/ardour/ardour/audiosource.h
@@ -70,7 +70,7 @@ class AudioSource : public Source
int read_peaks (PeakData *peaks, jack_nframes_t npeaks, jack_nframes_t start, jack_nframes_t cnt, double samples_per_unit) const;
int build_peaks ();
bool peaks_ready (sigc::slot<void>, sigc::connection&) const;
-
+
mutable sigc::signal<void> PeaksReady;
mutable sigc::signal<void,jack_nframes_t,jack_nframes_t> PeakRangeReady;
@@ -129,7 +129,7 @@ class AudioSource : public Source
static vector<AudioSource*> pending_peak_sources;
static Glib::Mutex* pending_peak_sources_lock;
- static void queue_for_peaks (AudioSource&);
+ static void queue_for_peaks (AudioSource*);
static void clear_queue_for_peaks ();
struct PeakBuildRecord {
diff --git a/libs/ardour/ardour/auditioner.h b/libs/ardour/ardour/auditioner.h
index 434ec32f97..424ede0009 100644
--- a/libs/ardour/ardour/auditioner.h
+++ b/libs/ardour/ardour/auditioner.h
@@ -40,7 +40,7 @@ class Auditioner : public AudioTrack
Auditioner (Session&);
~Auditioner ();
- void audition_region (AudioRegion&);
+ void audition_region (boost::shared_ptr<Region>);
ARDOUR::AudioPlaylist& prepare_playlist ();
void audition_current_playlist ();
@@ -54,7 +54,7 @@ class Auditioner : public AudioTrack
bool active() const { return g_atomic_int_get (&_active); }
private:
- AudioRegion *the_region;
+ boost::shared_ptr<AudioRegion> the_region;
jack_nframes_t current_frame;
mutable gint _active;
Glib::Mutex lock;
diff --git a/libs/ardour/ardour/automation_event.h b/libs/ardour/ardour/automation_event.h
index dad94161d0..a3b84289c1 100644
--- a/libs/ardour/ardour/automation_event.h
+++ b/libs/ardour/ardour/automation_event.h
@@ -27,8 +27,11 @@
#include <sigc++/signal.h>
#include <glibmm/thread.h>
+
#include <pbd/undo.h>
#include <pbd/xml++.h>
+#include <pbd/statefuldestructible.h>
+
#include <ardour/ardour.h>
#include <ardour/state_manager.h>
@@ -51,7 +54,7 @@ struct ControlEvent {
};
-class AutomationList : public StateManager, public Stateful
+ class AutomationList : public StateManager, public PBD::StatefulDestructible
{
public:
typedef std::list<ControlEvent*> AutomationEventList;
diff --git a/libs/ardour/ardour/crossfade.h b/libs/ardour/ardour/crossfade.h
index aea7b31852..ded41bbfda 100644
--- a/libs/ardour/ardour/crossfade.h
+++ b/libs/ardour/ardour/crossfade.h
@@ -23,10 +23,12 @@
#include <vector>
#include <algorithm>
+#include <boost/shared_ptr.hpp>
#include <sigc++/signal.h>
#include <pbd/undo.h>
+#include <pbd/statefuldestructible.h>
#include <ardour/ardour.h>
#include <ardour/curve.h>
@@ -51,7 +53,7 @@ struct CrossfadeState : public StateManager::State {
bool active;
};
-class Crossfade : public Stateful, public StateManager
+class Crossfade : public PBD::StatefulDestructible, public StateManager
{
public:
@@ -62,7 +64,7 @@ class Crossfade : public Stateful, public StateManager
/* constructor for "fixed" xfades at each end of an internal overlap */
- Crossfade (ARDOUR::AudioRegion& in, ARDOUR::AudioRegion& out,
+ Crossfade (boost::shared_ptr<ARDOUR::AudioRegion> in, boost::shared_ptr<ARDOUR::AudioRegion> out,
jack_nframes_t position,
jack_nframes_t initial_length,
AnchorPoint);
@@ -71,12 +73,12 @@ class Crossfade : public Stateful, public StateManager
except the "internal" case.
*/
- Crossfade (ARDOUR::AudioRegion& in, ARDOUR::AudioRegion& out, CrossfadeModel, bool active);
+ Crossfade (boost::shared_ptr<ARDOUR::AudioRegion> in, boost::shared_ptr<ARDOUR::AudioRegion> out, CrossfadeModel, bool active);
/* copy constructor to copy a crossfade with new regions. used (for example)
when a playlist copy is made */
- Crossfade (const Crossfade &, ARDOUR::AudioRegion *, ARDOUR::AudioRegion *);
+ Crossfade (const Crossfade &, boost::shared_ptr<ARDOUR::AudioRegion>, boost::shared_ptr<ARDOUR::AudioRegion>);
/* the usual XML constructor */
@@ -88,8 +90,8 @@ class Crossfade : public Stateful, public StateManager
XMLNode& get_state (void);
int set_state (const XMLNode&);
- ARDOUR::AudioRegion& in() const { return *_in; }
- ARDOUR::AudioRegion& out() const { return *_out; }
+ boost::shared_ptr<ARDOUR::AudioRegion> in() const { return _in; }
+ boost::shared_ptr<ARDOUR::AudioRegion> out() const { return _out; }
jack_nframes_t read_at (Sample *buf, Sample *mixdown_buffer,
float *gain_buffer, jack_nframes_t position, jack_nframes_t cnt,
@@ -107,12 +109,12 @@ class Crossfade : public Stateful, public StateManager
return std::min (_in->layer(), _out->layer());
}
- bool involves (ARDOUR::AudioRegion& region) const {
- return _in == &region || _out == &region;
+ bool involves (boost::shared_ptr<ARDOUR::AudioRegion> region) const {
+ return _in == region || _out == region;
}
- bool involves (ARDOUR::AudioRegion& a, ARDOUR::AudioRegion& b) const {
- return (_in == &a && _out == &b) || (_in == &b && _out == &a);
+ bool involves (boost::shared_ptr<ARDOUR::AudioRegion> a, boost::shared_ptr<ARDOUR::AudioRegion> b) const {
+ return (_in == a && _out == b) || (_in == b && _out == a);
}
jack_nframes_t length() const { return _length; }
@@ -120,7 +122,6 @@ class Crossfade : public Stateful, public StateManager
jack_nframes_t position() const { return _position; }
sigc::signal<void,Crossfade*> Invalidated;
- sigc::signal<void> GoingAway;
bool covers (jack_nframes_t frame) const {
return _position <= frame && frame < _position + _length;
@@ -155,8 +156,8 @@ class Crossfade : public Stateful, public StateManager
static jack_nframes_t _short_xfade_length;
- ARDOUR::AudioRegion* _in;
- ARDOUR::AudioRegion* _out;
+ boost::shared_ptr<ARDOUR::AudioRegion> _in;
+ boost::shared_ptr<ARDOUR::AudioRegion> _out;
bool _active;
bool _in_update;
OverlapType overlap_type;
@@ -172,7 +173,7 @@ class Crossfade : public Stateful, public StateManager
static Sample* crossfade_buffer_in;
void initialize (bool savestate=true);
- int compute (ARDOUR::AudioRegion&, ARDOUR::AudioRegion&, CrossfadeModel);
+ int compute (boost::shared_ptr<ARDOUR::AudioRegion>, boost::shared_ptr<ARDOUR::AudioRegion>, CrossfadeModel);
bool update (bool force);
StateManager::State* state_factory (std::string why) const;
diff --git a/libs/ardour/ardour/diskstream.h b/libs/ardour/ardour/diskstream.h
index 858ed1af6f..2bce6a424f 100644
--- a/libs/ardour/ardour/diskstream.h
+++ b/libs/ardour/ardour/diskstream.h
@@ -34,7 +34,7 @@
#include <pbd/fastlog.h>
#include <pbd/ringbufferNPT.h>
#include <pbd/stateful.h>
-#include <pbd/destructible.h>
+#include <pbd/statefuldestructible.h>
#include <ardour/ardour.h>
#include <ardour/configuration.h>
@@ -54,7 +54,7 @@ class Session;
class Playlist;
class IO;
- class Diskstream : public Stateful, public sigc::trackable, public PBD::Destructible
+ class Diskstream : public sigc::trackable, public PBD::StatefulDestructible
{
public:
enum Flag {
@@ -134,7 +134,7 @@ class IO;
int set_loop (Location *loc);
- std::list<Region*>& last_capture_regions () { return _last_capture_regions; }
+ std::list<boost::shared_ptr<Region> >& last_capture_regions () { return _last_capture_regions; }
void handle_input_change (IOChange, void *src);
@@ -147,7 +147,7 @@ class IO;
static sigc::signal<void> DiskOverrun;
static sigc::signal<void> DiskUnderrun;
- static sigc::signal<void,list<Source*>*> DeleteSources;
+ static sigc::signal<void,std::list<boost::shared_ptr<Source> >*> DeleteSources;
protected:
friend class Session;
@@ -224,7 +224,7 @@ class IO;
virtual bool realtime_set_speed (double, bool global_change);
- std::list<Region*> _last_capture_regions;
+ std::list<boost::shared_ptr<Region> > _last_capture_regions;
virtual int use_pending_capture_data (XMLNode& node) = 0;
virtual void get_input_sources () = 0;
diff --git a/libs/ardour/ardour/io.h b/libs/ardour/ardour/io.h
index 7b5e72742d..ec29c6f843 100644
--- a/libs/ardour/ardour/io.h
+++ b/libs/ardour/ardour/io.h
@@ -31,7 +31,7 @@
#include <pbd/fastlog.h>
#include <pbd/undo.h>
-#include <pbd/stateful.h>
+#include <pbd/statefuldestructible.h>
#include <pbd/controllable.h>
#include <ardour/ardour.h>
@@ -65,7 +65,7 @@ class BufferSet;
* An IO can contain ports of varying types, making routes/inserts/etc with
* varied combinations of types (eg MIDI and audio) possible.
*/
-class IO : public Stateful, public ARDOUR::StateManager
+class IO : public PBD::StatefulDestructible, public ARDOUR::StateManager
{
public:
@@ -76,7 +76,7 @@ class IO : public Stateful, public ARDOUR::StateManager
int output_min = -1, int output_max = -1,
DataType default_type = DataType::AUDIO);
- virtual ~IO();
+virtual ~IO();
ChanCount input_minimum() const { return _input_minimum; }
ChanCount input_maximum() const { return _input_maximum; }
diff --git a/libs/ardour/ardour/location.h b/libs/ardour/ardour/location.h
index beae4a6e07..1052b74bd4 100644
--- a/libs/ardour/ardour/location.h
+++ b/libs/ardour/ardour/location.h
@@ -33,6 +33,7 @@
#include <pbd/undo.h>
#include <pbd/stateful.h>
+#include <pbd/statefuldestructible.h>
#include <ardour/ardour.h>
#include <ardour/state_manager.h>
@@ -41,7 +42,7 @@ using std::string;
namespace ARDOUR {
-class Location : public Stateful, public sigc::trackable
+class Location : public sigc::trackable, public PBD::StatefulDestructible
{
public:
enum Flags {
@@ -72,6 +73,7 @@ class Location : public Stateful, public sigc::trackable
}
Location (const Location& other);
+ Location (const XMLNode&);
Location* operator= (const Location& other);
jack_nframes_t start() { return _start; }
@@ -132,7 +134,7 @@ class Location : public Stateful, public sigc::trackable
bool set_flag_internal (bool yn, Flags flag);
};
-class Locations : public Stateful, public StateManager
+class Locations : public StateManager, public PBD::StatefulDestructible
{
public:
typedef std::list<Location *> LocationList;
diff --git a/libs/ardour/ardour/midi_diskstream.h b/libs/ardour/ardour/midi_diskstream.h
index bf64cedd08..e62121672f 100644
--- a/libs/ardour/ardour/midi_diskstream.h
+++ b/libs/ardour/ardour/midi_diskstream.h
@@ -85,7 +85,7 @@ class MidiDiskstream : public Diskstream
void monitor_input (bool);
- MidiSource* write_source() { return (MidiSource*)_write_source; }
+ boost::shared_ptr<SMFSource> write_source () { return _write_source; }
void set_destructive (bool yn); // doom!
@@ -153,7 +153,7 @@ class MidiDiskstream : public Diskstream
//RawMidi* _playback_wrap_buffer;
//RawMidi* _capture_wrap_buffer;
MidiPort* _source_port;
- SMFSource* _write_source; ///< aka capturing source
+ boost::shared_ptr<SMFSource> _write_source;
RingBufferNPT<CaptureTransition>* _capture_transition_buf;
//RingBufferNPT<RawMidi>::rw_vector _playback_vector;
//RingBufferNPT<RawMidi>::rw_vector _capture_vector;
diff --git a/libs/ardour/ardour/midi_playlist.h b/libs/ardour/ardour/midi_playlist.h
index 11627b5a07..36793b70ea 100644
--- a/libs/ardour/ardour/midi_playlist.h
+++ b/libs/ardour/ardour/midi_playlist.h
@@ -69,10 +69,7 @@ public:
(obj.*method) (states, _current_state_id);
}
- bool destroy_region (Region*);
-
- void get_equivalent_regions (const MidiRegion&, std::vector<MidiRegion*>&);
- void get_region_list_equivalent_regions (const MidiRegion&, std::vector<MidiRegion*>&);
+ bool destroy_region (boost::shared_ptr<Region>);
void drop_all_states ();
@@ -87,11 +84,11 @@ protected:
/* playlist "callbacks" */
void flush_notifications ();
- void finalize_split_region (Region *orig, Region *left, Region *right);
-
- void refresh_dependents (Region& region);
- void check_dependents (Region& region, bool norefresh);
- void remove_dependents (Region& region);
+ void finalize_split_region (boost::shared_ptr<Region> original, boost::shared_ptr<Region> left, boost::shared_ptr<Region> right);
+
+ void check_dependents (boost::shared_ptr<Region> region, bool norefresh);
+ void refresh_dependents (boost::shared_ptr<Region> region);
+ void remove_dependents (boost::shared_ptr<Region> region);
protected:
~MidiPlaylist (); /* public should use unref() */
@@ -100,7 +97,7 @@ private:
XMLNode& state (bool full_state);
void dump () const;
- bool region_changed (Change, Region*);
+ bool region_changed (Change, boost::shared_ptr<Region>);
};
} /* namespace ARDOUR */
diff --git a/libs/ardour/ardour/midi_region.h b/libs/ardour/ardour/midi_region.h
index 745d3fa4a8..a5c578b7cd 100644
--- a/libs/ardour/ardour/midi_region.h
+++ b/libs/ardour/ardour/midi_region.h
@@ -46,16 +46,9 @@ class MidiRingBuffer;
class MidiRegion : public Region
{
public:
- MidiRegion (MidiSource&, jack_nframes_t start, jack_nframes_t length, bool announce = true);
- MidiRegion (MidiSource&, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
- MidiRegion (SourceList &, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
- MidiRegion (const MidiRegion&, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
- MidiRegion (const MidiRegion&);
- MidiRegion (MidiSource&, const XMLNode&);
- MidiRegion (SourceList &, const XMLNode&);
~MidiRegion();
- MidiSource& midi_source (uint32_t n=0) const;
+ boost::shared_ptr<MidiSource> midi_source (uint32_t n=0) const;
jack_nframes_t read_at (MidiRingBuffer& dst,
jack_nframes_t position,
@@ -77,6 +70,17 @@ class MidiRegion : public Region
UndoAction get_memento() const;
private:
+ friend class RegionFactory;
+
+ MidiRegion (boost::shared_ptr<MidiSource>, jack_nframes_t start, jack_nframes_t length);
+ MidiRegion (boost::shared_ptr<MidiSource>, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
+ MidiRegion (SourceList &, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
+ MidiRegion (boost::shared_ptr<const MidiRegion>, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
+ MidiRegion (boost::shared_ptr<const MidiRegion>);
+ MidiRegion (boost::shared_ptr<MidiSource>, const XMLNode&);
+ MidiRegion (SourceList &, const XMLNode&);
+
+ private:
friend class Playlist;
private:
diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h
index 59fd0f8bc5..c04b59286f 100644
--- a/libs/ardour/ardour/playlist.h
+++ b/libs/ardour/ardour/playlist.h
@@ -25,6 +25,7 @@
#include <set>
#include <map>
#include <list>
+#include <boost/shared_ptr.hpp>
#include <sys/stat.h>
@@ -34,6 +35,7 @@
#include <pbd/undo.h>
#include <pbd/stateful.h>
+#include <pbd/statefuldestructible.h>
#include <ardour/ardour.h>
#include <ardour/crossfade_compare.h>
@@ -46,16 +48,16 @@ namespace ARDOUR {
class Session;
class Region;
-class Playlist : public Stateful, public StateManager {
+class Playlist : public StateManager, public PBD::StatefulDestructible {
public:
- typedef list<Region*> RegionList;
+ typedef list<boost::shared_ptr<Region> > RegionList;
Playlist (Session&, const XMLNode&, DataType type, bool hidden = false);
Playlist (Session&, string name, DataType type, bool hidden = false);
Playlist (const Playlist&, string name, bool hidden = false);
Playlist (const Playlist&, jack_nframes_t start, jack_nframes_t cnt, string name, bool hidden = false);
- virtual void clear (bool with_delete = false, bool with_save = true);
+ virtual void clear (bool with_save = true);
virtual void dump () const;
virtual UndoAction get_memento() const = 0;
@@ -82,17 +84,17 @@ class Playlist : public Stateful, public StateManager {
PBD::ID id() { return _id; }
/* Editing operations */
- void add_region (const Region&, jack_nframes_t position, float times = 1, bool with_save = true);
- void remove_region (Region *);
- void get_equivalent_regions (const Region&, std::vector<Region*>&);
- void get_region_list_equivalent_regions (const Region&, std::vector<Region*>&);
- void replace_region (Region& old, Region& newr, jack_nframes_t pos);
- void split_region (Region&, jack_nframes_t position);
+ void add_region (boost::shared_ptr<Region>, jack_nframes_t position, float times = 1, bool with_save = true);
+ void remove_region (boost::shared_ptr<Region>);
+ void get_equivalent_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >&);
+ void get_region_list_equivalent_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >&);
+ void replace_region (boost::shared_ptr<Region> old, boost::shared_ptr<Region> newr, jack_nframes_t pos);
+ void split_region (boost::shared_ptr<Region>, jack_nframes_t position);
void partition (jack_nframes_t start, jack_nframes_t end, bool just_top_level);
- void duplicate (Region&, jack_nframes_t position, float times);
+ void duplicate (boost::shared_ptr<Region>, jack_nframes_t position, float times);
void nudge_after (jack_nframes_t start, jack_nframes_t distance, bool forwards);
- Region* find_region (const PBD::ID&) const;
+ boost::shared_ptr<Region> find_region (const PBD::ID&) const;
Playlist* cut (list<AudioRange>&, bool result_is_hidden = true);
Playlist* copy (list<AudioRange>&, bool result_is_hidden = true);
@@ -102,25 +104,24 @@ class Playlist : public Stateful, public StateManager {
RegionList* regions_at (jack_nframes_t frame);
RegionList* regions_touched (jack_nframes_t start, jack_nframes_t end);
- Region* top_region_at (jack_nframes_t frame);
+ boost::shared_ptr<Region> top_region_at (jack_nframes_t frame);
- Region* find_next_region (jack_nframes_t frame, RegionPoint point, int dir);
+ boost::shared_ptr<Region> find_next_region (jack_nframes_t frame, RegionPoint point, int dir);
- template<class T> void foreach_region (T *t, void (T::*func)(Region *, void *), void *arg);
- template<class T> void foreach_region (T *t, void (T::*func)(Region *));
+ template<class T> void foreach_region (T *t, void (T::*func)(boost::shared_ptr<Region>, void *), void *arg);
+ template<class T> void foreach_region (T *t, void (T::*func)(boost::shared_ptr<Region>));
XMLNode& get_state ();
int set_state (const XMLNode&);
XMLNode& get_template ();
- sigc::signal<void,Region *> RegionAdded;
- sigc::signal<void,Region *> RegionRemoved;
+ sigc::signal<void,boost::shared_ptr<Region> > RegionAdded;
+ sigc::signal<void,boost::shared_ptr<Region> > RegionRemoved;
sigc::signal<void,Playlist*,bool> InUse;
sigc::signal<void> Modified;
sigc::signal<void> NameChanged;
sigc::signal<void> LengthChanged;
sigc::signal<void> LayeringChanged;
- sigc::signal<void,Playlist *> GoingAway;
sigc::signal<void> StatePushed;
static sigc::signal<void,Playlist*> PlaylistCreated;
@@ -131,10 +132,10 @@ class Playlist : public Stateful, public StateManager {
void freeze ();
void thaw ();
- void raise_region (Region&);
- void lower_region (Region&);
- void raise_region_to_top (Region&);
- void lower_region_to_bottom (Region&);
+ void raise_region (boost::shared_ptr<Region>);
+ void lower_region (boost::shared_ptr<Region>);
+ void raise_region_to_top (boost::shared_ptr<Region>);
+ void lower_region_to_bottom (boost::shared_ptr<Region>);
uint32_t read_data_count() const { return _read_data_count; }
@@ -145,7 +146,7 @@ class Playlist : public Stateful, public StateManager {
/* destructive editing */
- virtual bool destroy_region (Region *) = 0;
+ virtual bool destroy_region (boost::shared_ptr<Region>) = 0;
protected:
friend class Session;
@@ -216,8 +217,8 @@ class Playlist : public Stateful, public StateManager {
void release_notifications ();
virtual void flush_notifications ();
- void notify_region_removed (Region *);
- void notify_region_added (Region *);
+ void notify_region_removed (boost::shared_ptr<Region>);
+ void notify_region_added (boost::shared_ptr<Region>);
void notify_length_changed ();
void notify_layering_changed ();
void notify_modified ();
@@ -225,11 +226,11 @@ class Playlist : public Stateful, public StateManager {
void mark_session_dirty();
- void region_changed_proxy (Change, Region*);
- virtual bool region_changed (Change, Region*);
+ void region_changed_proxy (Change, boost::shared_ptr<Region>);
+ virtual bool region_changed (Change, boost::shared_ptr<Region>);
- void region_bounds_changed (Change, Region *);
- void region_deleted (Region *);
+ void region_bounds_changed (Change, boost::shared_ptr<Region>);
+ void region_deleted (boost::shared_ptr<Region>);
void sort_regions ();
@@ -240,11 +241,11 @@ class Playlist : public Stateful, public StateManager {
void splice_unlocked ();
- virtual void finalize_split_region (Region *original, Region *left, Region *right) {}
+ virtual void finalize_split_region (boost::shared_ptr<Region> original, boost::shared_ptr<Region> left, boost::shared_ptr<Region> right) {}
- virtual void check_dependents (Region& region, bool norefresh) {}
- virtual void refresh_dependents (Region& region) {}
- virtual void remove_dependents (Region& region) {}
+ virtual void check_dependents (boost::shared_ptr<Region> region, bool norefresh) {}
+ virtual void refresh_dependents (boost::shared_ptr<Region> region) {}
+ virtual void remove_dependents (boost::shared_ptr<Region> region) {}
virtual XMLNode& state (bool);
@@ -253,9 +254,9 @@ class Playlist : public Stateful, public StateManager {
void save_state (std::string why);
void maybe_save_state (std::string why);
- void add_region_internal (Region *, jack_nframes_t position, bool delay_sort = false);
+ void add_region_internal (boost::shared_ptr<Region>, jack_nframes_t position, bool delay_sort = false);
- int remove_region_internal (Region *, bool delay_sort = false);
+ int remove_region_internal (boost::shared_ptr<Region>, bool delay_sort = false);
RegionList *find_regions_at (jack_nframes_t frame);
void copy_regions (RegionList&) const;
void partition_internal (jack_nframes_t start, jack_nframes_t end, bool cutting, RegionList& thawlist);
@@ -268,7 +269,7 @@ class Playlist : public Stateful, public StateManager {
Playlist *copy (jack_nframes_t start, jack_nframes_t cnt, bool result_is_hidden);
- int move_region_to_layer (layer_t, Region& r, int dir);
+ int move_region_to_layer (layer_t, boost::shared_ptr<Region> r, int dir);
void relayer ();
static Playlist* copyPlaylist (const Playlist&, jack_nframes_t start, jack_nframes_t length,
@@ -277,7 +278,7 @@ class Playlist : public Stateful, public StateManager {
void unset_freeze_parent (Playlist*);
void unset_freeze_child (Playlist*);
- void timestamp_layer_op (Region&);
+ void timestamp_layer_op (boost::shared_ptr<Region>);
PBD::ID _id;
};
diff --git a/libs/ardour/ardour/playlist_templates.h b/libs/ardour/ardour/playlist_templates.h
index d3d682b8c5..7ce6c1818c 100644
--- a/libs/ardour/ardour/playlist_templates.h
+++ b/libs/ardour/ardour/playlist_templates.h
@@ -30,14 +30,14 @@ template<class T> void AudioPlaylist::foreach_crossfade (T *t, void (T::*func)(C
}
}
-template<class T> void Playlist::foreach_region (T *t, void (T::*func)(Region *, void *), void *arg) {
+template<class T> void Playlist::foreach_region (T *t, void (T::*func)(boost::shared_ptr<Region>, void *), void *arg) {
RegionLock rlock (this, false);
for (RegionList::iterator i = regions.begin(); i != regions.end(); i++) {
(t->*func) ((*i), arg);
}
}
-template<class T> void Playlist::foreach_region (T *t, void (T::*func)(Region *)) {
+template<class T> void Playlist::foreach_region (T *t, void (T::*func)(boost::shared_ptr<Region>)) {
RegionLock rlock (this, false);
for (RegionList::const_iterator i = regions.begin(); i != regions.end(); i++) {
(t->*func) (*i);
diff --git a/libs/ardour/ardour/plugin.h b/libs/ardour/ardour/plugin.h
index a199e99933..2117a9d58a 100644
--- a/libs/ardour/ardour/plugin.h
+++ b/libs/ardour/ardour/plugin.h
@@ -24,7 +24,7 @@
#include <boost/shared_ptr.hpp>
#include <sigc++/signal.h>
-#include <pbd/stateful.h>
+#include <pbd/statefuldestructible.h>
#include <pbd/controllable.h>
#include <jack/types.h>
@@ -78,8 +78,7 @@ class PluginInfo {
typedef boost::shared_ptr<PluginInfo> PluginInfoPtr;
typedef std::list<PluginInfoPtr> PluginInfoList;
-class Plugin : public Stateful, public sigc::trackable
-
+class Plugin : public PBD::StatefulDestructible, public sigc::trackable
{
public:
Plugin (ARDOUR::AudioEngine&, ARDOUR::Session&);
@@ -141,7 +140,6 @@ class Plugin : public Stateful, public sigc::trackable
virtual bool has_editor() const = 0;
sigc::signal<void,uint32_t,float> ParameterChanged;
- sigc::signal<void,Plugin *> GoingAway;
PBD::Controllable *get_nth_control (uint32_t);
diff --git a/libs/ardour/ardour/redirect.h b/libs/ardour/ardour/redirect.h
index b9e91e1cfd..4015c708de 100644
--- a/libs/ardour/ardour/redirect.h
+++ b/libs/ardour/ardour/redirect.h
@@ -92,7 +92,6 @@ class Redirect : public IO
sigc::signal<void,Redirect*,void*> placement_changed;
sigc::signal<void,Redirect*,bool> AutomationPlaybackChanged;
sigc::signal<void,Redirect*,uint32_t> AutomationChanged;
- sigc::signal<void,Redirect*> GoingAway;
static sigc::signal<void,Redirect*> RedirectCreated;
diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h
index 80504ce044..1abba574f1 100644
--- a/libs/ardour/ardour/region.h
+++ b/libs/ardour/ardour/region.h
@@ -22,8 +22,10 @@
#define __ardour_region_h__
#include <vector>
+#include <boost/shared_ptr.hpp>
#include <pbd/undo.h>
+#include <pbd/statefuldestructible.h>
#include <ardour/ardour.h>
#include <ardour/state_manager.h>
@@ -56,10 +58,10 @@ struct RegionState : public StateManager::State
mutable RegionEditState _first_edit;
};
-class Region : public Stateful, public StateManager
+class Region : public PBD::StatefulDestructible, public StateManager
{
public:
- typedef std::vector<Source *> SourceList;
+ typedef std::vector<boost::shared_ptr<Source> > SourceList;
enum Flag {
Muted = 0x1,
@@ -94,15 +96,6 @@ class Region : public Stateful, public StateManager
static Change LayerChanged;
static Change HiddenChanged;
- Region (Source& src, jack_nframes_t start, jack_nframes_t length,
- const string& name, DataType type, layer_t = 0, Flag flags = DefaultFlags);
- Region (SourceList& srcs, jack_nframes_t start, jack_nframes_t length,
- const string& name, DataType type, layer_t = 0, Flag flags = DefaultFlags);
- Region (const Region&, jack_nframes_t start, jack_nframes_t length,
- const string& name, layer_t = 0, Flag flags = DefaultFlags);
- Region (const Region&);
- Region (SourceList& srcs, const XMLNode&);
- Region (Source& src, const XMLNode&);
virtual ~Region();
const PBD::ID& id() const { return _id; }
@@ -151,11 +144,11 @@ class Region : public Stateful, public StateManager
return ARDOUR::coverage (_position, _position + _length - 1, start, end);
}
- bool equivalent (const Region&) const;
- bool size_equivalent (const Region&) const;
- bool overlap_equivalent (const Region&) const;
- bool region_list_equivalent (const Region&) const;
- bool source_equivalent (const Region&) const;
+ bool equivalent (boost::shared_ptr<const Region>) const;
+ bool size_equivalent (boost::shared_ptr<const Region>) const;
+ bool overlap_equivalent (boost::shared_ptr<const Region>) const;
+ bool region_list_equivalent (boost::shared_ptr<const Region>) const;
+ bool source_equivalent (boost::shared_ptr<const Region>) const;
/* EDITING OPERATIONS */
@@ -194,12 +187,10 @@ class Region : public Stateful, public StateManager
void set_playlist (ARDOUR::Playlist*);
- void lock_sources ();
- void unlock_sources ();
- void source_deleted (Source*);
+ void source_deleted (boost::shared_ptr<Source>);
- Source& source (uint32_t n=0) const { return *_sources[ (n < _sources.size()) ? n : 0 ]; }
- uint32_t n_channels() const { return _sources.size(); }
+ boost::shared_ptr<Source> source (uint32_t n=0) const { return _sources[ (n < _sources.size()) ? n : 0 ]; }
+ uint32_t n_channels() const { return _sources.size(); }
std::vector<string> master_source_names();
@@ -210,24 +201,24 @@ class Region : public Stateful, public StateManager
virtual XMLNode& state (bool);
virtual int set_state (const XMLNode&);
- sigc::signal<void,Region*> GoingAway;
-
- /* This is emitted only when a new id is assigned. Therefore,
- in a pure Region copy, it will not be emitted.
-
- It must be emitted by derived classes, not Region
- itself, to permit dynamic_cast<> to be used to
- infer the type of Region.
- */
-
- static sigc::signal<void,Region*> CheckNewRegion;
-
- Region* get_parent();
+ boost::shared_ptr<Region> get_parent();
uint64_t last_layer_op() const { return _last_layer_op; }
void set_last_layer_op (uint64_t when);
protected:
+ friend class RegionFactory;
+
+ Region (boost::shared_ptr<Source> src, jack_nframes_t start, jack_nframes_t length,
+ const string& name, DataType type, layer_t = 0, Flag flags = DefaultFlags);
+ Region (SourceList& srcs, jack_nframes_t start, jack_nframes_t length,
+ const string& name, DataType type, layer_t = 0, Flag flags = DefaultFlags);
+ Region (boost::shared_ptr<const Region>, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Flag flags = DefaultFlags);
+ Region (boost::shared_ptr<const Region>);
+ Region (boost::shared_ptr<Source> src, const XMLNode&);
+ Region (SourceList& srcs, const XMLNode&);
+
+ protected:
XMLNode& get_short_state (); /* used only by Session */
/* state management */
diff --git a/libs/ardour/ardour/region_factory.h b/libs/ardour/ardour/region_factory.h
index f72c0a52d8..bd5089f512 100644
--- a/libs/ardour/ardour/region_factory.h
+++ b/libs/ardour/ardour/region_factory.h
@@ -10,12 +10,30 @@ namespace ARDOUR {
class Session;
-Region* createRegion (const Region&, jack_nframes_t start,
- jack_nframes_t length, std::string name,
- layer_t = 0, Region::Flag flags = Region::DefaultFlags);
-// Region* createRegion (const Region&, std::string name);
-Region* createRegion (const Region&);
-Region* createRegion (Session&, XMLNode&, bool);
+class RegionFactory {
+
+ public:
+ /** This is emitted only when a new id is assigned. Therefore,
+ in a pure Region copy, it will not be emitted.
+
+ It must be emitted by derived classes, not Region
+ itself, to permit dynamic_cast<> to be used to
+ infer the type of Region.
+ */
+ static sigc::signal<void,boost::shared_ptr<Region> > CheckNewRegion;
+
+ static boost::shared_ptr<Region> create (boost::shared_ptr<Region>, jack_nframes_t start,
+ jack_nframes_t length, std::string name,
+ layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
+ static boost::shared_ptr<Region> create (boost::shared_ptr<AudioRegion>, jack_nframes_t start,
+ jack_nframes_t length, std::string name,
+ layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
+ static boost::shared_ptr<Region> create (boost::shared_ptr<Source>, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
+ static boost::shared_ptr<Region> create (SourceList &, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
+ static boost::shared_ptr<Region> create (boost::shared_ptr<Region>);
+ static boost::shared_ptr<Region> create (Session&, XMLNode&, bool);
+ static boost::shared_ptr<Region> create (SourceList &, const XMLNode&);
+};
}
diff --git a/libs/ardour/ardour/reverse.h b/libs/ardour/ardour/reverse.h
index 05ea8a1353..c60df990f2 100644
--- a/libs/ardour/ardour/reverse.h
+++ b/libs/ardour/ardour/reverse.h
@@ -30,7 +30,7 @@ class Reverse : public AudioFilter {
Reverse (ARDOUR::Session&);
~Reverse ();
- int run (ARDOUR::AudioRegion&);
+ int run (boost::shared_ptr<ARDOUR::AudioRegion>);
};
} /* namespace */
diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h
index 5b9c92dc71..7abc69f059 100644
--- a/libs/ardour/ardour/route.h
+++ b/libs/ardour/ardour/route.h
@@ -56,7 +56,7 @@ enum mute_type {
MAIN_OUTS = 0x8
};
- class Route : public IO, public PBD::Destructible
+class Route : public IO
{
protected:
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index eeb905a301..ee87848dcb 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -1,22 +1,22 @@
-/*
- Copyright (C) 2000 Paul Davis
+ /*
+ Copyright (C) 2000 Paul Davis
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id$
-*/
+ $Id$
+ */
#ifndef __ardour_session_h__
#define __ardour_session_h__
@@ -27,6 +27,9 @@
#include <vector>
#include <set>
#include <stack>
+
+#include <boost/weak_ptr.hpp>
+
#include <stdint.h>
#include <sndfile.h>
@@ -37,11 +40,13 @@
#include <pbd/undo.h>
#include <pbd/pool.h>
#include <pbd/rcu.h>
+#include <pbd/statefuldestructible.h>
#include <midi++/types.h>
#include <midi++/mmc.h>
#include <pbd/stateful.h>
+#include <pbd/destructible.h>
#include <ardour/ardour.h>
#include <ardour/configuration.h>
@@ -108,12 +113,10 @@ struct RouteGroup;
using std::vector;
using std::string;
-using std::list;
using std::map;
using std::set;
-class Session : public sigc::trackable, public Stateful
-
+class Session : public sigc::trackable, public PBD::StatefulDestructible
{
private:
typedef std::pair<boost::shared_ptr<Route>,bool> RouteBooleanState;
@@ -133,7 +136,7 @@ class Session : public sigc::trackable, public Stateful
MTC,
JACK
};
-
+
enum AutoConnectOption {
AutoConnectPhysical = 0x1,
AutoConnectMaster = 0x2
@@ -185,6 +188,8 @@ class Session : public sigc::trackable, public Stateful
Route* route;
};
+ boost::shared_ptr<Region> region;
+
list<AudioRange> audio_range;
list<MusicRange> music_range;
@@ -339,11 +344,9 @@ class Session : public sigc::trackable, public Stateful
void disable_record (bool rt_context, bool force = false);
void step_back_from_record ();
- sigc::signal<void> going_away;
-
/* Proxy signal for region hidden changes */
- sigc::signal<void,Region*> RegionHiddenChange;
+ sigc::signal<void,boost::shared_ptr<Region> > RegionHiddenChange;
/* Emitted when all i/o connections are complete */
@@ -382,7 +385,7 @@ class Session : public sigc::trackable, public Stateful
int wipe ();
//int wipe_diskstream (AudioDiskstream *);
- int remove_region_from_region_list (Region&);
+ int remove_region_from_region_list (boost::shared_ptr<Region>);
jack_nframes_t get_maximum_extent () const;
jack_nframes_t current_end_frame() const { return end_location->start(); }
@@ -633,21 +636,21 @@ class Session : public sigc::trackable, public Stateful
/* region info */
- sigc::signal<void,Region *> RegionAdded;
- sigc::signal<void,Region *> RegionRemoved;
+ sigc::signal<void,boost::shared_ptr<Region> > RegionAdded;
+ sigc::signal<void,boost::shared_ptr<Region> > RegionRemoved;
int region_name (string& result, string base = string(""), bool newlevel = false) const;
string new_region_name (string);
string path_from_region_name (string name, string identifier);
- Region* find_whole_file_parent (Region& child);
- void find_equivalent_playlist_regions (Region&, std::vector<Region*>& result);
+ boost::shared_ptr<Region> find_whole_file_parent (Region&);
+ void find_equivalent_playlist_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >& result);
- Region* XMLRegionFactory (const XMLNode&, bool full);
- AudioRegion* XMLAudioRegionFactory (const XMLNode&, bool full);
- MidiRegion* XMLMidiRegionFactory (const XMLNode&, bool full);
+ boost::shared_ptr<Region> XMLRegionFactory (const XMLNode&, bool full);
+ boost::shared_ptr<AudioRegion> XMLAudioRegionFactory (const XMLNode&, bool full);
+ boost::shared_ptr<MidiRegion> XMLMidiRegionFactory (const XMLNode&, bool full);
- template<class T> void foreach_region (T *obj, void (T::*func)(Region *));
+ template<class T> void foreach_region (T *obj, void (T::*func)(boost::shared_ptr<Region>));
/* source management */
@@ -661,8 +664,7 @@ class Session : public sigc::trackable, public Stateful
string pathname;
/* result */
- std::vector<Region*> new_regions;
-
+ std::vector<boost::shared_ptr<Region> > new_regions;
};
int import_audiofile (import_status&);
@@ -675,9 +677,9 @@ class Session : public sigc::trackable, public Stateful
int start_audio_export (ARDOUR::AudioExportSpecification&);
int stop_audio_export (ARDOUR::AudioExportSpecification&);
- void add_source (Source *);
- void remove_source (Source *);
- int cleanup_audio_file_source (AudioFileSource&);
+ void add_source (boost::shared_ptr<Source>);
+ void remove_source (boost::weak_ptr<Source>);
+ int cleanup_audio_file_source (boost::shared_ptr<AudioFileSource>);
struct cleanup_report {
vector<string> paths;
@@ -687,8 +689,8 @@ class Session : public sigc::trackable, public Stateful
int cleanup_sources (cleanup_report&);
int cleanup_trash_sources (cleanup_report&);
- int destroy_region (Region*);
- int destroy_regions (list<Region*>);
+ int destroy_region (boost::shared_ptr<Region>);
+ int destroy_regions (std::list<boost::shared_ptr<Region> >);
int remove_last_capture ();
@@ -706,14 +708,14 @@ class Session : public sigc::trackable, public Stateful
static sigc::signal<int> AskAboutPendingState;
- sigc::signal<void,Source *> SourceAdded;
- sigc::signal<void,Source *> SourceRemoved;
+ sigc::signal<void,boost::shared_ptr<Source> > SourceAdded;
+ sigc::signal<void,boost::shared_ptr<Source> > SourceRemoved;
- AudioFileSource *create_audio_source_for_session (ARDOUR::AudioDiskstream&, uint32_t which_channel, bool destructive);
+ boost::shared_ptr<AudioFileSource> create_audio_source_for_session (ARDOUR::AudioDiskstream&, uint32_t which_channel, bool destructive);
- MidiSource *create_midi_source_for_session (ARDOUR::MidiDiskstream&);
+ boost::shared_ptr<MidiSource> create_midi_source_for_session (ARDOUR::MidiDiskstream&);
- Source *source_by_id (const PBD::ID&);
+ boost::shared_ptr<Source> source_by_id (const PBD::ID&);
/* playlist management */
@@ -750,7 +752,7 @@ class Session : public sigc::trackable, public Stateful
boost::shared_ptr<Auditioner> the_auditioner() { return auditioner; }
void audition_playlist ();
- void audition_region (Region&);
+ void audition_region (boost::shared_ptr<Region>);
void cancel_audition ();
bool is_auditioning () const;
@@ -758,7 +760,8 @@ class Session : public sigc::trackable, public Stateful
/* flattening stuff */
- int write_one_audio_track (AudioTrack&, jack_nframes_t start, jack_nframes_t cnt, bool overwrite, vector<Source*>&, InterThreadInfo& wot);
+ int write_one_audio_track (AudioTrack&, jack_nframes_t start, jack_nframes_t cnt, bool overwrite, vector<boost::shared_ptr<Source> >&,
+ InterThreadInfo& wot);
int freeze (InterThreadInfo&);
/* session-wide solo/mute/rec-enable */
@@ -861,12 +864,15 @@ class Session : public sigc::trackable, public Stateful
void commit_reversible_command (Command* cmd = 0);
void add_command (Command *const cmd) {
- current_trans.add_command (cmd);
+ current_trans->add_command (cmd);
}
+ std::map<PBD::ID, PBD::StatefulDestructible*> registry;
+
// these commands are implemented in libs/ardour/session_command.cc
Command *memento_command_factory(XMLNode *n);
- void register_with_memento_command_factory(PBD::ID, Stateful *);
+ void register_with_memento_command_factory(PBD::ID, PBD::StatefulDestructible *);
+
class GlobalSoloStateCommand : public Command
{
GlobalRouteBooleanState before, after;
@@ -936,17 +942,17 @@ class Session : public sigc::trackable, public Stateful
/* tempo FX */
struct TimeStretchRequest {
- ARDOUR::AudioRegion* region;
+ boost::shared_ptr<ARDOUR::AudioRegion> region;
float fraction; /* session: read ; GUI: write */
float progress; /* session: write ; GUI: read */
bool running; /* read/write */
bool quick_seek; /* GUI: write */
bool antialias; /* GUI: write */
- TimeStretchRequest () : region (0) {}
+ TimeStretchRequest () {}
};
- AudioRegion* tempoize_region (TimeStretchRequest&);
+ boost::shared_ptr<AudioRegion> tempoize_region (TimeStretchRequest&);
string raid_path() const;
void set_raid_path(string);
@@ -1558,27 +1564,27 @@ class Session : public sigc::trackable, public Stateful
/* REGION MANAGEMENT */
mutable Glib::Mutex region_lock;
- typedef map<PBD::ID,Region *> RegionList;
+ typedef map<PBD::ID,boost::shared_ptr<Region> > RegionList;
RegionList regions;
- void region_renamed (Region *);
- void region_changed (Change, Region *);
- void add_region (Region *);
- void remove_region (Region *);
+ void region_renamed (boost::shared_ptr<Region>);
+ void region_changed (Change, boost::shared_ptr<Region>);
+ void add_region (boost::shared_ptr<Region>);
+ void remove_region (boost::shared_ptr<Region>);
int load_regions (const XMLNode& node);
/* SOURCES */
mutable Glib::Mutex source_lock;
- typedef std::map<PBD::ID,Source *> SourceList;
+ typedef std::map<PBD::ID,boost::shared_ptr<Source> > SourceMap;
- SourceList sources;
+ SourceMap sources;
int load_sources (const XMLNode& node);
XMLNode& get_sources_as_xml ();
- Source *XMLSourceFactory (const XMLNode&);
+ boost::shared_ptr<Source> XMLSourceFactory (const XMLNode&);
/* PLAYLISTS */
@@ -1609,9 +1615,9 @@ class Session : public sigc::trackable, public Stateful
NamedSelection *named_selection_factory (string name);
NamedSelection *XMLNamedSelectionFactory (const XMLNode&);
- /* CURVES and AUTOMATION LISTS */
- std::map<PBD::ID, Curve*> curves;
- std::map<PBD::ID, AutomationList*> automation_lists;
+ /* CURVES and AUTOMATION LISTS */
+ std::map<PBD::ID, Curve*> curves;
+ std::map<PBD::ID, AutomationList*> automation_lists;
/* DEFAULT FADE CURVES */
@@ -1621,9 +1627,9 @@ class Session : public sigc::trackable, public Stateful
/* AUDITIONING */
boost::shared_ptr<Auditioner> auditioner;
- void set_audition (AudioRegion*);
+ void set_audition (boost::shared_ptr<Region>);
void non_realtime_set_audition ();
- AudioRegion *pending_audition_region;
+ boost::shared_ptr<Region> pending_audition_region;
/* EXPORT */
@@ -1692,7 +1698,7 @@ class Session : public sigc::trackable, public Stateful
void reverse_diskstream_buffers ();
UndoHistory history;
- UndoTransaction current_trans;
+ UndoTransaction* current_trans;
GlobalRouteBooleanState get_global_route_boolean (bool (Route::*method)(void) const);
GlobalRouteMeterState get_global_route_metering ();
diff --git a/libs/ardour/ardour/session_region.h b/libs/ardour/ardour/session_region.h
index fae950baa6..bce025adbe 100644
--- a/libs/ardour/ardour/session_region.h
+++ b/libs/ardour/ardour/session_region.h
@@ -6,7 +6,7 @@
namespace ARDOUR {
-template<class T> void Session::foreach_region (T *obj, void (T::*func)(Region *))
+template<class T> void Session::foreach_region (T *obj, void (T::*func)(boost::shared_ptr<Region>))
{
Glib::Mutex::Lock lm (region_lock);
for (RegionList::iterator i = regions.begin(); i != regions.end(); i++) {
@@ -14,6 +14,6 @@ template<class T> void Session::foreach_region (T *obj, void (T::*func)(Region *
}
}
-}
+} // namespace ARDOUR
#endif /* __ardour_session_region_h__ */
diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h
index a8d0fed20b..1728cdb477 100644
--- a/libs/ardour/ardour/source.h
+++ b/libs/ardour/ardour/source.h
@@ -24,15 +24,16 @@
#include <string>
#include <sigc++/signal.h>
+#include <boost/enable_shared_from_this.hpp>
-#include <pbd/stateful.h>
+#include <pbd/statefuldestructible.h>
#include <ardour/ardour.h>
#include <ardour/data_type.h>
namespace ARDOUR {
-class Source : public Stateful, public sigc::trackable
+class Source : public PBD::StatefulDestructible, public sigc::trackable, public boost::enable_shared_from_this<Source>
{
public:
Source (std::string name, DataType type);
@@ -42,13 +43,9 @@ class Source : public Stateful, public sigc::trackable
std::string name() const { return _name; }
int set_name (std::string str, bool destructive);
- const PBD::ID& id() const { return _id; }
+ DataType type() { return _type; }
- uint32_t use_cnt() const { return _use_cnt; }
- void use ();
- void release ();
-
- virtual void mark_for_remove() = 0;
+ const PBD::ID& id() const { return _id; }
time_t timestamp() const { return _timestamp; }
void stamp (time_t when) { _timestamp = when; }
@@ -58,18 +55,19 @@ class Source : public Stateful, public sigc::trackable
virtual jack_nframes_t natural_position() const { return 0; }
+ virtual void mark_for_remove() = 0;
+ virtual void mark_streaming_write_completed () = 0;
+
XMLNode& get_state ();
int set_state (const XMLNode&);
-
+
static sigc::signal<void,Source*> SourceCreated;
- sigc::signal<void,Source *> GoingAway;
protected:
void update_length (jack_nframes_t pos, jack_nframes_t cnt);
string _name;
DataType _type;
- uint32_t _use_cnt;
time_t _timestamp;
jack_nframes_t _length;
diff --git a/libs/ardour/ardour/source_factory.h b/libs/ardour/ardour/source_factory.h
new file mode 100644
index 0000000000..2b25752a0d
--- /dev/null
+++ b/libs/ardour/ardour/source_factory.h
@@ -0,0 +1,28 @@
+#ifndef __ardour_source_factory_h__
+#define __ardour_source_factory_h__
+
+#include <string>
+#include <stdint.h>
+#include <sigc++/sigc++.h>
+#include <boost/shared_ptr.hpp>
+
+#include <ardour/source.h>
+#include <ardour/audiofilesource.h>
+
+class XMLNode;
+
+namespace ARDOUR {
+
+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> 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);
+};
+
+}
+
+#endif /* __ardour_source_factory_h__ */
diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h
index bfd3e429c3..a365717417 100644
--- a/libs/ardour/ardour/tempo.h
+++ b/libs/ardour/ardour/tempo.h
@@ -26,8 +26,11 @@
#include <vector>
#include <cmath>
#include <glibmm/thread.h>
+
#include <pbd/undo.h>
#include <pbd/stateful.h>
+#include <pbd/statefuldestructible.h>
+
#include <sigc++/signal.h>
#include <ardour/ardour.h>
@@ -169,7 +172,8 @@ class TempoMapState : public StateManager::State {
Metrics *metrics;
};
-class TempoMap : public Stateful, public StateManager {
+class TempoMap : public StateManager, public PBD::StatefulDestructible
+{
public:
TempoMap (jack_nframes_t frame_rate);
diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h
index d5bfded460..c0975be922 100644
--- a/libs/ardour/ardour/types.h
+++ b/libs/ardour/ardour/types.h
@@ -26,6 +26,8 @@
#endif
#include <istream>
+#include <vector>
+#include <boost/shared_ptr.hpp>
#include <inttypes.h>
#include <jack/types.h>
@@ -43,6 +45,7 @@ typedef int intptr_t;
namespace ARDOUR {
class Source;
+ class AudioSource;
typedef jack_default_audio_sample_t Sample;
typedef float pan_t;
@@ -254,6 +257,7 @@ namespace ARDOUR {
VST
};
+ typedef std::vector<boost::shared_ptr<Source> > SourceList;
} // namespace ARDOUR
std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf);