summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2006-08-25 01:07:15 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2006-08-25 01:07:15 +0000
commitce234f363e95c38fc92728e520bf5ba240a89aa7 (patch)
tree96ce8c4734bdd564ec1f2ad0c36bc32f0b108204
parent7e95f29ce95edf01d6d451f96fae03f3d3451ff8 (diff)
use shared_ptr<> for all region handling
git-svn-id: svn://localhost/ardour2/trunk@852 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/SConscript4
-rw-r--r--gtk2_ardour/about.cc14
-rwxr-xr-xgtk2_ardour/arval2
-rw-r--r--gtk2_ardour/audio_region_editor.cc92
-rw-r--r--gtk2_ardour/audio_region_editor.h4
-rw-r--r--gtk2_ardour/audio_region_view.cc106
-rw-r--r--gtk2_ardour/audio_region_view.h88
-rw-r--r--gtk2_ardour/audio_regionview.cc10
-rw-r--r--gtk2_ardour/audio_streamview.cc49
-rw-r--r--gtk2_ardour/audio_streamview.h8
-rw-r--r--gtk2_ardour/automation_line.h4
-rw-r--r--gtk2_ardour/crossfade_edit.cc71
-rw-r--r--gtk2_ardour/crossfade_edit.h4
-rw-r--r--gtk2_ardour/crossfade_view.cc2
-rw-r--r--gtk2_ardour/editor.cc108
-rw-r--r--gtk2_ardour/editor.h52
-rw-r--r--gtk2_ardour/editor_audio_import.cc35
-rw-r--r--gtk2_ardour/editor_canvas.cc8
-rw-r--r--gtk2_ardour/editor_canvas_events.cc4
-rw-r--r--gtk2_ardour/editor_export_audio.cc26
-rw-r--r--gtk2_ardour/editor_keyboard.cc8
-rw-r--r--gtk2_ardour/editor_mixer.cc1
-rw-r--r--gtk2_ardour/editor_mouse.cc222
-rw-r--r--gtk2_ardour/editor_ops.cc327
-rw-r--r--gtk2_ardour/editor_region_list.cc64
-rw-r--r--gtk2_ardour/editor_timefx.cc12
-rw-r--r--gtk2_ardour/export_dialog.cc2
-rw-r--r--gtk2_ardour/export_region_dialog.cc5
-rw-r--r--gtk2_ardour/export_region_dialog.h4
-rw-r--r--gtk2_ardour/io_selector.cc6
-rw-r--r--gtk2_ardour/io_selector.h2
-rw-r--r--gtk2_ardour/location_ui.cc2
-rw-r--r--gtk2_ardour/meter_bridge.cc4
-rw-r--r--gtk2_ardour/mixer_ui.cc2
-rw-r--r--gtk2_ardour/playlist_selector.cc2
-rw-r--r--gtk2_ardour/plugin_selector.cc2
-rw-r--r--gtk2_ardour/plugin_ui.cc4
-rw-r--r--gtk2_ardour/plugin_ui.h2
-rw-r--r--gtk2_ardour/public_editor.h6
-rw-r--r--gtk2_ardour/region_gain_line.cc22
-rw-r--r--gtk2_ardour/region_selection.cc26
-rw-r--r--gtk2_ardour/region_view.cc78
-rw-r--r--gtk2_ardour/region_view.h22
-rw-r--r--gtk2_ardour/route_params_ui.cc23
-rw-r--r--gtk2_ardour/route_params_ui.h4
-rw-r--r--gtk2_ardour/route_time_axis.cc4
-rw-r--r--gtk2_ardour/route_time_axis.h2
-rw-r--r--gtk2_ardour/selection.cc2
-rw-r--r--gtk2_ardour/selection_templates.h24
-rw-r--r--gtk2_ardour/send_ui.cc8
-rw-r--r--gtk2_ardour/send_ui.h4
-rw-r--r--gtk2_ardour/sfdb_ui.cc17
-rw-r--r--gtk2_ardour/streamview.cc18
-rw-r--r--gtk2_ardour/streamview.h12
-rw-r--r--gtk2_ardour/tape_region_view.cc10
-rw-r--r--gtk2_ardour/tape_region_view.h2
-rw-r--r--gtk2_ardour/time_axis_view.h4
-rw-r--r--libs/ardour/SConscript1
-rw-r--r--libs/ardour/ardour/audio_diskstream.h2
-rw-r--r--libs/ardour/ardour/audiofilter.h8
-rw-r--r--libs/ardour/ardour/audioplaylist.h14
-rw-r--r--libs/ardour/ardour/audioregion.h23
-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.h8
-rw-r--r--libs/ardour/ardour/io.h6
-rw-r--r--libs/ardour/ardour/location.h6
-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.h44
-rw-r--r--libs/ardour/ardour/region_factory.h28
-rw-r--r--libs/ardour/ardour/reverse.h2
-rw-r--r--libs/ardour/ardour/route.h2
-rw-r--r--libs/ardour/ardour/session.h60
-rw-r--r--libs/ardour/ardour/session_region.h2
-rw-r--r--libs/ardour/ardour/source.h5
-rw-r--r--libs/ardour/ardour/tempo.h6
-rw-r--r--libs/ardour/ardour/types.h4
-rw-r--r--libs/ardour/audio_diskstream.cc50
-rw-r--r--libs/ardour/audio_playlist.cc145
-rw-r--r--libs/ardour/audio_track.cc12
-rw-r--r--libs/ardour/audiofilter.cc23
-rw-r--r--libs/ardour/audioregion.cc95
-rw-r--r--libs/ardour/auditioner.cc15
-rw-r--r--libs/ardour/automation_event.cc2
-rw-r--r--libs/ardour/control_protocol_manager.cc2
-rw-r--r--libs/ardour/coreaudiosource.cc2
-rw-r--r--libs/ardour/crossfade.cc38
-rw-r--r--libs/ardour/diskstream.cc4
-rw-r--r--libs/ardour/import.cc18
-rw-r--r--libs/ardour/insert.cc4
-rw-r--r--libs/ardour/ladspa_plugin.cc2
-rw-r--r--libs/ardour/location.cc34
-rw-r--r--libs/ardour/osc.cc2
-rw-r--r--libs/ardour/playlist.cc221
-rw-r--r--libs/ardour/playlist_factory.cc46
-rw-r--r--libs/ardour/region.cc73
-rw-r--r--libs/ardour/reverse.cc16
-rw-r--r--libs/ardour/send.cc2
-rw-r--r--libs/ardour/session.cc115
-rw-r--r--libs/ardour/session_command.cc7
-rw-r--r--libs/ardour/session_events.cc2
-rw-r--r--libs/ardour/session_state.cc48
-rw-r--r--libs/ardour/session_timefx.cc23
-rw-r--r--libs/ardour/sndfilesource.cc11
-rw-r--r--libs/ardour/vst_plugin.cc2
-rw-r--r--libs/pbd/pbd/command.h3
-rw-r--r--libs/pbd/pbd/memento_command.h39
-rw-r--r--libs/pbd/pbd/statefuldestructible.h13
-rw-r--r--libs/pbd/pbd/undo.h34
-rw-r--r--libs/pbd/undo.cc78
114 files changed, 1606 insertions, 1570 deletions
diff --git a/gtk2_ardour/SConscript b/gtk2_ardour/SConscript
index 658caac1e3..ca40cbfcb9 100644
--- a/gtk2_ardour/SConscript
+++ b/gtk2_ardour/SConscript
@@ -209,6 +209,10 @@ itest_files=Split("""
itest.cc
""")
+stest_files=Split("""
+stest.cc
+""")
+
extra_sources = []
vst_files = [ 'vst_pluginui.cc' ]
diff --git a/gtk2_ardour/about.cc b/gtk2_ardour/about.cc
index 033b5c4604..e48e08f130 100644
--- a/gtk2_ardour/about.cc
+++ b/gtk2_ardour/about.cc
@@ -186,13 +186,13 @@ About::About ()
set_website (X_("http://ardour.org/"));
set_website_label (X_("ardour.org"));
set_version ((string_compose(_("%1\n(built with ardour/gtk %2.%3.%4 libardour: %5.%6.%7)"),
- VERSIONSTRING,
- gtk_ardour_major_version,
- gtk_ardour_minor_version,
- gtk_ardour_micro_version,
- libardour_major_version,
- libardour_minor_version,
- libardour_micro_version)));
+ VERSIONSTRING,
+ gtk_ardour_major_version,
+ gtk_ardour_minor_version,
+ gtk_ardour_micro_version,
+ libardour_major_version,
+ libardour_minor_version,
+ libardour_micro_version)));
#ifdef WITH_PAYMENT_OPTIONS
diff --git a/gtk2_ardour/arval b/gtk2_ardour/arval
index dcbef15a0f..cea6299d05 100755
--- a/gtk2_ardour/arval
+++ b/gtk2_ardour/arval
@@ -1,3 +1,3 @@
#!/bin/sh
source ardev_common.sh
-exec valgrind --num-callers=15 --tool=memcheck ./ardour.bin --novst $*
+exec valgrind --num-callers=50 --tool=memcheck gtk2_ardour/ardour.bin --novst $*
diff --git a/gtk2_ardour/audio_region_editor.cc b/gtk2_ardour/audio_region_editor.cc
index 194f358b42..3149a863ad 100644
--- a/gtk2_ardour/audio_region_editor.cc
+++ b/gtk2_ardour/audio_region_editor.cc
@@ -37,7 +37,7 @@ using namespace PBD;
using namespace sigc;
using namespace std;
-AudioRegionEditor::AudioRegionEditor (Session& s, AudioRegion& r, AudioRegionView& rv)
+AudioRegionEditor::AudioRegionEditor (Session& s, boost::shared_ptr<AudioRegion> r, AudioRegionView& rv)
: RegionEditor (s),
_region (r),
_region_view (rv),
@@ -262,7 +262,7 @@ AudioRegionEditor::AudioRegionEditor (Session& s, AudioRegion& r, AudioRegionVie
signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Window *> (this)));
string title = _("ardour: region ");
- title += _region.name();
+ title += _region->name();
set_title (title);
show_all();
@@ -277,7 +277,7 @@ AudioRegionEditor::AudioRegionEditor (Session& s, AudioRegion& r, AudioRegionVie
fade_in_changed ();
fade_out_changed ();
- XMLNode *node = _region.extra_xml ("GUI");
+ XMLNode *node = _region->extra_xml ("GUI");
XMLProperty *prop = 0;
bool showing_envelope = false;
@@ -293,7 +293,7 @@ AudioRegionEditor::AudioRegionEditor (Session& s, AudioRegion& r, AudioRegionVie
envelope_view_button.set_active (false);
}
- _region.StateChanged.connect (mem_fun(*this, &AudioRegionEditor::region_changed));
+ _region->StateChanged.connect (mem_fun(*this, &AudioRegionEditor::region_changed));
spin_arrow_grab = false;
@@ -392,25 +392,25 @@ AudioRegionEditor::breleased (GdkEventButton* ev, Gtk::SpinButton* but, void (Au
void
AudioRegionEditor::start_editing_fade_in ()
{
- _region.freeze ();
+ _region->freeze ();
}
void
AudioRegionEditor::stop_editing_fade_in ()
{
- _region.thaw (_("fade in edit"));
+ _region->thaw (_("fade in edit"));
}
void
AudioRegionEditor::start_editing_fade_out ()
{
- _region.freeze ();
+ _region->freeze ();
}
void
AudioRegionEditor::stop_editing_fade_out ()
{
- _region.thaw (_("fade out edit"));
+ _region->thaw (_("fade out edit"));
}
void
@@ -453,24 +453,24 @@ AudioRegionEditor::connect_editor_events ()
void
AudioRegionEditor::start_clock_changed ()
{
- _region.set_position (start_clock.current_time(), this);
+ _region->set_position (start_clock.current_time(), this);
}
void
AudioRegionEditor::end_clock_changed ()
{
- _region.trim_end (end_clock.current_time(), this);
+ _region->trim_end (end_clock.current_time(), this);
- end_clock.set (_region.position() + _region.length(), true);
+ end_clock.set (_region->position() + _region->length(), true);
}
void
AudioRegionEditor::length_clock_changed ()
{
jack_nframes_t frames = length_clock.current_time();
- _region.trim_end (_region.position() + frames, this);
+ _region->trim_end (_region->position() + frames, this);
- length_clock.set (_region.length());
+ length_clock.set (_region->length());
}
gint
@@ -482,7 +482,7 @@ AudioRegionEditor::envelope_active_button_press(GdkEventButton *ev)
gint
AudioRegionEditor::envelope_active_button_release (GdkEventButton *ev)
{
- _region.set_envelope_active (!_region.envelope_active());
+ _region->set_envelope_active (!_region->envelope_active());
return stop_signal (envelope_active_button, "button_release_event");
}
@@ -507,42 +507,42 @@ AudioRegionEditor::audition_button_toggled ()
void
AudioRegionEditor::raise_button_clicked ()
{
- _region.raise ();
+ _region->raise ();
}
void
AudioRegionEditor::lower_button_clicked ()
{
- _region.lower ();
+ _region->lower ();
}
void
AudioRegionEditor::opaque_button_clicked ()
{
- bool ractive = _region.opaque();
+ bool ractive = _region->opaque();
if (opaque_button.get_active() != ractive) {
- _region.set_opaque (!ractive);
+ _region->set_opaque (!ractive);
}
}
void
AudioRegionEditor::mute_button_clicked ()
{
- bool ractive = _region.muted();
+ bool ractive = _region->muted();
if (mute_button.get_active() != ractive) {
- _region.set_muted (!ractive);
+ _region->set_muted (!ractive);
}
}
void
AudioRegionEditor::lock_button_clicked ()
{
- bool ractive = _region.locked();
+ bool ractive = _region->locked();
if (lock_button.get_active() != ractive) {
- _region.set_locked (!ractive);
+ _region->set_locked (!ractive);
}
}
@@ -550,15 +550,15 @@ void
AudioRegionEditor::layer_changed ()
{
char buf[8];
- snprintf (buf, sizeof(buf), "%d", (int) _region.layer() + 1);
+ snprintf (buf, sizeof(buf), "%d", (int) _region->layer() + 1);
layer_value_label.set_text (buf);
}
void
AudioRegionEditor::name_changed ()
{
- if (name_entry.get_text() != _region.name()) {
- name_entry.set_text (_region.name());
+ if (name_entry.get_text() != _region->name()) {
+ name_entry.set_text (_region->name());
}
}
@@ -567,7 +567,7 @@ AudioRegionEditor::lock_changed ()
{
bool yn;
- if ((yn = _region.locked()) != lock_button.get_active()) {
+ if ((yn = _region->locked()) != lock_button.get_active()) {
lock_button.set_active (yn);
}
@@ -581,7 +581,7 @@ AudioRegionEditor::envelope_active_changed ()
{
bool yn;
- if ((yn = _region.envelope_active()) != envelope_active_button.get_active()) {
+ if ((yn = _region->envelope_active()) != envelope_active_button.get_active()) {
envelope_active_button.set_active (yn);
}
}
@@ -590,7 +590,7 @@ void
AudioRegionEditor::opacity_changed ()
{
bool yn;
- if ((yn = _region.opaque()) != opaque_button.get_active()) {
+ if ((yn = _region->opaque()) != opaque_button.get_active()) {
opaque_button.set_active (yn);
}
}
@@ -599,7 +599,7 @@ void
AudioRegionEditor::mute_changed ()
{
bool yn;
- if ((yn = _region.muted()) != mute_button.get_active()) {
+ if ((yn = _region->muted()) != mute_button.get_active()) {
mute_button.set_active (yn);
}
}
@@ -608,9 +608,9 @@ void
AudioRegionEditor::bounds_changed (Change what_changed)
{
if (what_changed & Change ((PositionChanged|LengthChanged))) {
- start_clock.set (_region.position(), true);
- end_clock.set (_region.position() + _region.length(), true);
- length_clock.set (_region.length(), true);
+ start_clock.set (_region->position(), true);
+ end_clock.set (_region->position() + _region->length(), true);
+ length_clock.set (_region->length(), true);
}
}
@@ -623,8 +623,8 @@ AudioRegionEditor::activation ()
void
AudioRegionEditor::name_entry_changed ()
{
- if (name_entry.get_text() != _region.name()) {
- _region.set_name (name_entry.get_text());
+ if (name_entry.get_text() != _region->name()) {
+ _region->set_name (name_entry.get_text());
}
}
@@ -637,11 +637,11 @@ AudioRegionEditor::fade_in_changed ()
jack_nframes_t frames;
bool x;
- if (adj_frames != (frames = (jack_nframes_t) _region.fade_in().back()->when)) {
+ if (adj_frames != (frames = (jack_nframes_t) _region->fade_in().back()->when)) {
fade_in_length_adjustment.set_value ((frames * 1000.0f) / sr);
}
- if ((x = _region.fade_in_active()) != fade_in_active_button.get_active()) {
+ if ((x = _region->fade_in_active()) != fade_in_active_button.get_active()) {
fade_in_active_button.set_active (x);
}
}
@@ -654,11 +654,11 @@ AudioRegionEditor::fade_out_changed ()
jack_nframes_t adj_frames = (jack_nframes_t) floor (msecs * (sr/1000.0f));
jack_nframes_t frames;
bool x;
- if (adj_frames != (frames = (jack_nframes_t) _region.fade_out().back()->when)) {
+ if (adj_frames != (frames = (jack_nframes_t) _region->fade_out().back()->when)) {
fade_out_length_adjustment.set_value ((frames * 1000.0f) / sr);
}
- if ((x = _region.fade_out_active()) != fade_out_active_button.get_active()) {
+ if ((x = _region->fade_out_active()) != fade_out_active_button.get_active()) {
fade_out_active_button.set_active (x);
}
}
@@ -668,9 +668,9 @@ AudioRegionEditor::fade_in_length_adjustment_changed ()
{
jack_nframes_t fade_length = (jack_nframes_t) floor (fade_in_length_adjustment.get_value() * _session.frame_rate() * 0.001);
fade_length = max (fade_length, (jack_nframes_t) 64);
- fade_length = min (fade_length, _region.length());
+ fade_length = min (fade_length, _region->length());
- _region.set_fade_in_length (fade_length);
+ _region->set_fade_in_length (fade_length);
/* region is frozen, no worries */
fade_in_changed();
}
@@ -680,9 +680,9 @@ AudioRegionEditor::fade_out_length_adjustment_changed ()
{
jack_nframes_t fade_length = (jack_nframes_t) floor (fade_out_length_adjustment.get_value() * _session.frame_rate() * 0.001);
fade_length = max (fade_length, (jack_nframes_t) 64);
- fade_length = min (fade_length, _region.length());
+ fade_length = min (fade_length, _region->length());
- _region.set_fade_out_length (fade_length);
+ _region->set_fade_out_length (fade_length);
/* region is frozen, no worries */
fade_out_changed();
}
@@ -690,13 +690,13 @@ AudioRegionEditor::fade_out_length_adjustment_changed ()
void
AudioRegionEditor::fade_in_active_toggled ()
{
- _region.set_fade_in_active (fade_in_active_button.get_active());
+ _region->set_fade_in_active (fade_in_active_button.get_active());
}
void
AudioRegionEditor::fade_out_active_toggled ()
{
- _region.set_fade_out_active (fade_out_active_button.get_active());
+ _region->set_fade_out_active (fade_out_active_button.get_active());
}
void
@@ -704,7 +704,7 @@ AudioRegionEditor::fade_out_active_changed ()
{
bool x;
- if ((x = _region.fade_out_active()) != fade_out_active_button.get_active()) {
+ if ((x = _region->fade_out_active()) != fade_out_active_button.get_active()) {
fade_out_active_button.set_active (x);
}
}
@@ -714,7 +714,7 @@ AudioRegionEditor::fade_in_active_changed ()
{
bool x;
- if ((x = _region.fade_in_active()) != fade_in_active_button.get_active()) {
+ if ((x = _region->fade_in_active()) != fade_in_active_button.get_active()) {
fade_in_active_button.set_active (x);
}
}
diff --git a/gtk2_ardour/audio_region_editor.h b/gtk2_ardour/audio_region_editor.h
index 38cd920e5e..dbbc40f9ba 100644
--- a/gtk2_ardour/audio_region_editor.h
+++ b/gtk2_ardour/audio_region_editor.h
@@ -53,11 +53,11 @@ class AudioRegionView;
class AudioRegionEditor : public RegionEditor
{
public:
- AudioRegionEditor (ARDOUR::Session&, ARDOUR::AudioRegion&, AudioRegionView& rv);
+ AudioRegionEditor (ARDOUR::Session&, boost::shared_ptr<ARDOUR::AudioRegion>, AudioRegionView& rv);
~AudioRegionEditor ();
private:
- ARDOUR::AudioRegion& _region;
+ boost::shared_ptr<ARDOUR::AudioRegion> _region;
AudioRegionView& _region_view;
void connect_editor_events ();
diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc
index 915fa05750..19c8702e89 100644
--- a/gtk2_ardour/audio_region_view.cc
+++ b/gtk2_ardour/audio_region_view.cc
@@ -57,7 +57,7 @@ using namespace ArdourCanvas;
static const int32_t sync_mark_width = 9;
-AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, AudioRegion& r, double spu,
+AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
Gdk::Color& basic_color)
: RegionView (parent, tv, r, spu, basic_color)
, sync_mark(0)
@@ -73,7 +73,7 @@ AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView
{
}
-AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, AudioRegion& r, double spu,
+AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
Gdk::Color& basic_color, TimeAxisViewItem::Visibility visibility)
: RegionView (parent, tv, r, spu, basic_color, visibility)
, sync_mark(0)
@@ -103,7 +103,7 @@ AudioRegionView::init (Gdk::Color& basic_color, bool wfd)
zero_line = 0;
_flags = 0;
- if ((node = _region.extra_xml ("GUI")) != 0) {
+ if ((node = _region->extra_xml ("GUI")) != 0) {
set_flags (node);
} else {
_flags = WaveformVisible;
@@ -149,11 +149,11 @@ AudioRegionView::init (Gdk::Color& basic_color, bool wfd)
fade_out_handle->set_data ("regionview", this);
}
- string foo = _region.name();
+ string foo = _region->name();
foo += ':';
foo += "gain";
- gain_line = new AudioRegionGainLine (foo, trackview.session(), *this, *group, audio_region().envelope());
+ gain_line = new AudioRegionGainLine (foo, trackview.session(), *this, *group, audio_region()->envelope());
if (!(_flags & EnvelopeVisible)) {
gain_line->hide ();
@@ -161,7 +161,7 @@ AudioRegionView::init (Gdk::Color& basic_color, bool wfd)
gain_line->show ();
}
- reset_width_dependent_items ((double) _region.length() / samples_per_unit);
+ reset_width_dependent_items ((double) _region->length() / samples_per_unit);
gain_line->reset ();
@@ -176,7 +176,7 @@ AudioRegionView::init (Gdk::Color& basic_color, bool wfd)
fade_in_active_changed ();
fade_out_active_changed ();
- _region.StateChanged.connect (mem_fun(*this, &AudioRegionView::region_changed));
+ _region->StateChanged.connect (mem_fun(*this, &AudioRegionView::region_changed));
fade_in_shape->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_event), fade_in_shape, this));
fade_in_handle->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_handle_event), fade_in_handle, this));
@@ -205,11 +205,11 @@ AudioRegionView::~AudioRegionView ()
}
}
-ARDOUR::AudioRegion&
+boost::shared_ptr<ARDOUR::AudioRegion>
AudioRegionView::audio_region() const
{
// "Guaranteed" to succeed...
- return dynamic_cast<AudioRegion&>(_region);
+ return boost::dynamic_pointer_cast<AudioRegion>(_region);
}
void
@@ -254,13 +254,13 @@ AudioRegionView::fade_out_changed ()
void
AudioRegionView::set_fade_in_active (bool yn)
{
- audio_region().set_fade_in_active (yn);
+ audio_region()->set_fade_in_active (yn);
}
void
AudioRegionView::set_fade_out_active (bool yn)
{
- audio_region().set_fade_out_active (yn);
+ audio_region()->set_fade_out_active (yn);
}
void
@@ -270,7 +270,7 @@ AudioRegionView::fade_in_active_changed ()
uint32_t col;
UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
- if (audio_region().fade_in_active()) {
+ if (audio_region()->fade_in_active()) {
col = RGBA_TO_UINT(r,g,b,120);
fade_in_shape->property_fill_color_rgba() = col;
fade_in_shape->property_width_pixels() = 0;
@@ -290,7 +290,7 @@ AudioRegionView::fade_out_active_changed ()
uint32_t col;
UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
- if (audio_region().fade_out_active()) {
+ if (audio_region()->fade_out_active()) {
col = RGBA_TO_UINT(r,g,b,120);
fade_out_shape->property_fill_color_rgba() = col;
fade_out_shape->property_width_pixels() = 0;
@@ -311,7 +311,7 @@ AudioRegionView::region_scale_amplitude_changed ()
for (uint32_t n = 0; n < waves.size(); ++n) {
// force a reload of the cache
- waves[n]->property_data_src() = &_region;
+ waves[n]->property_data_src() = _region.get();
}
}
@@ -323,13 +323,13 @@ AudioRegionView::region_resized (Change what_changed)
if (what_changed & Change (StartChanged|LengthChanged)) {
for (uint32_t n = 0; n < waves.size(); ++n) {
- waves[n]->property_region_start() = _region.start();
+ waves[n]->property_region_start() = _region->start();
}
for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
for (vector<WaveView*>::iterator w = (*i)->waves.begin(); w != (*i)->waves.end(); ++w) {
- (*w)->property_region_start() = _region.start();
+ (*w)->property_region_start() = _region->start();
}
}
}
@@ -369,7 +369,7 @@ AudioRegionView::region_muted ()
RegionView::region_muted();
for (uint32_t n=0; n < waves.size(); ++n) {
- if (_region.muted()) {
+ if (_region->muted()) {
waves[n]->property_wave_color() = color_map[cMutedWaveForm];
} else {
waves[n]->property_wave_color() = color_map[cWaveForm];
@@ -449,7 +449,7 @@ AudioRegionView::reset_fade_shapes ()
void
AudioRegionView::reset_fade_in_shape ()
{
- reset_fade_in_shape_width ((jack_nframes_t) audio_region().fade_in().back()->when);
+ reset_fade_in_shape_width ((jack_nframes_t) audio_region()->fade_in().back()->when);
}
void
@@ -494,7 +494,7 @@ AudioRegionView::reset_fade_in_shape_width (jack_nframes_t width)
fade_in_shape->show();
float curve[npoints];
- audio_region().fade_in().get_vector (0, audio_region().fade_in().back()->when, curve, npoints);
+ audio_region()->fade_in().get_vector (0, audio_region()->fade_in().back()->when, curve, npoints);
points = get_canvas_points ("fade in shape", npoints+3);
@@ -533,7 +533,7 @@ AudioRegionView::reset_fade_in_shape_width (jack_nframes_t width)
void
AudioRegionView::reset_fade_out_shape ()
{
- reset_fade_out_shape_width ((jack_nframes_t) audio_region().fade_out().back()->when);
+ reset_fade_out_shape_width ((jack_nframes_t) audio_region()->fade_out().back()->when);
}
void
@@ -559,7 +559,7 @@ AudioRegionView::reset_fade_out_shape_width (jack_nframes_t width)
}
double handle_center;
- handle_center = (_region.length() - width) / samples_per_unit;
+ handle_center = (_region->length() - width) / samples_per_unit;
if (handle_center > 7.0) {
handle_center -= 3.0;
@@ -580,7 +580,7 @@ AudioRegionView::reset_fade_out_shape_width (jack_nframes_t width)
fade_out_shape->show();
float curve[npoints];
- audio_region().fade_out().get_vector (0, audio_region().fade_out().back()->when, curve, npoints);
+ audio_region()->fade_out().get_vector (0, audio_region()->fade_out().back()->when, curve, npoints);
if (_height > NAME_HIGHLIGHT_THRESH) {
h = _height - NAME_HIGHLIGHT_SIZE;
@@ -658,11 +658,11 @@ AudioRegionView::set_colors ()
RegionView::set_colors();
if (gain_line) {
- gain_line->set_line_color (audio_region().envelope_active() ? color_map[cGainLine] : color_map[cGainLineInactive]);
+ gain_line->set_line_color (audio_region()->envelope_active() ? color_map[cGainLine] : color_map[cGainLineInactive]);
}
for (uint32_t n=0; n < waves.size(); ++n) {
- if (_region.muted()) {
+ if (_region->muted()) {
waves[n]->property_wave_color() = color_map[cMutedWaveForm];
} else {
waves[n]->property_wave_color() = color_map[cWaveForm];
@@ -754,14 +754,14 @@ AudioRegionView::create_waves ()
for (uint32_t n = 0; n < nchans; ++n) {
- if (n >= audio_region().n_channels()) {
+ if (n >= audio_region()->n_channels()) {
break;
}
wave_caches.push_back (WaveView::create_cache ());
if (wait_for_data) {
- if (audio_region().source(n).peaks_ready (bind (mem_fun(*this, &AudioRegionView::peaks_ready_handler), n), data_ready_connection)) {
+ if (audio_region()->source(n).peaks_ready (bind (mem_fun(*this, &AudioRegionView::peaks_ready_handler), n), data_ready_connection)) {
create_one_wave (n, true);
} else {
create_zero_line = false;
@@ -774,7 +774,7 @@ AudioRegionView::create_waves ()
if (create_zero_line) {
zero_line = new ArdourCanvas::SimpleLine (*group);
zero_line->property_x1() = (gdouble) 1.0;
- zero_line->property_x2() = (gdouble) (_region.length() / samples_per_unit) - 1.0;
+ zero_line->property_x2() = (gdouble) (_region->length() / samples_per_unit) - 1.0;
zero_line->property_color_rgba() = (guint) color_map[cZeroLine];
manage_zero_line ();
}
@@ -786,7 +786,7 @@ AudioRegionView::create_one_wave (uint32_t which, bool direct)
RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
uint32_t nchans = atv.get_diskstream()->n_channels();
uint32_t n;
- uint32_t nwaves = std::min (nchans, audio_region().n_channels());
+ uint32_t nwaves = std::min (nchans, audio_region()->n_channels());
gdouble ht;
if (trackview.height < NAME_HIGHLIGHT_SIZE) {
@@ -799,7 +799,7 @@ AudioRegionView::create_one_wave (uint32_t which, bool direct)
WaveView *wave = new WaveView(*group);
- wave->property_data_src() = (gpointer) &_region;
+ wave->property_data_src() = (gpointer) _region.get();
wave->property_cache() = wave_caches[which];
wave->property_cache_updater() = true;
wave->property_channel() = which;
@@ -811,8 +811,8 @@ AudioRegionView::create_one_wave (uint32_t which, bool direct)
wave->property_height() = (double) ht;
wave->property_samples_per_unit() = samples_per_unit;
wave->property_amplitude_above_axis() = _amplitude_above_axis;
- wave->property_wave_color() = _region.muted() ? color_map[cMutedWaveForm] : color_map[cWaveForm];
- wave->property_region_start() = _region.start();
+ wave->property_wave_color() = _region->muted() ? color_map[cMutedWaveForm] : color_map[cWaveForm];
+ wave->property_region_start() = _region->start();
if (!(_flags & WaveformVisible)) {
wave->hide();
@@ -848,7 +848,7 @@ AudioRegionView::create_one_wave (uint32_t which, bool direct)
if (!zero_line) {
zero_line = new ArdourCanvas::SimpleLine (*group);
zero_line->property_x1() = (gdouble) 1.0;
- zero_line->property_x2() = (gdouble) (_region.length() / samples_per_unit) - 1.0;
+ zero_line->property_x2() = (gdouble) (_region->length() / samples_per_unit) - 1.0;
zero_line->property_color_rgba() = (guint) color_map[cZeroLine];
manage_zero_line ();
}
@@ -886,7 +886,7 @@ AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
jack_nframes_t fx = trackview.editor.pixel_to_frame (x);
- if (fx > _region.length()) {
+ if (fx > _region->length()) {
return;
}
@@ -899,20 +899,20 @@ AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
gain_line->view_to_model_y (y);
trackview.session().begin_reversible_command (_("add gain control point"));
- XMLNode &before = audio_region().envelope().get_state();
+ XMLNode &before = audio_region()->envelope().get_state();
- if (!audio_region().envelope_active()) {
- XMLNode &before = audio_region().get_state();
- audio_region().set_envelope_active(true);
- XMLNode &after = audio_region().get_state();
- trackview.session().add_command (new MementoCommand<AudioRegion>(audio_region(), &before, &after));
+ if (!audio_region()->envelope_active()) {
+ XMLNode &before = audio_region()->get_state();
+ audio_region()->set_envelope_active(true);
+ XMLNode &after = audio_region()->get_state();
+ trackview.session().add_command (new MementoCommand<AudioRegion>(*(audio_region().get()), &before, &after));
}
- audio_region().envelope().add (fx, y);
+ audio_region()->envelope().add (fx, y);
- XMLNode &after = audio_region().envelope().get_state();
- trackview.session().add_command (new MementoCommand<Curve>(audio_region().envelope(), &before, &after));
+ XMLNode &after = audio_region()->envelope().get_state();
+ trackview.session().add_command (new MementoCommand<Curve>(audio_region()->envelope(), &before, &after));
trackview.session().commit_reversible_command ();
}
@@ -920,7 +920,7 @@ void
AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
{
ControlPoint *cp = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"));
- audio_region().envelope().erase (cp->model);
+ audio_region()->envelope().erase (cp->model);
}
void
@@ -931,7 +931,7 @@ AudioRegionView::store_flags()
node->add_property ("waveform-visible", (_flags & WaveformVisible) ? "yes" : "no");
node->add_property ("envelope-visible", (_flags & EnvelopeVisible) ? "yes" : "no");
- _region.add_extra_xml (*node);
+ _region->add_extra_xml (*node);
}
void
@@ -998,7 +998,7 @@ AudioRegionView::add_ghost (AutomationTimeAxisView& atv)
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&trackview);
assert(rtv);
- double unit_position = _region.position () / samples_per_unit;
+ double unit_position = _region->position () / samples_per_unit;
GhostRegion* ghost = new GhostRegion (atv, unit_position);
uint32_t nchans;
@@ -1006,13 +1006,13 @@ AudioRegionView::add_ghost (AutomationTimeAxisView& atv)
for (uint32_t n = 0; n < nchans; ++n) {
- if (n >= audio_region().n_channels()) {
+ if (n >= audio_region()->n_channels()) {
break;
}
WaveView *wave = new WaveView(*ghost->group);
- wave->property_data_src() = &_region;
+ wave->property_data_src() = _region.get();
wave->property_cache() = wave_caches[n];
wave->property_cache_updater() = false;
wave->property_channel() = n;
@@ -1023,13 +1023,13 @@ AudioRegionView::add_ghost (AutomationTimeAxisView& atv)
wave->property_samples_per_unit() = samples_per_unit;
wave->property_amplitude_above_axis() = _amplitude_above_axis;
wave->property_wave_color() = color_map[cGhostTrackWave];
- wave->property_region_start() = _region.start();
+ wave->property_region_start() = _region->start();
ghost->waves.push_back(wave);
}
ghost->set_height ();
- ghost->set_duration (_region.length() / samples_per_unit);
+ ghost->set_duration (_region->length() / samples_per_unit);
ghosts.push_back (ghost);
ghost->GoingAway.connect (mem_fun(*this, &AudioRegionView::remove_ghost));
@@ -1075,7 +1075,7 @@ void
AudioRegionView::envelope_active_changed ()
{
if (gain_line) {
- gain_line->set_line_color (audio_region().envelope_active() ? color_map[cGainLine] : color_map[cGainLineInactive]);
+ gain_line->set_line_color (audio_region()->envelope_active() ? color_map[cGainLine] : color_map[cGainLineInactive]);
}
}
@@ -1083,11 +1083,11 @@ void
AudioRegionView::set_waveview_data_src()
{
- double unit_length= _region.length() / samples_per_unit;
+ double unit_length= _region->length() / samples_per_unit;
for (uint32_t n = 0; n < waves.size(); ++n) {
// TODO: something else to let it know the channel
- waves[n]->property_data_src() = &_region;
+ waves[n]->property_data_src() = _region.get();
}
for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
@@ -1095,7 +1095,7 @@ AudioRegionView::set_waveview_data_src()
(*i)->set_duration (unit_length);
for (vector<WaveView*>::iterator w = (*i)->waves.begin(); w != (*i)->waves.end(); ++w) {
- (*w)->property_data_src() = &_region;
+ (*w)->property_data_src() = _region.get();
}
}
diff --git a/gtk2_ardour/audio_region_view.h b/gtk2_ardour/audio_region_view.h
index ec3ea6c4c5..1e032e17a4 100644
--- a/gtk2_ardour/audio_region_view.h
+++ b/gtk2_ardour/audio_region_view.h
@@ -51,7 +51,7 @@ class AudioRegionView : public RegionView
public:
AudioRegionView (ArdourCanvas::Group *,
RouteTimeAxisView&,
- ARDOUR::AudioRegion&,
+ boost::shared_ptr<ARDOUR::AudioRegion>,
double initial_samples_per_unit,
Gdk::Color& basic_color);
@@ -59,44 +59,44 @@ class AudioRegionView : public RegionView
virtual void init (Gdk::Color& base_color, bool wait_for_data = false);
- ARDOUR::AudioRegion& audio_region() const;
-
- void set_height (double);
- void set_samples_per_unit (double);
-
- void set_amplitude_above_axis (gdouble spp);
-
- void temporarily_hide_envelope (); ///< Dangerous!
- void unhide_envelope (); ///< Dangerous!
-
- void set_envelope_visible (bool);
- void set_waveform_visible (bool yn);
- void set_waveform_shape (WaveformShape);
-
- bool waveform_rectified() const { return _flags & WaveformRectified; }
- bool waveform_visible() const { return _flags & WaveformVisible; }
- bool envelope_visible() const { return _flags & EnvelopeVisible; }
-
- void show_region_editor ();
-
- void add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *event);
- void remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent *event);
-
- AudioRegionGainLine* get_gain_line() const { return gain_line; }
-
- void region_changed (ARDOUR::Change);
- void envelope_active_changed ();
-
- GhostRegion* add_ghost (AutomationTimeAxisView&);
-
- void reset_fade_in_shape_width (jack_nframes_t);
- void reset_fade_out_shape_width (jack_nframes_t);
- void set_fade_in_active (bool);
- void set_fade_out_active (bool);
-
- virtual void entered ();
- virtual void exited ();
-
+ boost::shared_ptr<ARDOUR::AudioRegion> audio_region() const;
+
+ void set_height (double);
+ void set_samples_per_unit (double);
+
+ void set_amplitude_above_axis (gdouble spp);
+
+ void temporarily_hide_envelope (); ///< Dangerous!
+ void unhide_envelope (); ///< Dangerous!
+
+ void set_envelope_visible (bool);
+ void set_waveform_visible (bool yn);
+ void set_waveform_shape (WaveformShape);
+
+ bool waveform_rectified() const { return _flags & WaveformRectified; }
+ bool waveform_visible() const { return _flags & WaveformVisible; }
+ bool envelope_visible() const { return _flags & EnvelopeVisible; }
+
+ void show_region_editor ();
+
+ void add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *event);
+ void remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent *event);
+
+ AudioRegionGainLine* get_gain_line() const { return gain_line; }
+
+ void region_changed (ARDOUR::Change);
+ void envelope_active_changed ();
+
+ GhostRegion* add_ghost (AutomationTimeAxisView&);
+
+ void reset_fade_in_shape_width (jack_nframes_t);
+ void reset_fade_out_shape_width (jack_nframes_t);
+ void set_fade_in_active (bool);
+ void set_fade_out_active (bool);
+
+ virtual void entered ();
+ virtual void exited ();
+
protected:
/* this constructor allows derived types
@@ -105,11 +105,11 @@ class AudioRegionView : public RegionView
*/
AudioRegionView (ArdourCanvas::Group *,
- RouteTimeAxisView&,
- ARDOUR::AudioRegion&,
- double samples_per_unit,
- Gdk::Color& basic_color,
- TimeAxisViewItem::Visibility);
+ RouteTimeAxisView&,
+ boost::shared_ptr<ARDOUR::AudioRegion>,
+ double samples_per_unit,
+ Gdk::Color& basic_color,
+ TimeAxisViewItem::Visibility);
enum Flags {
EnvelopeVisible = 0x1,
diff --git a/gtk2_ardour/audio_regionview.cc b/gtk2_ardour/audio_regionview.cc
index e2d20c0cc0..f9fb43f641 100644
--- a/gtk2_ardour/audio_regionview.cc
+++ b/gtk2_ardour/audio_regionview.cc
@@ -360,7 +360,7 @@ AudioRegionView::region_scale_amplitude_changed ()
for (uint32_t n = 0; n < waves.size(); ++n) {
// force a reload of the cache
- waves[n]->property_data_src() = &region;
+ waves[n]->property_data_src() = region.get();
}
}
@@ -1044,7 +1044,7 @@ AudioRegionView::create_one_wave (uint32_t which, bool direct)
WaveView *wave = new WaveView(*group);
- wave->property_data_src() = (gpointer) &region;
+ wave->property_data_src() = (gpointer) region.get()
wave->property_cache() = wave_caches[which];
wave->property_cache_updater() = true;
wave->property_channel() = which;
@@ -1269,7 +1269,7 @@ AudioRegionView::add_ghost (AutomationTimeAxisView& atv)
WaveView *wave = new WaveView(*ghost->group);
- wave->property_data_src() = &region;
+ wave->property_data_src() = region.get();
wave->property_cache() = wave_caches[n];
wave->property_cache_updater() = false;
wave->property_channel() = n;
@@ -1365,7 +1365,7 @@ AudioRegionView::set_waveview_data_src()
for (uint32_t n = 0; n < waves.size(); ++n) {
// TODO: something else to let it know the channel
- waves[n]->property_data_src() = &region;
+ waves[n]->property_data_src() = region.get();
}
for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
@@ -1373,7 +1373,7 @@ AudioRegionView::set_waveview_data_src()
(*i)->set_duration (unit_length);
for (vector<WaveView*>::iterator w = (*i)->waves.begin(); w != (*i)->waves.end(); ++w) {
- (*w)->property_data_src() = &region;
+ (*w)->property_data_src() = region.get();
}
}
diff --git a/gtk2_ardour/audio_streamview.cc b/gtk2_ardour/audio_streamview.cc
index d650df1563..c0b3ba4c39 100644
--- a/gtk2_ardour/audio_streamview.cc
+++ b/gtk2_ardour/audio_streamview.cc
@@ -30,6 +30,7 @@
#include <ardour/audio_track.h>
#include <ardour/playlist_templates.h>
#include <ardour/source.h>
+#include <ardour/region_factory.h>
#include "audio_streamview.h"
#include "audio_region_view.h"
@@ -124,11 +125,11 @@ AudioStreamView::set_amplitude_above_axis (gdouble app)
}
void
-AudioStreamView::add_region_view_internal (Region *r, bool wait_for_waves)
+AudioStreamView::add_region_view_internal (boost::shared_ptr<Region> r, bool wait_for_waves)
{
ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::add_region_view), r));
- AudioRegion* region = dynamic_cast<AudioRegion*> (r);
+ boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion> (r);
if (region == 0) {
return;
@@ -138,7 +139,7 @@ AudioStreamView::add_region_view_internal (Region *r, bool wait_for_waves)
list<RegionView *>::iterator i;
for (i = region_views.begin(); i != region_views.end(); ++i) {
- if (&(*i)->region() == r) {
+ if ((*i)->region() == r) {
/* great. we already have a AudioRegionView for this Region. use it again. */
@@ -149,11 +150,11 @@ AudioStreamView::add_region_view_internal (Region *r, bool wait_for_waves)
switch (_trackview.audio_track()->mode()) {
case Normal:
- region_view = new AudioRegionView (canvas_group, _trackview, *region,
+ region_view = new AudioRegionView (canvas_group, _trackview, region,
_samples_per_unit, region_color);
break;
case Destructive:
- region_view = new TapeAudioRegionView (canvas_group, _trackview, *region,
+ region_view = new TapeAudioRegionView (canvas_group, _trackview, region,
_samples_per_unit, region_color);
break;
}
@@ -168,13 +169,13 @@ AudioStreamView::add_region_view_internal (Region *r, bool wait_for_waves)
/* catch regionview going away */
- region->GoingAway.connect (mem_fun (*this, &AudioStreamView::remove_region_view));
+ region->GoingAway.connect (bind (mem_fun (*this, &AudioStreamView::remove_region_view), region));
RegionViewAdded (region_view);
}
void
-AudioStreamView::remove_region_view (Region *r)
+AudioStreamView::remove_region_view (boost::shared_ptr<Region> r)
{
ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::remove_region_view), r));
@@ -184,8 +185,8 @@ AudioStreamView::remove_region_view (Region *r)
tmp = i;
++tmp;
- AudioRegion* ar = dynamic_cast<AudioRegion*>(r);
- if (ar && (*i)->crossfade.involves (*ar)) {
+ boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion>(r);
+ if (ar && (*i)->crossfade.involves (ar)) {
delete *i;
crossfade_views.erase (i);
}
@@ -263,10 +264,10 @@ AudioStreamView::add_crossfade (Crossfade *crossfade)
for (list<RegionView *>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
AudioRegionView* arv = dynamic_cast<AudioRegionView*>(*i);
- if (!lview && arv && &(arv->region()) == &crossfade->out()) {
+ if (!lview && arv && (arv->region() == crossfade->out())) {
lview = arv;
}
- if (!rview && arv && &(arv->region()) == &crossfade->in()) {
+ if (!rview && arv && (arv->region() == crossfade->in())) {
rview = arv;
}
}
@@ -391,7 +392,7 @@ AudioStreamView::setup_rec_box ()
/* add a new region, but don't bother if they set use_rec_regions mid-record */
- AudioRegion::SourceList sources;
+ SourceList sources;
for (list<sigc::connection>::iterator prc = peak_ready_connections.begin(); prc != peak_ready_connections.end(); ++prc) {
(*prc).disconnect();
@@ -417,11 +418,12 @@ AudioStreamView::setup_rec_box ()
start = rec_regions.back()->start() + _trackview.get_diskstream()->get_captured_frames(rec_regions.size()-1);
}
- AudioRegion * region = new AudioRegion(sources, start, 1 , "", 0, (Region::Flag)(Region::DefaultFlags | Region::DoNotSaveState), false);
+ boost::shared_ptr<AudioRegion> region (boost::dynamic_pointer_cast<AudioRegion>
+ (RegionFactory::create (sources, start, 1 , "", 0, (Region::Flag)(Region::DefaultFlags | Region::DoNotSaveState), false)));
region->set_position (_trackview.session().transport_frame(), this);
rec_regions.push_back (region);
/* catch it if it goes away */
- region->GoingAway.connect (mem_fun (*this, &AudioStreamView::remove_rec_region));
+ region->GoingAway.connect (bind (mem_fun (*this, &AudioStreamView::remove_rec_region), region));
/* we add the region later */
}
@@ -502,23 +504,10 @@ AudioStreamView::setup_rec_box ()
last_rec_peak_frame = 0;
/* remove temp regions */
- for (list<Region*>::iterator iter=rec_regions.begin(); iter != rec_regions.end(); )
- {
- list<Region*>::iterator tmp;
-
- tmp = iter;
- ++tmp;
-
- /* this will trigger the remove_region_view */
- delete *iter;
-
- iter = tmp;
- }
rec_regions.clear();
// cerr << "\tclear " << rec_rects.size() << " rec rects\n";
-
/* transport stopped, clear boxes */
for (vector<RecBoxInfo>::iterator iter=rec_rects.begin(); iter != rec_rects.end(); ++iter) {
@@ -566,9 +555,9 @@ AudioStreamView::update_rec_regions ()
uint32_t n = 0;
- for (list<Region*>::iterator iter = rec_regions.begin(); iter != rec_regions.end(); n++) {
+ for (list<boost::shared_ptr<Region> >::iterator iter = rec_regions.begin(); iter != rec_regions.end(); n++) {
- list<Region*>::iterator tmp;
+ list<boost::shared_ptr<Region> >::iterator tmp;
tmp = iter;
++tmp;
@@ -580,7 +569,7 @@ AudioStreamView::update_rec_regions ()
}
// FIXME
- AudioRegion * region = dynamic_cast<AudioRegion*>(*iter);
+ boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion>(*iter);
assert(region);
jack_nframes_t origlen = region->length();
diff --git a/gtk2_ardour/audio_streamview.h b/gtk2_ardour/audio_streamview.h
index edda221bbd..8d5ab4117c 100644
--- a/gtk2_ardour/audio_streamview.h
+++ b/gtk2_ardour/audio_streamview.h
@@ -79,10 +79,10 @@ class AudioStreamView : public StreamView
void rec_peak_range_ready (jack_nframes_t start, jack_nframes_t cnt, ARDOUR::Source* src);
void update_rec_regions ();
- void add_region_view_internal (ARDOUR::Region*, bool wait_for_waves);
- void remove_region_view (ARDOUR::Region* );
- void remove_audio_region_view (ARDOUR::AudioRegion* );
- void remove_audio_rec_region (ARDOUR::AudioRegion*);
+ void add_region_view_internal (boost::shared_ptr<ARDOUR::Region>, bool wait_for_waves);
+ void remove_region_view (boost::shared_ptr<ARDOUR::Region> );
+ void remove_audio_region_view (boost::shared_ptr<ARDOUR::AudioRegion> );
+ void remove_audio_rec_region (boost::shared_ptr<ARDOUR::AudioRegion>);
void undisplay_diskstream ();
void redisplay_diskstream ();
diff --git a/gtk2_ardour/automation_line.h b/gtk2_ardour/automation_line.h
index ec86b7455f..f8262d2a2d 100644
--- a/gtk2_ardour/automation_line.h
+++ b/gtk2_ardour/automation_line.h
@@ -30,7 +30,9 @@
#include <sigc++/signal.h>
#include "canvas.h"
#include "simplerect.h"
+
#include <pbd/undo.h>
+#include <pbd/statefuldestructible.h>
#include <ardour/automation_event.h>
@@ -94,7 +96,7 @@ class ControlPoint
ShapeType _shape;
};
-class AutomationLine : public sigc::trackable, public Stateful
+class AutomationLine : public sigc::trackable, public PBD::StatefulDestructible
{
public:
AutomationLine (const string & name, TimeAxisView&, ArdourCanvas::Group&, ARDOUR::AutomationList&);
diff --git a/gtk2_ardour/crossfade_edit.cc b/gtk2_ardour/crossfade_edit.cc
index b2967dc4a9..a89d4462ae 100644
--- a/gtk2_ardour/crossfade_edit.cc
+++ b/gtk2_ardour/crossfade_edit.cc
@@ -36,6 +36,7 @@
#include <ardour/audioplaylist.h>
#include <ardour/audiosource.h>
#include <ardour/playlist_templates.h>
+#include <ardour/region_factory.h>
#include <gtkmm2ext/gtk_ui.h>
@@ -590,7 +591,7 @@ CrossfadeEditor::canvas_allocation (Gtk::Allocation& alloc)
vector<ArdourCanvas::WaveView*>::iterator i;
uint32_t n;
- ht = canvas->get_allocation().get_height() / xfade.in().n_channels();
+ ht = canvas->get_allocation().get_height() / xfade.in()->n_channels();
for (n = 0, i = fade[In].waves.begin(); i != fade[In].waves.end(); ++i, ++n) {
double yoff;
@@ -602,7 +603,7 @@ CrossfadeEditor::canvas_allocation (Gtk::Allocation& alloc)
(*i)->property_samples_per_unit() = spu;
}
- ht = canvas->get_allocation().get_height() / xfade.out().n_channels();
+ ht = canvas->get_allocation().get_height() / xfade.out()->n_channels();
for (n = 0, i = fade[Out].waves.begin(); i != fade[Out].waves.end(); ++i, ++n) {
double yoff;
@@ -1015,10 +1016,10 @@ CrossfadeEditor::y_coordinate (double& yfract) const
}
void
-CrossfadeEditor::make_waves (AudioRegion& region, WhichFade which)
+CrossfadeEditor::make_waves (boost::shared_ptr<AudioRegion> region, WhichFade which)
{
gdouble ht;
- uint32_t nchans = region.n_channels();
+ uint32_t nchans = region->n_channels();
guint32 color;
double spu;
@@ -1035,11 +1036,11 @@ CrossfadeEditor::make_waves (AudioRegion& region, WhichFade which)
gdouble yoff = n * ht;
- if (region.source(n).peaks_ready (bind (mem_fun(*this, &CrossfadeEditor::peaks_ready), &region, which), peaks_ready_connection)) {
+ if (region->source(n).peaks_ready (bind (mem_fun(*this, &CrossfadeEditor::peaks_ready), region, which), peaks_ready_connection)) {
WaveView* waveview = new WaveView (*(canvas->root()));
- waveview->property_data_src() = &region;
+ waveview->property_data_src() = region.get();
waveview->property_cache_updater() = true;
waveview->property_cache() = WaveView::create_cache();
waveview->property_channel() = n;
@@ -1064,14 +1065,14 @@ CrossfadeEditor::make_waves (AudioRegion& region, WhichFade which)
}
void
-CrossfadeEditor::peaks_ready (AudioRegion* r, WhichFade which)
+CrossfadeEditor::peaks_ready (boost::shared_ptr<AudioRegion> r, WhichFade which)
{
/* this should never be called, because the peak files for an xfade
will be ready by the time we want them. but our API forces us
to provide this, so ..
*/
peaks_ready_connection.disconnect ();
- make_waves (*r, which);
+ make_waves (r, which);
}
void
@@ -1097,29 +1098,29 @@ CrossfadeEditor::audition_both ()
postroll = 0;
}
- if ((left_start_offset = xfade.out().length() - xfade.length()) >= preroll) {
+ if ((left_start_offset = xfade.out()->length() - xfade.length()) >= preroll) {
left_start_offset -= preroll;
}
length = 0;
- if ((left_length = xfade.length()) < xfade.out().length() - left_start_offset) {
+ if ((left_length = xfade.length()) < xfade.out()->length() - left_start_offset) {
length += postroll;
}
right_length = xfade.length();
- if (xfade.in().length() - right_length < postroll) {
+ if (xfade.in()->length() - right_length < postroll) {
right_length += postroll;
}
- AudioRegion* left = new AudioRegion (xfade.out(), left_start_offset, left_length, "xfade out",
- 0, Region::DefaultFlags, false);
- AudioRegion* right = new AudioRegion (xfade.in(), 0, right_length, "xfade in",
- 0, Region::DefaultFlags, false);
+ boost::shared_ptr<AudioRegion> left (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade.out(), left_start_offset, left_length, "xfade out",
+ 0, Region::DefaultFlags, false)));
+ boost::shared_ptr<AudioRegion> right (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade.in(), 0, right_length, "xfade in",
+ 0, Region::DefaultFlags, false)));
- pl.add_region (*left, 0);
- pl.add_region (*right, 1+preroll);
+ pl.add_region (left, 0);
+ pl.add_region (right, 1+preroll);
/* there is only one ... */
@@ -1131,10 +1132,10 @@ CrossfadeEditor::audition_both ()
void
CrossfadeEditor::audition_left_dry ()
{
- AudioRegion* left = new AudioRegion (xfade.out(), xfade.out().length() - xfade.length(), xfade.length(), "xfade left",
- 0, Region::DefaultFlags, false);
+ boost::shared_ptr<AudioRegion> left (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade.out(), xfade.out()->length() - xfade.length(), xfade.length(), "xfade left",
+ 0, Region::DefaultFlags, false)));
- session.audition_region (*left);
+ session.audition_region (left);
}
void
@@ -1142,13 +1143,13 @@ CrossfadeEditor::audition_left ()
{
AudioPlaylist& pl (session.the_auditioner()->prepare_playlist());
- AudioRegion* left = new AudioRegion (xfade.out(), xfade.out().length() - xfade.length(), xfade.length(), "xfade left",
- 0, Region::DefaultFlags, false);
- AudioRegion* right = new AudioRegion (xfade.in(), 0, xfade.length(), "xfade in",
- 0, Region::DefaultFlags, false);
+ boost::shared_ptr<AudioRegion> left (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade.out(), xfade.out()->length() - xfade.length(), xfade.length(), "xfade left",
+ 0, Region::DefaultFlags, false)));
+ boost::shared_ptr<AudioRegion> right (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade.in(), 0, xfade.length(), "xfade in",
+ 0, Region::DefaultFlags, false)));
- pl.add_region (*left, 0);
- pl.add_region (*right, 1);
+ pl.add_region (left, 0);
+ pl.add_region (right, 1);
right->set_muted (true);
@@ -1164,9 +1165,9 @@ CrossfadeEditor::audition_left ()
void
CrossfadeEditor::audition_right_dry ()
{
- AudioRegion* right = new AudioRegion (xfade.in(), 0, xfade.length(), "xfade in",
- 0, Region::DefaultFlags, false);
- session.audition_region (*right);
+ boost::shared_ptr<AudioRegion> right (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade.in(), 0, xfade.length(), "xfade in",
+ 0, Region::DefaultFlags, false)));
+ session.audition_region (right);
}
void
@@ -1174,13 +1175,13 @@ CrossfadeEditor::audition_right ()
{
AudioPlaylist& pl (session.the_auditioner()->prepare_playlist());
- AudioRegion* left = new AudioRegion (xfade.out(), xfade.out().length() - xfade.length(), xfade.length(), "xfade out",
- 0, Region::DefaultFlags, false);
- AudioRegion* right = new AudioRegion (xfade.out(), 0, xfade.length(), "xfade out",
- 0, Region::DefaultFlags, false);
+ boost::shared_ptr<AudioRegion> left (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade.out(), xfade.out()->length() - xfade.length(), xfade.length(), "xfade out",
+ 0, Region::DefaultFlags, false)));
+ boost::shared_ptr<AudioRegion> right (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade.out(), 0, xfade.length(), "xfade out",
+ 0, Region::DefaultFlags, false)));
- pl.add_region (*left, 0);
- pl.add_region (*right, 1);
+ pl.add_region (left, 0);
+ pl.add_region (right, 1);
left->set_muted (true);
diff --git a/gtk2_ardour/crossfade_edit.h b/gtk2_ardour/crossfade_edit.h
index b156ee69fe..ad0661c036 100644
--- a/gtk2_ardour/crossfade_edit.h
+++ b/gtk2_ardour/crossfade_edit.h
@@ -162,8 +162,8 @@ class CrossfadeEditor : public ArdourDialog
sigc::connection peaks_ready_connection;
- void make_waves (ARDOUR::AudioRegion&, WhichFade);
- void peaks_ready (ARDOUR::AudioRegion* r, WhichFade);
+ void make_waves (boost::shared_ptr<ARDOUR::AudioRegion>, WhichFade);
+ void peaks_ready (boost::shared_ptr<ARDOUR::AudioRegion> r, WhichFade);
void _apply_to (ARDOUR::Crossfade* xf);
void setup (ARDOUR::Crossfade*);
diff --git a/gtk2_ardour/crossfade_view.cc b/gtk2_ardour/crossfade_view.cc
index 087af25e73..49fe40ca63 100644
--- a/gtk2_ardour/crossfade_view.cc
+++ b/gtk2_ardour/crossfade_view.cc
@@ -227,7 +227,7 @@ CrossfadeView::set_valid (bool yn)
AudioRegionView&
CrossfadeView::upper_regionview () const
{
- if (left_view.region().layer() > right_view.region().layer()) {
+ if (left_view.region()->layer() > right_view.region()->layer()) {
return left_view;
} else {
return right_view;
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 2be8b2d73b..ce8145fa47 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -246,7 +246,6 @@ Editor::Editor (AudioEngine& eng)
latest_regionview = 0;
last_update_frame = 0;
drag_info.item = 0;
- last_audition_region = 0;
current_mixer_strip = 0;
current_bbt_points = 0;
@@ -1169,7 +1168,7 @@ Editor::connect_to_session (Session *t)
update_title ();
- session->going_away.connect (mem_fun(*this, &Editor::session_going_away));
+ session->GoingAway.connect (mem_fun(*this, &Editor::session_going_away));
/* These signals can all be emitted by a non-GUI thread. Therefore the
handlers for them must not attempt to directly interact with the GUI,
@@ -1399,13 +1398,14 @@ Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* i
}
MenuList& items (fade_context_menu.items());
+ AudioRegion& ar (*arv->audio_region().get()); // FIXME
items.clear ();
switch (item_type) {
case FadeInItem:
case FadeInHandleItem:
- if (arv->audio_region().fade_in_active()) {
+ if (arv->audio_region()->fade_in_active()) {
items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), false)));
} else {
items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), true)));
@@ -1413,16 +1413,16 @@ Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* i
items.push_back (SeparatorElem());
- items.push_back (MenuElem (_("Linear"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_in_shape), AudioRegion::Linear)));
- items.push_back (MenuElem (_("Slowest"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_in_shape), AudioRegion::LogB)));
- items.push_back (MenuElem (_("Slow"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_in_shape), AudioRegion::Fast)));
- items.push_back (MenuElem (_("Fast"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_in_shape), AudioRegion::LogA)));
- items.push_back (MenuElem (_("Fastest"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_in_shape), AudioRegion::Slow)));
+ items.push_back (MenuElem (_("Linear"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::Linear)));
+ items.push_back (MenuElem (_("Slowest"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::LogB)));
+ items.push_back (MenuElem (_("Slow"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::Fast)));
+ items.push_back (MenuElem (_("Fast"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::LogA)));
+ items.push_back (MenuElem (_("Fastest"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::Slow)));
break;
case FadeOutItem:
case FadeOutHandleItem:
- if (arv->audio_region().fade_out_active()) {
+ if (arv->audio_region()->fade_out_active()) {
items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), false)));
} else {
items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), true)));
@@ -1430,11 +1430,11 @@ Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* i
items.push_back (SeparatorElem());
- items.push_back (MenuElem (_("Linear"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_out_shape), AudioRegion::Linear)));
- items.push_back (MenuElem (_("Slowest"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_out_shape), AudioRegion::Fast)));
- items.push_back (MenuElem (_("Slow"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_out_shape), AudioRegion::LogB)));
- items.push_back (MenuElem (_("Fast"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_out_shape), AudioRegion::LogA)));
- items.push_back (MenuElem (_("Fastest"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_out_shape), AudioRegion::Slow)));
+ items.push_back (MenuElem (_("Linear"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::Linear)));
+ items.push_back (MenuElem (_("Slowest"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::Fast)));
+ items.push_back (MenuElem (_("Slow"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::LogB)));
+ items.push_back (MenuElem (_("Fast"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::LogA)));
+ items.push_back (MenuElem (_("Fastest"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::Slow)));
break;
default:
@@ -1501,7 +1501,7 @@ Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type,
case RegionViewNameHighlight:
if (!with_selection) {
if (region_edit_menu_split_item) {
- if (clicked_regionview && clicked_regionview->region().covers (edit_cursor->current_frame)) {
+ if (clicked_regionview && clicked_regionview->region()->covers (edit_cursor->current_frame)) {
ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, true);
} else {
ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, false);
@@ -1736,9 +1736,9 @@ Editor::add_crossfade_context_items (AudioStreamView* view, Crossfade* xfade, Me
}
if (many) {
- str = xfade->out().name();
+ str = xfade->out()->name();
str += "->";
- str += xfade->in().name();
+ str += xfade->in()->name();
} else {
str = _("Crossfade");
}
@@ -1764,17 +1764,17 @@ Editor::xfade_edit_right_region ()
}
void
-Editor::add_region_context_items (AudioStreamView* sv, Region* region, Menu_Helpers::MenuList& edit_items)
+Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr<Region> region, Menu_Helpers::MenuList& edit_items)
{
using namespace Menu_Helpers;
Menu *region_menu = manage (new Menu);
MenuList& items = region_menu->items();
region_menu->set_name ("ArdourContextMenu");
- AudioRegion* ar = 0;
+ boost::shared_ptr<AudioRegion> ar;
if (region) {
- ar = dynamic_cast<AudioRegion*> (region);
+ ar = boost::dynamic_pointer_cast<AudioRegion> (region);
}
/* when this particular menu pops up, make the relevant region
@@ -3015,10 +3015,10 @@ Editor::mapover_audio_tracks (slot<void,AudioTimeAxisView&,uint32_t> sl)
void
Editor::mapped_set_selected_regionview_from_click (RouteTimeAxisView& tv, uint32_t ignored,
- RegionView* basis, vector<RegionView*>* all_equivs)
+ RegionView* basis, vector<RegionView*>* all_equivs)
{
Playlist* pl;
- vector<Region*> results;
+ vector<boost::shared_ptr<Region> > results;
RegionView* marv;
boost::shared_ptr<Diskstream> ds;
@@ -3037,8 +3037,8 @@ Editor::mapped_set_selected_regionview_from_click (RouteTimeAxisView& tv, uint32
pl->get_equivalent_regions (basis->region(), results);
}
- for (vector<Region*>::iterator ir = results.begin(); ir != results.end(); ++ir) {
- if ((marv = tv.view()->find_view (**ir)) != 0) {
+ for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
+ if ((marv = tv.view()->find_view (*ir)) != 0) {
all_equivs->push_back (marv);
}
}
@@ -3138,55 +3138,55 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op,
for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
if (&(*x)->get_time_axis_view() == &clicked_regionview->get_time_axis_view()) {
- if ((*x)->region().last_frame() > last_frame) {
- last_frame = (*x)->region().last_frame();
+ if ((*x)->region()->last_frame() > last_frame) {
+ last_frame = (*x)->region()->last_frame();
}
- if ((*x)->region().first_frame() < first_frame) {
- first_frame = (*x)->region().first_frame();
+ if ((*x)->region()->first_frame() < first_frame) {
+ first_frame = (*x)->region()->first_frame();
}
}
}
/* 2. figure out the boundaries for our search for new objects */
- switch (clicked_regionview->region().coverage (first_frame, last_frame)) {
+ switch (clicked_regionview->region()->coverage (first_frame, last_frame)) {
case OverlapNone:
cerr << "no overlap, first = " << first_frame << " last = " << last_frame << " region = "
- << clicked_regionview->region().first_frame() << " .. " << clicked_regionview->region().last_frame() << endl;
+ << clicked_regionview->region()->first_frame() << " .. " << clicked_regionview->region()->last_frame() << endl;
- if (last_frame < clicked_regionview->region().first_frame()) {
+ if (last_frame < clicked_regionview->region()->first_frame()) {
first_frame = last_frame;
- last_frame = clicked_regionview->region().last_frame();
+ last_frame = clicked_regionview->region()->last_frame();
} else {
last_frame = first_frame;
- first_frame = clicked_regionview->region().first_frame();
+ first_frame = clicked_regionview->region()->first_frame();
}
break;
case OverlapExternal:
cerr << "external overlap, first = " << first_frame << " last = " << last_frame << " region = "
- << clicked_regionview->region().first_frame() << " .. " << clicked_regionview->region().last_frame() << endl;
+ << clicked_regionview->region()->first_frame() << " .. " << clicked_regionview->region()->last_frame() << endl;
- if (last_frame < clicked_regionview->region().first_frame()) {
+ if (last_frame < clicked_regionview->region()->first_frame()) {
first_frame = last_frame;
- last_frame = clicked_regionview->region().last_frame();
+ last_frame = clicked_regionview->region()->last_frame();
} else {
last_frame = first_frame;
- first_frame = clicked_regionview->region().first_frame();
+ first_frame = clicked_regionview->region()->first_frame();
}
break;
case OverlapInternal:
cerr << "internal overlap, first = " << first_frame << " last = " << last_frame << " region = "
- << clicked_regionview->region().first_frame() << " .. " << clicked_regionview->region().last_frame() << endl;
+ << clicked_regionview->region()->first_frame() << " .. " << clicked_regionview->region()->last_frame() << endl;
- if (last_frame < clicked_regionview->region().first_frame()) {
+ if (last_frame < clicked_regionview->region()->first_frame()) {
first_frame = last_frame;
- last_frame = clicked_regionview->region().last_frame();
+ last_frame = clicked_regionview->region()->last_frame();
} else {
last_frame = first_frame;
- first_frame = clicked_regionview->region().first_frame();
+ first_frame = clicked_regionview->region()->first_frame();
}
break;
@@ -3233,7 +3233,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op,
}
void
-Editor::set_selected_regionview_from_region_list (Region& region, Selection::Operation op)
+Editor::set_selected_regionview_from_region_list (boost::shared_ptr<Region> region, Selection::Operation op)
{
vector<RegionView*> all_equivalent_regions;
@@ -3244,7 +3244,7 @@ Editor::set_selected_regionview_from_region_list (Region& region, Selection::Ope
if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
Playlist* pl;
- vector<Region*> results;
+ vector<boost::shared_ptr<Region> > results;
RegionView* marv;
boost::shared_ptr<Diskstream> ds;
@@ -3257,8 +3257,8 @@ Editor::set_selected_regionview_from_region_list (Region& region, Selection::Ope
pl->get_region_list_equivalent_regions (region, results);
}
- for (vector<Region*>::iterator ir = results.begin(); ir != results.end(); ++ir) {
- if ((marv = tatv->view()->find_view (**ir)) != 0) {
+ for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
+ if ((marv = tatv->view()->find_view (*ir)) != 0) {
all_equivalent_regions.push_back (marv);
}
}
@@ -3285,17 +3285,17 @@ Editor::set_selected_regionview_from_region_list (Region& region, Selection::Ope
}
bool
-Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv, Region* r)
+Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv, boost::shared_ptr<Region> r)
{
RegionView* rv;
- Region* ar;
+ boost::shared_ptr<AudioRegion> ar;
- if ((ar = dynamic_cast<Region*> (r)) == 0) {
- return TRUE;
+ if ((ar = boost::dynamic_pointer_cast<AudioRegion> (r)) == 0) {
+ return true;
}
- if ((rv = sv->find_view (*ar)) == 0) {
- return TRUE;
+ if ((rv = sv->find_view (ar)) == 0) {
+ return true;
}
/* don't reset the selection if its something other than
@@ -3303,7 +3303,7 @@ Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv,
*/
if (selection->regions.size() > 1) {
- return TRUE;
+ return true;
}
begin_reversible_command (_("set selected regions"));
@@ -3312,7 +3312,7 @@ Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv,
commit_reversible_command () ;
- return TRUE;
+ return true;
}
void
@@ -3962,7 +3962,7 @@ bool
Editor::audio_region_selection_covers (jack_nframes_t where)
{
for (RegionSelection::iterator a = selection->regions.begin(); a != selection->regions.end(); ++a) {
- if ((*a)->region().covers (where)) {
+ if ((*a)->region()->covers (where)) {
return true;
}
}
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index dd62a4dd75..15e0efde11 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -155,9 +155,9 @@ class Editor : public PublicEditor
void scroll_timeaxis_to_imageframe_item(const TimeAxisViewItem* item) ;
TimeAxisView* get_named_time_axis(const string & name) ;
- void consider_auditioning (ARDOUR::Region&);
- void hide_a_region (ARDOUR::Region&);
- void remove_a_region (ARDOUR::Region&);
+ void consider_auditioning (boost::shared_ptr<ARDOUR::Region>);
+ void hide_a_region (boost::shared_ptr<ARDOUR::Region>);
+ void remove_a_region (boost::shared_ptr<ARDOUR::Region>);
/* option editor-access */
@@ -439,8 +439,8 @@ class Editor : public PublicEditor
bool set_selected_track_from_click (bool press, Selection::Operation op = Selection::Set, bool with_undo = true, bool no_remove=false);
bool set_selected_regionview_from_click (bool press, Selection::Operation op = Selection::Set, bool no_track_remove=false);
- void set_selected_regionview_from_region_list (ARDOUR::Region& region, Selection::Operation op = Selection::Set);
- bool set_selected_regionview_from_map_event (GdkEventAny*, StreamView*, ARDOUR::Region*);
+ void set_selected_regionview_from_region_list (boost::shared_ptr<ARDOUR::Region> region, Selection::Operation op = Selection::Set);
+ bool set_selected_regionview_from_map_event (GdkEventAny*, StreamView*, boost::shared_ptr<ARDOUR::Region>);
void collect_new_region_view (RegionView *);
Gtk::Menu track_context_menu;
@@ -462,7 +462,7 @@ class Editor : public PublicEditor
Gtk::Menu* build_track_selection_context_menu (jack_nframes_t);
void add_dstream_context_items (Gtk::Menu_Helpers::MenuList&);
void add_bus_context_items (Gtk::Menu_Helpers::MenuList&);
- void add_region_context_items (AudioStreamView*, ARDOUR::Region*, Gtk::Menu_Helpers::MenuList&);
+ void add_region_context_items (AudioStreamView*, boost::shared_ptr<ARDOUR::Region>, Gtk::Menu_Helpers::MenuList&);
void add_crossfade_context_items (AudioStreamView*, ARDOUR::Crossfade*, Gtk::Menu_Helpers::MenuList&, bool many);
void add_selection_context_items (Gtk::Menu_Helpers::MenuList&);
@@ -630,7 +630,7 @@ class Editor : public PublicEditor
void select_all_selectables_using_cursor (Cursor *, bool);
void select_all_selectables_between_cursors (Cursor *, Cursor *);
- ARDOUR::Region* find_next_region (jack_nframes_t, ARDOUR::RegionPoint, int32_t dir, TrackViewList&, TimeAxisView ** = 0);
+ boost::shared_ptr<ARDOUR::Region> find_next_region (jack_nframes_t, ARDOUR::RegionPoint, int32_t dir, TrackViewList&, TimeAxisView ** = 0);
vector<jack_nframes_t> region_boundary_cache;
void build_region_boundary_cache ();
@@ -698,7 +698,7 @@ class Editor : public PublicEditor
add (color_);
}
Gtk::TreeModelColumn<Glib::ustring> name;
- Gtk::TreeModelColumn<ARDOUR::Region*> region;
+ Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region> > region;
Gtk::TreeModelColumn<Gdk::Color> color_;
};
@@ -720,7 +720,7 @@ class Editor : public PublicEditor
bool region_list_display_button_press (GdkEventButton *);
bool region_list_display_button_release (GdkEventButton *);
void region_list_clear ();
- void region_list_selection_mapover (sigc::slot<void,ARDOUR::Region&>);
+ void region_list_selection_mapover (sigc::slot<void,boost::shared_ptr<ARDOUR::Region> >);
void build_region_list_menu ();
void show_region_list_display_context_menu (int button, int time);
@@ -832,14 +832,14 @@ class Editor : public PublicEditor
int ensure_cursor (jack_nframes_t* pos);
- void handle_new_audio_region (ARDOUR::AudioRegion *);
- void handle_audio_region_removed (ARDOUR::AudioRegion *);
- void add_audio_region_to_region_display (ARDOUR::AudioRegion *);
- void region_hidden (ARDOUR::Region*);
+ void handle_new_audio_region (boost::shared_ptr<ARDOUR::AudioRegion>);
+ void handle_audio_region_removed (boost::shared_ptr<ARDOUR::AudioRegion>);
+ void add_audio_region_to_region_display (boost::shared_ptr<ARDOUR::AudioRegion>);
+ void region_hidden (boost::shared_ptr<ARDOUR::Region>);
void redisplay_regions ();
- void insert_into_tmp_audio_regionlist(ARDOUR::AudioRegion *);
+ void insert_into_tmp_audio_regionlist(boost::shared_ptr<ARDOUR::AudioRegion>);
- list<ARDOUR::AudioRegion *> tmp_audio_region_list;
+ list<boost::shared_ptr<ARDOUR::AudioRegion> > tmp_audio_region_list;
void cut_copy (Editing::CutCopyOp);
void cut_copy_points (Editing::CutCopyOp);
@@ -862,13 +862,13 @@ class Editor : public PublicEditor
void split_region_at (jack_nframes_t);
void split_regions_at (jack_nframes_t, RegionSelection&);
void crop_region_to_selection ();
- void set_a_regions_sync_position (ARDOUR::Region&, jack_nframes_t);
+ void set_a_regions_sync_position (boost::shared_ptr<ARDOUR::Region>, jack_nframes_t);
void set_region_sync_from_edit_cursor ();
void remove_region_sync();
void align_selection (ARDOUR::RegionPoint, jack_nframes_t position);
void align_selection_relative (ARDOUR::RegionPoint point, jack_nframes_t position);
- void align_region (ARDOUR::Region&, ARDOUR::RegionPoint point, jack_nframes_t position);
- void align_region_internal (ARDOUR::Region&, ARDOUR::RegionPoint point, jack_nframes_t position);
+ void align_region (boost::shared_ptr<ARDOUR::Region>, ARDOUR::RegionPoint point, jack_nframes_t position);
+ void align_region_internal (boost::shared_ptr<ARDOUR::Region>, ARDOUR::RegionPoint point, jack_nframes_t position);
void remove_some_regions ();
void remove_clicked_region ();
void destroy_clicked_region ();
@@ -878,8 +878,8 @@ class Editor : public PublicEditor
void region_fill_selection ();
void region_fill_track ();
- void audition_playlist_region_standalone (ARDOUR::Region&);
- void audition_playlist_region_via_route (ARDOUR::Region&, ARDOUR::Route&);
+ void audition_playlist_region_standalone (boost::shared_ptr<ARDOUR::Region>);
+ void audition_playlist_region_via_route (boost::shared_ptr<ARDOUR::Region>, ARDOUR::Route&);
void split_multichannel_region();
void reverse_region ();
void normalize_region ();
@@ -906,7 +906,7 @@ class Editor : public PublicEditor
void keyboard_insert_region_list_selection ();
void region_from_selection ();
- void create_region_from_selection (std::vector<ARDOUR::AudioRegion*>&);
+ void create_region_from_selection (std::vector<boost::shared_ptr<ARDOUR::AudioRegion> >&);
bool region_renamed;
void rename_region ();
@@ -932,7 +932,7 @@ class Editor : public PublicEditor
void amplitude_zoom (gdouble scale);
void amplitude_zoom_step (bool in);
- void insert_region_list_drag (ARDOUR::AudioRegion&, int x, int y);
+ void insert_region_list_drag (boost::shared_ptr<ARDOUR::AudioRegion>, int x, int y);
void insert_region_list_selection (float times);
void add_external_audio_action (Editing::ImportMode);
@@ -943,7 +943,7 @@ class Editor : public PublicEditor
int import_sndfile (Glib::ustring path, Editing::ImportMode mode, ARDOUR::AudioTrack* track, jack_nframes_t& pos);
int embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool& check_sample_rate, Editing::ImportMode mode,
ARDOUR::AudioTrack* track, jack_nframes_t& pos, bool prompt);
- int finish_bringing_in_audio (ARDOUR::AudioRegion& region, uint32_t, uint32_t, ARDOUR::AudioTrack* track, jack_nframes_t& pos, Editing::ImportMode mode);
+ int finish_bringing_in_audio (boost::shared_ptr<ARDOUR::AudioRegion> region, uint32_t, uint32_t, ARDOUR::AudioTrack* track, jack_nframes_t& pos, Editing::ImportMode mode);
/* generic interthread progress window */
@@ -1026,7 +1026,7 @@ class Editor : public PublicEditor
bool have_pending_keyboard_selection;
jack_nframes_t pending_keyboard_selection_start;
- ARDOUR::Region* select_region_for_operation (int dir, TimeAxisView **tv);
+ boost::shared_ptr<ARDOUR::Region> select_region_for_operation (int dir, TimeAxisView **tv);
void extend_selection_to_end_of_region (bool next);
void extend_selection_to_start_of_region (bool previous);
@@ -1585,7 +1585,7 @@ class Editor : public PublicEditor
void export_range_markers ();
int write_region_selection(RegionSelection&);
- bool write_region (string path, ARDOUR::AudioRegion&);
+ bool write_region (string path, boost::shared_ptr<ARDOUR::AudioRegion>);
void export_region ();
void bounce_region_selection ();
void bounce_range_selection ();
@@ -1628,7 +1628,7 @@ class Editor : public PublicEditor
void instant_save ();
- ARDOUR::AudioRegion* last_audition_region;
+ boost::shared_ptr<ARDOUR::AudioRegion> last_audition_region;
/* freeze operations */
diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc
index 71e28c9a1d..ebff933514 100644
--- a/gtk2_ardour/editor_audio_import.cc
+++ b/gtk2_ardour/editor_audio_import.cc
@@ -31,6 +31,7 @@
#include <ardour/audio_track.h>
#include <ardour/audioplaylist.h>
#include <ardour/audiofilesource.h>
+#include <ardour/region_factory.h>
#include <pbd/memento_command.h>
#include "ardour_ui.h"
@@ -176,8 +177,8 @@ Editor::import_sndfile (Glib::ustring path, ImportMode mode, AudioTrack* track,
/* import thread finished - see if we should build a new track */
if (!import_status.new_regions.empty()) {
- AudioRegion& region (*import_status.new_regions.front());
- finish_bringing_in_audio (region, region.n_channels(), region.n_channels(), track, pos, mode);
+ boost::shared_ptr<AudioRegion> region (import_status.new_regions.front());
+ finish_bringing_in_audio (region, region->n_channels(), region->n_channels(), track, pos, mode);
}
track_canvas.get_window()->set_cursor (*current_canvas_cursor);
@@ -189,8 +190,8 @@ Editor::embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool
AudioTrack* track, jack_nframes_t& pos, bool prompt)
{
AudioFileSource *source = 0; /* keep g++ quiet */
- AudioRegion::SourceList sources;
- AudioRegion* region;
+ SourceList sources;
+ boost::shared_ptr<AudioRegion> region;
string idspec;
string linked_path;
SoundFileInfo finfo;
@@ -287,18 +288,18 @@ Editor::embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool
region_name = PBD::basename_nosuffix (path);
region_name += "-0";
- region = new AudioRegion (sources, 0, sources[0]->length(), region_name, 0,
- Region::Flag (Region::DefaultFlags|Region::WholeFile|Region::External));
+ region = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (sources, 0, sources[0]->length(), region_name, 0,
+ Region::Flag (Region::DefaultFlags|Region::WholeFile|Region::External)));
input_chan = finfo.channels;
-
+
if (session->get_output_auto_connect() & Session::AutoConnectMaster) {
output_chan = (session->master_out() ? session->master_out()->n_inputs() : input_chan);
} else {
output_chan = input_chan;
}
- finish_bringing_in_audio (*region, input_chan, output_chan, track, pos, mode);
+ finish_bringing_in_audio (region, input_chan, output_chan, track, pos, mode);
out:
track_canvas.get_window()->set_cursor (*current_canvas_cursor);
@@ -306,10 +307,8 @@ Editor::embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool
}
int
-Editor::finish_bringing_in_audio (AudioRegion& region, uint32_t in_chans, uint32_t out_chans, AudioTrack* track, jack_nframes_t& pos, ImportMode mode)
+Editor::finish_bringing_in_audio (boost::shared_ptr<AudioRegion> region, uint32_t in_chans, uint32_t out_chans, AudioTrack* track, jack_nframes_t& pos, ImportMode mode)
{
- AudioRegion* copy;
-
switch (mode) {
case ImportAsRegion:
/* relax, its been done */
@@ -319,14 +318,14 @@ Editor::finish_bringing_in_audio (AudioRegion& region, uint32_t in_chans, uint32
if (track) {
Playlist* playlist = track->diskstream()->playlist();
- AudioRegion* copy = new AudioRegion (region);
+ boost::shared_ptr<AudioRegion> copy (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (region)));
begin_reversible_command (_("insert sndfile"));
XMLNode &before = playlist->get_state();
- playlist->add_region (*copy, pos);
+ playlist->add_region (copy, pos);
session->add_command (new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
commit_reversible_command ();
- pos += region.length();
+ pos += region->length();
}
break;
@@ -334,8 +333,8 @@ Editor::finish_bringing_in_audio (AudioRegion& region, uint32_t in_chans, uint32
{
list<boost::shared_ptr<AudioTrack> > at (session->new_audio_track (in_chans, out_chans, Normal, 1));
if (!at.empty()) {
- copy = new AudioRegion (region);
- at.front()->diskstream()->playlist()->add_region (*copy, pos);
+ boost::shared_ptr<AudioRegion> copy (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (region)));
+ at.front()->diskstream()->playlist()->add_region (copy, pos);
}
break;
}
@@ -344,8 +343,8 @@ Editor::finish_bringing_in_audio (AudioRegion& region, uint32_t in_chans, uint32
{
list<boost::shared_ptr<AudioTrack> > at (session->new_audio_track (in_chans, out_chans, Destructive));
if (!at.empty()) {
- copy = new AudioRegion (region);
- at.front()->diskstream()->playlist()->add_region (*copy, pos);
+ boost::shared_ptr<AudioRegion> copy (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (region)));
+ at.front()->diskstream()->playlist()->add_region (copy, pos);
}
break;
}
diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc
index 39066dda72..632dadd60a 100644
--- a/gtk2_ardour/editor_canvas.cc
+++ b/gtk2_ardour/editor_canvas.cc
@@ -485,11 +485,11 @@ Editor::drop_regions (const RefPtr<Gdk::DragContext>& context,
for (uint32_t i = 0; i < sr->cnt; ++i) {
- Region* r = reinterpret_cast<Region*> (sr->ptr[i]);
- AudioRegion* ar;
+ boost::shared_ptr<Region> r (reinterpret_cast<Region*> (sr->ptr[i]));
+ boost::shared_ptr<AudioRegion> ar;
- if ((ar = dynamic_cast<AudioRegion*>(r)) != 0) {
- insert_region_list_drag (*ar, x, y);
+ if ((ar = boost::dynamic_pointer_cast<AudioRegion>(r)) != 0) {
+ insert_region_list_drag (ar, x, y);
}
}
diff --git a/gtk2_ardour/editor_canvas_events.cc b/gtk2_ardour/editor_canvas_events.cc
index 8e635bbe13..79bc146519 100644
--- a/gtk2_ardour/editor_canvas_events.cc
+++ b/gtk2_ardour/editor_canvas_events.cc
@@ -468,7 +468,7 @@ Editor::canvas_fade_out_handle_event (GdkEvent *event, ArdourCanvas::Item* item,
}
struct DescendingRegionLayerSorter {
- bool operator()(Region* a, Region* b) {
+ bool operator()(boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
return a->layer() > b->layer();
}
};
@@ -522,7 +522,7 @@ Editor::canvas_crossfade_view_event (GdkEvent* event, ArdourCanvas::Item* item,
DescendingRegionLayerSorter cmp;
rl->sort (cmp);
- RegionView* rv = atv->view()->find_view (*rl->front());
+ RegionView* rv = atv->view()->find_view (rl->front());
/* proxy */
diff --git a/gtk2_ardour/editor_export_audio.cc b/gtk2_ardour/editor_export_audio.cc
index 865796a1ed..6eeff78d84 100644
--- a/gtk2_ardour/editor_export_audio.cc
+++ b/gtk2_ardour/editor_export_audio.cc
@@ -92,12 +92,12 @@ Editor::export_region ()
return;
}
- ExportDialog* dialog = new ExportRegionDialog (*this, &clicked_regionview->region());
+ ExportDialog* dialog = new ExportRegionDialog (*this, clicked_regionview->region());
dialog->connect_to_session (session);
dialog->set_range (
- clicked_regionview->region().first_frame(),
- clicked_regionview->region().last_frame());
+ clicked_regionview->region()->first_frame(),
+ clicked_regionview->region()->last_frame());
dialog->start_export();
}
@@ -140,7 +140,7 @@ Editor::bounce_region_selection ()
{
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
- Region& region ((*i)->region());
+ boost::shared_ptr<Region> region ((*i)->region());
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&(*i)->get_time_axis_view());
Track* track = dynamic_cast<Track*>(rtv->route().get());
@@ -150,12 +150,12 @@ Editor::bounce_region_selection ()
itt.cancel = false;
itt.progress = 0.0f;
- track->bounce_range (region.position(), region.position() + region.length(), itt);
+ track->bounce_range (region->position(), region->position() + region->length(), itt);
}
}
bool
-Editor::write_region (string path, AudioRegion& region)
+Editor::write_region (string path, boost::shared_ptr<AudioRegion> region)
{
AudioFileSource* fs;
const jack_nframes_t chunk_size = 4096;
@@ -168,11 +168,11 @@ Editor::write_region (string path, AudioRegion& region)
vector<AudioFileSource *> sources;
uint32_t nchans;
- nchans = region.n_channels();
+ nchans = region->n_channels();
/* don't do duplicate of the entire source if that's what is going on here */
- if (region.start() == 0 && region.length() == region.source().length()) {
+ if (region->start() == 0 && region->length() == region->source().length()) {
/* XXX should link(2) to create a new inode with "path" */
return true;
}
@@ -184,11 +184,11 @@ Editor::write_region (string path, AudioRegion& region)
for (cnt = 0; cnt < 999999; ++cnt) {
if (nchans == 1) {
snprintf (s, sizeof(s), "%s/%s_%" PRIu32 ".wav", session->sound_dir().c_str(),
- legalize_for_path(region.name()).c_str(), cnt);
+ legalize_for_path(region->name()).c_str(), cnt);
}
else {
snprintf (s, sizeof(s), "%s/%s_%" PRIu32 "-%" PRId32 ".wav", session->sound_dir().c_str(),
- legalize_for_path(region.name()).c_str(), cnt, n);
+ legalize_for_path(region->name()).c_str(), cnt, n);
}
path = s;
@@ -221,8 +221,8 @@ Editor::write_region (string path, AudioRegion& region)
}
- to_read = region.length();
- pos = region.position();
+ to_read = region->length();
+ pos = region->position();
while (to_read) {
jack_nframes_t this_time;
@@ -233,7 +233,7 @@ Editor::write_region (string path, AudioRegion& region)
fs = (*src);
- if (region.read_at (buf, buf, gain_buffer, pos, this_time) != this_time) {
+ if (region->read_at (buf, buf, gain_buffer, pos, this_time) != this_time) {
break;
}
diff --git a/gtk2_ardour/editor_keyboard.cc b/gtk2_ardour/editor_keyboard.cc
index 95289c7f5a..e9ccd26f46 100644
--- a/gtk2_ardour/editor_keyboard.cc
+++ b/gtk2_ardour/editor_keyboard.cc
@@ -103,12 +103,12 @@ Editor::kbd_mute_unmute_region ()
{
if (entered_regionview) {
begin_reversible_command (_("mute region"));
- XMLNode &before = entered_regionview->region().playlist()->get_state();
+ XMLNode &before = entered_regionview->region()->playlist()->get_state();
- entered_regionview->region().set_muted (!entered_regionview->region().muted());
+ entered_regionview->region()->set_muted (!entered_regionview->region()->muted());
- XMLNode &after = entered_regionview->region().playlist()->get_state();
- session->add_command (new MementoCommand<ARDOUR::Playlist>(*(entered_regionview->region().playlist()), &before, &after));
+ XMLNode &after = entered_regionview->region()->playlist()->get_state();
+ session->add_command (new MementoCommand<ARDOUR::Playlist>(*(entered_regionview->region()->playlist()), &before, &after));
commit_reversible_command();
}
}
diff --git a/gtk2_ardour/editor_mixer.cc b/gtk2_ardour/editor_mixer.cc
index 246dbdc647..c15c4f6094 100644
--- a/gtk2_ardour/editor_mixer.cc
+++ b/gtk2_ardour/editor_mixer.cc
@@ -255,7 +255,6 @@ Editor::session_going_away ()
latest_regionview = 0;
last_update_frame = 0;
drag_info.item = 0;
- last_audition_region = 0;
last_canvas_frame = 0;
/* hide all tracks */
diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc
index db42e0c414..62f7d7be0d 100644
--- a/gtk2_ardour/editor_mouse.cc
+++ b/gtk2_ardour/editor_mouse.cc
@@ -1751,7 +1751,7 @@ Editor::start_fade_in_grab (ArdourCanvas::Item* item, GdkEvent* event)
AudioRegionView* arv = static_cast<AudioRegionView*>(drag_info.data);
- drag_info.pointer_frame_offset = drag_info.grab_frame - ((jack_nframes_t) arv->audio_region().fade_in().back()->when + arv->region().position());
+ drag_info.pointer_frame_offset = drag_info.grab_frame - ((jack_nframes_t) arv->audio_region()->fade_in().back()->when + arv->region()->position());
}
void
@@ -1772,17 +1772,17 @@ Editor::fade_in_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
snap_to (pos);
}
- if (pos < (arv->region().position() + 64)) {
+ if (pos < (arv->region()->position() + 64)) {
fade_length = 64; // this should be a minimum defined somewhere
- } else if (pos > arv->region().last_frame()) {
- fade_length = arv->region().length();
+ } else if (pos > arv->region()->last_frame()) {
+ fade_length = arv->region()->length();
} else {
- fade_length = pos - arv->region().position();
+ fade_length = pos - arv->region()->position();
}
arv->reset_fade_in_shape_width (fade_length);
- show_verbose_duration_cursor (arv->region().position(), arv->region().position() + fade_length, 10);
+ show_verbose_duration_cursor (arv->region()->position(), arv->region()->position() + fade_length, 10);
drag_info.first_move = false;
}
@@ -1807,25 +1807,23 @@ Editor::fade_in_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* even
snap_to (pos);
}
- if (pos < (arv->region().position() + 64)) {
+ if (pos < (arv->region()->position() + 64)) {
fade_length = 64; // this should be a minimum defined somewhere
}
- else if (pos > arv->region().last_frame()) {
- fade_length = arv->region().length();
+ else if (pos > arv->region()->last_frame()) {
+ fade_length = arv->region()->length();
}
else {
- fade_length = pos - arv->region().position();
+ fade_length = pos - arv->region()->position();
}
begin_reversible_command (_("change fade in length"));
- XMLNode &before = arv->audio_region().get_state();
+ XMLNode &before = arv->audio_region()->get_state();
- arv->audio_region().set_fade_in_length (fade_length);
+ arv->audio_region()->set_fade_in_length (fade_length);
- XMLNode &after = arv->audio_region().get_state();
- session->add_command(new MementoCommand<ARDOUR::AudioRegion>(arv->audio_region(),
- &before,
- &after));
+ XMLNode &after = arv->audio_region()->get_state();
+ session->add_command(new MementoCommand<ARDOUR::AudioRegion>(*arv->audio_region().get(), &before, &after));
commit_reversible_command ();
fade_in_drag_motion_callback (item, event);
}
@@ -1846,7 +1844,7 @@ Editor::start_fade_out_grab (ArdourCanvas::Item* item, GdkEvent* event)
AudioRegionView* arv = static_cast<AudioRegionView*>(drag_info.data);
- drag_info.pointer_frame_offset = drag_info.grab_frame - (arv->region().length() - (jack_nframes_t) arv->audio_region().fade_out().back()->when + arv->region().position());
+ drag_info.pointer_frame_offset = drag_info.grab_frame - (arv->region()->length() - (jack_nframes_t) arv->audio_region()->fade_out().back()->when + arv->region()->position());
}
void
@@ -1867,19 +1865,19 @@ Editor::fade_out_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event
snap_to (pos);
}
- if (pos > (arv->region().last_frame() - 64)) {
+ if (pos > (arv->region()->last_frame() - 64)) {
fade_length = 64; // this should really be a minimum fade defined somewhere
}
- else if (pos < arv->region().position()) {
- fade_length = arv->region().length();
+ else if (pos < arv->region()->position()) {
+ fade_length = arv->region()->length();
}
else {
- fade_length = arv->region().last_frame() - pos;
+ fade_length = arv->region()->last_frame() - pos;
}
arv->reset_fade_out_shape_width (fade_length);
- show_verbose_duration_cursor (arv->region().last_frame() - fade_length, arv->region().last_frame(), 10);
+ show_verbose_duration_cursor (arv->region()->last_frame() - fade_length, arv->region()->last_frame(), 10);
drag_info.first_move = false;
}
@@ -1904,23 +1902,23 @@ Editor::fade_out_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* eve
snap_to (pos);
}
- if (pos > (arv->region().last_frame() - 64)) {
+ if (pos > (arv->region()->last_frame() - 64)) {
fade_length = 64; // this should really be a minimum fade defined somewhere
}
- else if (pos < arv->region().position()) {
- fade_length = arv->region().length();
+ else if (pos < arv->region()->position()) {
+ fade_length = arv->region()->length();
}
else {
- fade_length = arv->region().last_frame() - pos;
+ fade_length = arv->region()->last_frame() - pos;
}
begin_reversible_command (_("change fade out length"));
- XMLNode &before = arv->region().get_state();
+ XMLNode &before = arv->region()->get_state();
- arv->audio_region().set_fade_out_length (fade_length);
+ arv->audio_region()->set_fade_out_length (fade_length);
- XMLNode &after = arv->region().get_state();
- session->add_command(new MementoCommand<ARDOUR::Region>(arv->region(), &before, &after));
+ XMLNode &after = arv->region()->get_state();
+ session->add_command(new MementoCommand<ARDOUR::Region>(*arv->region().get(), &before, &after));
commit_reversible_command ();
fade_out_drag_motion_callback (item, event);
@@ -2685,7 +2683,7 @@ Editor::start_region_grab (ArdourCanvas::Item* item, GdkEvent* event)
speed = tv->get_diskstream()->speed();
}
- drag_info.last_frame_position = (jack_nframes_t) (clicked_regionview->region().position() / speed);
+ drag_info.last_frame_position = (jack_nframes_t) (clicked_regionview->region()->position() / speed);
drag_info.pointer_frame_offset = drag_info.grab_frame - drag_info.last_frame_position;
drag_info.last_trackview = &clicked_regionview->get_time_axis_view();
// we want a move threshold
@@ -2718,7 +2716,7 @@ Editor::start_region_copy_grab (ArdourCanvas::Item* item, GdkEvent* event)
}
drag_info.last_trackview = &clicked_regionview->get_time_axis_view();
- drag_info.last_frame_position = (jack_nframes_t) (clicked_regionview->region().position() / speed);
+ drag_info.last_frame_position = (jack_nframes_t) (clicked_regionview->region()->position() / speed);
drag_info.pointer_frame_offset = drag_info.grab_frame - drag_info.last_frame_position;
// we want a move threshold
drag_info.want_move_threshold = true;
@@ -2749,7 +2747,7 @@ Editor::start_region_brush_grab (ArdourCanvas::Item* item, GdkEvent* event)
speed = tv->get_diskstream()->speed();
}
- drag_info.last_frame_position = (jack_nframes_t) (clicked_regionview->region().position() / speed);
+ drag_info.last_frame_position = (jack_nframes_t) (clicked_regionview->region()->position() / speed);
drag_info.pointer_frame_offset = drag_info.grab_frame - drag_info.last_frame_position;
drag_info.last_trackview = &clicked_regionview->get_time_axis_view();
// we want a move threshold
@@ -2794,7 +2792,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
rv = (*i);
- Playlist* to_playlist = rv->region().playlist();
+ Playlist* to_playlist = rv->region()->playlist();
RouteTimeAxisView* atv = dynamic_cast<RouteTimeAxisView*>(&rv->get_time_axis_view());
insert_result = affected_playlists.insert (to_playlist);
@@ -2809,16 +2807,20 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
/* create a new region with the same name. */
// FIXME: ew. need a (virtual) Region::duplicate() or something?
- Region* newregion = NULL;
- if (dynamic_cast<AudioRegion*>(&rv->region()))
- newregion = new AudioRegion (dynamic_cast<AudioRegion&>(rv->region()));
- assert(newregion);
+
+ boost::shared_ptr<Region> newregion;
+ boost::shared_ptr<Region> ar;
+
+ if ((ar = boost::dynamic_pointer_cast<AudioRegion>(rv->region())) != 0) {
+ newregion = RegionFactory::create (ar);
+ }
+ assert(newregion != 0);
/* if the original region was locked, we don't care */
newregion->set_locked (false);
- to_playlist->add_region (*newregion, (jack_nframes_t) (rv->region().position() * atv->get_diskstream()->speed()));
+ to_playlist->add_region (newregion, (jack_nframes_t) (rv->region()->position() * atv->get_diskstream()->speed()));
c.disconnect ();
@@ -3033,8 +3035,8 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
pending_region_position = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
- sync_offset = rv->region().sync_offset (sync_dir);
- sync_frame = rv->region().adjust_to_sync (pending_region_position);
+ sync_offset = rv->region()->sync_offset (sync_dir);
+ sync_frame = rv->region()->adjust_to_sync (pending_region_position);
/* we snap if the snap modifier is not enabled.
*/
@@ -3053,7 +3055,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
pending_region_position = 0;
}
- if (pending_region_position > max_frames - rv->region().length()) {
+ if (pending_region_position > max_frames - rv->region()->length()) {
pending_region_position = drag_info.last_frame_position;
}
@@ -3202,8 +3204,8 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
if (-x_delta > ix1) {
x_delta = -ix1;
}
- } else if ((x_delta > 0) &&(rv->region().last_frame() > max_frames - x_delta)) {
- x_delta = max_frames - rv->region().last_frame();
+ } else if ((x_delta > 0) &&(rv->region()->last_frame() > max_frames - x_delta)) {
+ x_delta = max_frames - rv->region()->last_frame();
}
if (drag_info.first_move) {
@@ -3302,7 +3304,7 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event
speed = atv->get_diskstream()->speed();
}
- regionview_x_movement = (drag_info.last_frame_position != (jack_nframes_t) (rv->region().position()/speed));
+ regionview_x_movement = (drag_info.last_frame_position != (jack_nframes_t) (rv->region()->position()/speed));
regionview_y_movement = (drag_info.last_trackview != &rv->get_time_axis_view());
//printf ("last_frame: %s position is %lu %g\n", rv->get_time_axis_view().name().c_str(), drag_info.last_frame_position, speed);
@@ -3347,7 +3349,7 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event
TimeAxisView* tvp2 = trackview_by_y_position (iy1);
AudioTimeAxisView* atv2 = dynamic_cast<AudioTimeAxisView*>(tvp2);
- from_playlist = (*i)->region().playlist();
+ from_playlist = (*i)->region()->playlist();
to_playlist = atv2->playlist();
/* the from_playlist was frozen in the "first_move" case
@@ -3382,20 +3384,20 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event
TimeAxisView* tvp2 = trackview_by_y_position (iy1);
AudioTimeAxisView* atv2 = dynamic_cast<AudioTimeAxisView*>(tvp2);
- from_playlist = (*i)->region().playlist();
+ from_playlist = (*i)->region()->playlist();
to_playlist = atv2->playlist();
latest_regionview = 0;
where = (jack_nframes_t) (unit_to_frame (ix1) * speed);
- Region* new_region = createRegion ((*i)->region());
+ boost::shared_ptr<Region> new_region (RegionFactory::create ((*i)->region()));
- from_playlist->remove_region (&((*i)->region()));
-
+ from_playlist->remove_region (((*i)->region()));
+
sigc::connection c = atv2->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_new_region_view));
- to_playlist->add_region (*new_region, where);
+ to_playlist->add_region (new_region, where);
c.disconnect ();
-
+
if (latest_regionview) {
selection->add (latest_regionview);
}
@@ -3409,7 +3411,7 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event
rv = (*i);
- if (rv->region().locked()) {
+ if (rv->region()->locked()) {
continue;
}
@@ -3431,14 +3433,14 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event
} else {
- where = rv->region().position();
+ where = rv->region()->position();
}
rv->get_time_axis_view().reveal_dependent_views (*rv);
/* no need to add an undo here, we did that when we added this playlist to motion_frozen playlists */
- rv->region().set_position (where, (void *) this);
+ rv->region()->set_position (where, (void *) this);
}
}
@@ -3611,7 +3613,7 @@ Editor::start_selection_grab (ArdourCanvas::Item* item, GdkEvent* event)
/* lets try to create new Region for the selection */
- vector<AudioRegion*> new_regions;
+ vector<boost::shared_ptr<AudioRegion> > new_regions;
create_region_from_selection (new_regions);
if (new_regions.empty()) {
@@ -3620,7 +3622,7 @@ Editor::start_selection_grab (ArdourCanvas::Item* item, GdkEvent* event)
/* XXX fix me one day to use all new regions */
- Region* region = new_regions.front();
+ boost::shared_ptr<Region> region (new_regions.front());
/* add it to the current stream/playlist.
@@ -3641,7 +3643,7 @@ Editor::start_selection_grab (ArdourCanvas::Item* item, GdkEvent* event)
Playlist* playlist = clicked_trackview->playlist();
XMLNode *before = &(playlist->get_state());
- clicked_trackview->playlist()->add_region (*region, selection->time[clicked_selection].start);
+ clicked_trackview->playlist()->add_region (region, selection->time[clicked_selection].start);
XMLNode *after = &(playlist->get_state());
session->add_command(new MementoCommand<Playlist>(*playlist, before, after));
@@ -3666,7 +3668,7 @@ Editor::start_selection_grab (ArdourCanvas::Item* item, GdkEvent* event)
start_grab (event);
drag_info.last_trackview = clicked_trackview;
- drag_info.last_frame_position = latest_regionview->region().position();
+ drag_info.last_frame_position = latest_regionview->region()->position();
drag_info.pointer_frame_offset = drag_info.grab_frame - drag_info.last_frame_position;
show_verbose_time_cursor (drag_info.last_frame_position, 10);
@@ -3907,9 +3909,9 @@ Editor::start_trim (ArdourCanvas::Item* item, GdkEvent* event)
speed = tv->get_diskstream()->speed();
}
- jack_nframes_t region_start = (jack_nframes_t) (clicked_regionview->region().position() / speed);
- jack_nframes_t region_end = (jack_nframes_t) (clicked_regionview->region().last_frame() / speed);
- jack_nframes_t region_length = (jack_nframes_t) (clicked_regionview->region().length() / speed);
+ jack_nframes_t region_start = (jack_nframes_t) (clicked_regionview->region()->position() / speed);
+ jack_nframes_t region_end = (jack_nframes_t) (clicked_regionview->region()->last_frame() / speed);
+ jack_nframes_t region_length = (jack_nframes_t) (clicked_regionview->region()->length() / speed);
motion_frozen_playlists.clear();
@@ -4001,13 +4003,13 @@ Editor::trim_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
begin_reversible_command (trim_type);
for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i) {
- (*i)->region().freeze ();
+ (*i)->region()->freeze ();
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*i);
if (arv)
arv->temporarily_hide_envelope ();
- Playlist * pl = (*i)->region().playlist();
+ Playlist * pl = (*i)->region()->playlist();
insert_result = motion_frozen_playlists.insert (pl);
if (insert_result.second) {
session->add_command(new MementoCommand<Playlist>(*pl, &pl->get_state(), 0));
@@ -4023,7 +4025,7 @@ Editor::trim_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
switch (trim_op) {
case StartTrim:
- if ((left_direction == false) && (drag_info.current_pointer_frame <= rv->region().first_frame()/speed)) {
+ if ((left_direction == false) && (drag_info.current_pointer_frame <= rv->region()->first_frame()/speed)) {
break;
} else {
for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i) {
@@ -4033,7 +4035,7 @@ Editor::trim_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
}
case EndTrim:
- if ((left_direction == true) && (drag_info.current_pointer_frame > (jack_nframes_t) (rv->region().last_frame()/speed))) {
+ if ((left_direction == true) && (drag_info.current_pointer_frame > (jack_nframes_t) (rv->region()->last_frame()/speed))) {
break;
} else {
for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i) {
@@ -4061,10 +4063,10 @@ Editor::trim_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
switch (trim_op) {
case StartTrim:
- show_verbose_time_cursor((jack_nframes_t) (rv->region().position()/speed), 10);
+ show_verbose_time_cursor((jack_nframes_t) (rv->region()->position()/speed), 10);
break;
case EndTrim:
- show_verbose_time_cursor((jack_nframes_t) (rv->region().last_frame()/speed), 10);
+ show_verbose_time_cursor((jack_nframes_t) (rv->region()->last_frame()/speed), 10);
break;
case ContentsTrim:
show_verbose_time_cursor(drag_info.current_pointer_frame, 10);
@@ -4078,9 +4080,9 @@ Editor::trim_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
void
Editor::single_contents_trim (RegionView& rv, jack_nframes_t frame_delta, bool left_direction, bool swap_direction, bool obey_snap)
{
- Region& region (rv.region());
+ boost::shared_ptr<Region> region (rv.region());
- if (region.locked()) {
+ if (region->locked()) {
return;
}
@@ -4096,31 +4098,31 @@ Editor::single_contents_trim (RegionView& rv, jack_nframes_t frame_delta, bool l
if (left_direction) {
if (swap_direction) {
- new_bound = (jack_nframes_t) (region.position()/speed) + frame_delta;
+ new_bound = (jack_nframes_t) (region->position()/speed) + frame_delta;
} else {
- new_bound = (jack_nframes_t) (region.position()/speed) - frame_delta;
+ new_bound = (jack_nframes_t) (region->position()/speed) - frame_delta;
}
} else {
if (swap_direction) {
- new_bound = (jack_nframes_t) (region.position()/speed) - frame_delta;
+ new_bound = (jack_nframes_t) (region->position()/speed) - frame_delta;
} else {
- new_bound = (jack_nframes_t) (region.position()/speed) + frame_delta;
+ new_bound = (jack_nframes_t) (region->position()/speed) + frame_delta;
}
}
if (obey_snap) {
snap_to (new_bound);
}
- region.trim_start ((jack_nframes_t) (new_bound * speed), this);
+ region->trim_start ((jack_nframes_t) (new_bound * speed), this);
rv.region_changed (StartChanged);
}
void
Editor::single_start_trim (RegionView& rv, jack_nframes_t frame_delta, bool left_direction, bool obey_snap)
{
- Region& region (rv.region());
+ boost::shared_ptr<Region> region (rv.region());
- if (region.locked()) {
+ if (region->locked()) {
return;
}
@@ -4135,16 +4137,16 @@ Editor::single_start_trim (RegionView& rv, jack_nframes_t frame_delta, bool left
}
if (left_direction) {
- new_bound = (jack_nframes_t) (region.position()/speed) - frame_delta;
+ new_bound = (jack_nframes_t) (region->position()/speed) - frame_delta;
} else {
- new_bound = (jack_nframes_t) (region.position()/speed) + frame_delta;
+ new_bound = (jack_nframes_t) (region->position()/speed) + frame_delta;
}
if (obey_snap) {
snap_to (new_bound, (left_direction ? 0 : 1));
}
- region.trim_front ((jack_nframes_t) (new_bound * speed), this);
+ region->trim_front ((jack_nframes_t) (new_bound * speed), this);
rv.region_changed (Change (LengthChanged|PositionChanged|StartChanged));
}
@@ -4152,9 +4154,9 @@ Editor::single_start_trim (RegionView& rv, jack_nframes_t frame_delta, bool left
void
Editor::single_end_trim (RegionView& rv, jack_nframes_t frame_delta, bool left_direction, bool obey_snap)
{
- Region& region (rv.region());
+ boost::shared_ptr<Region> region (rv.region());
- if (region.locked()) {
+ if (region->locked()) {
return;
}
@@ -4169,15 +4171,15 @@ Editor::single_end_trim (RegionView& rv, jack_nframes_t frame_delta, bool left_d
}
if (left_direction) {
- new_bound = (jack_nframes_t) ((region.last_frame() + 1)/speed) - frame_delta;
+ new_bound = (jack_nframes_t) ((region->last_frame() + 1)/speed) - frame_delta;
} else {
- new_bound = (jack_nframes_t) ((region.last_frame() + 1)/speed) + frame_delta;
+ new_bound = (jack_nframes_t) ((region->last_frame() + 1)/speed) + frame_delta;
}
if (obey_snap) {
snap_to (new_bound);
}
- region.trim_end ((jack_nframes_t) (new_bound * speed), this);
+ region->trim_end ((jack_nframes_t) (new_bound * speed), this);
rv.region_changed (LengthChanged);
}
@@ -4233,10 +4235,10 @@ Editor::point_trim (GdkEvent* event)
for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin();
i != selection->regions.by_layer().end(); ++i)
{
- if (!(*i)->region().locked()) {
- Playlist *pl = (*i)->region().playlist();
+ if (!(*i)->region()->locked()) {
+ Playlist *pl = (*i)->region()->playlist();
XMLNode &before = pl->get_state();
- (*i)->region().trim_front (new_bound, this);
+ (*i)->region()->trim_front (new_bound, this);
XMLNode &after = pl->get_state();
session->add_command(new MementoCommand<Playlist>(*pl, &before, &after));
}
@@ -4244,10 +4246,10 @@ Editor::point_trim (GdkEvent* event)
} else {
- if (!rv->region().locked()) {
- Playlist *pl = rv->region().playlist();
+ if (!rv->region()->locked()) {
+ Playlist *pl = rv->region()->playlist();
XMLNode &before = pl->get_state();
- rv->region().trim_front (new_bound, this);
+ rv->region()->trim_front (new_bound, this);
XMLNode &after = pl->get_state();
session->add_command(new MementoCommand<Playlist>(*pl, &before, &after));
}
@@ -4264,10 +4266,10 @@ Editor::point_trim (GdkEvent* event)
for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i)
{
- if (!(*i)->region().locked()) {
- Playlist *pl = (*i)->region().playlist();
+ if (!(*i)->region()->locked()) {
+ Playlist *pl = (*i)->region()->playlist();
XMLNode &before = pl->get_state();
- (*i)->region().trim_end (new_bound, this);
+ (*i)->region()->trim_end (new_bound, this);
XMLNode &after = pl->get_state();
session->add_command(new MementoCommand<Playlist>(*pl, &before, &after));
}
@@ -4275,10 +4277,10 @@ Editor::point_trim (GdkEvent* event)
} else {
- if (!rv->region().locked()) {
- Playlist *pl = rv->region().playlist();
+ if (!rv->region()->locked()) {
+ Playlist *pl = rv->region()->playlist();
XMLNode &before = pl->get_state();
- rv->region().trim_end (new_bound, this);
+ rv->region()->trim_end (new_bound, this);
XMLNode &after = pl->get_state();
session->add_command (new MementoCommand<Playlist>(*pl, &before, &after));
}
@@ -4295,15 +4297,15 @@ Editor::point_trim (GdkEvent* event)
void
Editor::thaw_region_after_trim (RegionView& rv)
{
- Region& region (rv.region());
+ boost::shared_ptr<Region> region (rv.region());
- if (region.locked()) {
+ if (region->locked()) {
return;
}
- region.thaw (_("trimmed region"));
- XMLNode &after = region.playlist()->get_state();
- session->add_command (new MementoCommand<Playlist>(*(region.playlist()), 0, &after));
+ region->thaw (_("trimmed region"));
+ XMLNode &after = region->playlist()->get_state();
+ session->add_command (new MementoCommand<Playlist>(*(region->playlist()), 0, &after));
AudioRegionView* arv = dynamic_cast<AudioRegionView*>(&rv);
if (arv)
@@ -4717,7 +4719,7 @@ Editor::mouse_rename_region (ArdourCanvas::Item* item, GdkEvent* event)
ArdourPrompter prompter (false);
prompter.set_prompt (_("Name for region:"));
- prompter.set_initial_text (clicked_regionview->region().name());
+ prompter.set_initial_text (clicked_regionview->region()->name());
prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
prompter.show_all ();
@@ -4726,7 +4728,7 @@ Editor::mouse_rename_region (ArdourCanvas::Item* item, GdkEvent* event)
string str;
prompter.get_result(str);
if (str.length()) {
- clicked_regionview->region().set_name (str);
+ clicked_regionview->region()->set_name (str);
}
break;
}
@@ -4758,8 +4760,8 @@ Editor::time_fx_motion (ArdourCanvas::Item *item, GdkEvent* event)
return;
}
- if (drag_info.current_pointer_frame > rv->region().position()) {
- rv->get_time_axis_view().show_timestretch (rv->region().position(), drag_info.current_pointer_frame);
+ if (drag_info.current_pointer_frame > rv->region()->position()) {
+ rv->get_time_axis_view().show_timestretch (rv->region()->position(), drag_info.current_pointer_frame);
}
drag_info.last_pointer_frame = drag_info.current_pointer_frame;
@@ -4777,8 +4779,8 @@ Editor::end_time_fx (ArdourCanvas::Item* item, GdkEvent* event)
return;
}
- jack_nframes_t newlen = drag_info.last_pointer_frame - clicked_regionview->region().position();
- float percentage = (float) ((double) newlen - (double) clicked_regionview->region().length()) / ((double) newlen) * 100.0f;
+ jack_nframes_t newlen = drag_info.last_pointer_frame - clicked_regionview->region()->position();
+ float percentage = (float) ((double) newlen - (double) clicked_regionview->region()->length()) / ((double) newlen) * 100.0f;
begin_reversible_command (_("timestretch"));
@@ -4815,7 +4817,7 @@ Editor::mouse_brush_insert_region (RegionView* rv, jack_nframes_t pos)
/* don't brush a copy over the original */
- if (pos == rv->region().position()) {
+ if (pos == rv->region()->position()) {
return;
}
@@ -4829,7 +4831,7 @@ Editor::mouse_brush_insert_region (RegionView* rv, jack_nframes_t pos)
double speed = atv->get_diskstream()->speed();
XMLNode &before = playlist->get_state();
- playlist->add_region (*(new AudioRegion (arv->audio_region())), (jack_nframes_t) (pos * speed));
+ playlist->add_region (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (arv->audio_region())), (jack_nframes_t) (pos * speed));
XMLNode &after = playlist->get_state();
session->add_command(new MementoCommand<Playlist>(*playlist, &before, &after));
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index 55a863c6e3..db878bab41 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -203,7 +203,7 @@ Editor::split_regions_at (jack_nframes_t where, RegionSelection& regions)
tmp = a;
++tmp;
- Playlist* pl = (*a)->region().playlist();
+ Playlist* pl = (*a)->region()->playlist();
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*a);
if (arv)
@@ -234,7 +234,7 @@ Editor::remove_clicked_region ()
begin_reversible_command (_("remove region"));
XMLNode &before = playlist->get_state();
- playlist->remove_region (&clicked_regionview->region());
+ playlist->remove_region (clicked_regionview->region());
XMLNode &after = playlist->get_state();
session->add_command(new MementoCommand<Playlist>(*playlist, &before, &after));
commit_reversible_command ();
@@ -273,24 +273,24 @@ Do you really want to destroy %1 ?"),
}
if (selected > 0) {
- list<Region*> r;
+ list<boost::shared_ptr<Region> > r;
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
- r.push_back (&(*i)->region());
+ r.push_back ((*i)->region());
}
session->destroy_regions (r);
} else if (clicked_regionview) {
- session->destroy_region (&clicked_regionview->region());
+ session->destroy_region (clicked_regionview->region());
}
}
-Region *
+boost::shared_ptr<Region>
Editor::select_region_for_operation (int dir, TimeAxisView **tv)
{
RegionView* rv;
- Region *region;
+ boost::shared_ptr<Region> region;
jack_nframes_t start = 0;
if (selection->time.start () == selection->time.end_frame ()) {
@@ -298,18 +298,16 @@ Editor::select_region_for_operation (int dir, TimeAxisView **tv)
/* no current selection-> is there a selected regionview? */
if (selection->regions.empty()) {
- return 0;
+ return region;
}
}
- region = 0;
-
if (!selection->regions.empty()) {
rv = *(selection->regions.begin());
(*tv) = &rv->get_time_axis_view();
- region = &rv->region();
+ region = rv->region();
} else if (!selection->tracks.empty()) {
@@ -321,7 +319,7 @@ Editor::select_region_for_operation (int dir, TimeAxisView **tv)
Playlist *pl;
if ((pl = rtv->playlist()) == 0) {
- return 0;
+ return region;
}
region = pl->top_region_at (start);
@@ -335,7 +333,7 @@ void
Editor::extend_selection_to_end_of_region (bool next)
{
TimeAxisView *tv;
- Region *region;
+ boost::shared_ptr<Region> region;
jack_nframes_t start;
if ((region = select_region_for_operation (next ? 1 : 0, &tv)) == 0) {
@@ -363,7 +361,7 @@ void
Editor::extend_selection_to_start_of_region (bool previous)
{
TimeAxisView *tv;
- Region *region;
+ boost::shared_ptr<Region> region;
jack_nframes_t end;
if ((region = select_region_for_operation (previous ? -1 : 0, &tv)) == 0) {
@@ -401,18 +399,18 @@ Editor::nudge_forward (bool next)
begin_reversible_command (_("nudge forward"));
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
- Region& r ((*i)->region());
+ boost::shared_ptr<Region> r ((*i)->region());
- distance = get_nudge_distance (r.position(), next_distance);
+ distance = get_nudge_distance (r->position(), next_distance);
if (next) {
distance = next_distance;
}
- XMLNode &before = r.playlist()->get_state();
- r.set_position (r.position() + distance, this);
- XMLNode &after = r.playlist()->get_state();
- session->add_command (new MementoCommand<Playlist>(*(r.playlist()), &before, &after));
+ XMLNode &before = r->playlist()->get_state();
+ r->set_position (r->position() + distance, this);
+ XMLNode &after = r->playlist()->get_state();
+ session->add_command (new MementoCommand<Playlist>(*(r->playlist()), &before, &after));
}
commit_reversible_command ();
@@ -436,23 +434,23 @@ Editor::nudge_backward (bool next)
begin_reversible_command (_("nudge forward"));
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
- Region& r ((*i)->region());
+ boost::shared_ptr<Region> r ((*i)->region());
- distance = get_nudge_distance (r.position(), next_distance);
+ distance = get_nudge_distance (r->position(), next_distance);
if (next) {
distance = next_distance;
}
- XMLNode &before = r.playlist()->get_state();
+ XMLNode &before = r->playlist()->get_state();
- if (r.position() > distance) {
- r.set_position (r.position() - distance, this);
+ if (r->position() > distance) {
+ r->set_position (r->position() - distance, this);
} else {
- r.set_position (0, this);
+ r->set_position (0, this);
}
- XMLNode &after = r.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(r.playlist()), &before, &after));
+ XMLNode &after = r->playlist()->get_state();
+ session->add_command(new MementoCommand<Playlist>(*(r->playlist()), &before, &after));
}
commit_reversible_command ();
@@ -483,12 +481,12 @@ Editor::nudge_forward_capture_offset ()
distance = session->worst_output_latency();
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
- Region& r ((*i)->region());
+ boost::shared_ptr<Region> r ((*i)->region());
- XMLNode &before = r.playlist()->get_state();
- r.set_position (r.position() + distance, this);
- XMLNode &after = r.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(r.playlist()), &before, &after));
+ XMLNode &before = r->playlist()->get_state();
+ r->set_position (r->position() + distance, this);
+ XMLNode &after = r->playlist()->get_state();
+ session->add_command(new MementoCommand<Playlist>(*(r->playlist()), &before, &after));
}
commit_reversible_command ();
@@ -510,17 +508,17 @@ Editor::nudge_backward_capture_offset ()
distance = session->worst_output_latency();
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
- Region& r ((*i)->region());
+ boost::shared_ptr<Region> r ((*i)->region());
- XMLNode &before = r.playlist()->get_state();
+ XMLNode &before = r->playlist()->get_state();
- if (r.position() > distance) {
- r.set_position (r.position() - distance, this);
+ if (r->position() > distance) {
+ r->set_position (r->position() - distance, this);
} else {
- r.set_position (0, this);
+ r->set_position (0, this);
}
- XMLNode &after = r.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(r.playlist()), &before, &after));
+ XMLNode &after = r->playlist()->get_state();
+ session->add_command(new MementoCommand<Playlist>(*(r->playlist()), &before, &after));
}
commit_reversible_command ();
@@ -547,7 +545,7 @@ Editor::build_region_boundary_cache ()
{
jack_nframes_t pos = 0;
RegionPoint point;
- Region *r;
+ boost::shared_ptr<Region> r;
TrackViewList tracks;
region_boundary_cache.clear ();
@@ -643,12 +641,12 @@ Editor::build_region_boundary_cache ()
}
}
-Region*
+boost::shared_ptr<Region>
Editor::find_next_region (jack_nframes_t frame, RegionPoint point, int32_t dir, TrackViewList& tracks, TimeAxisView **ontrack)
{
TrackViewList::iterator i;
jack_nframes_t closest = max_frames;
- Region* ret = 0;
+ boost::shared_ptr<Region> ret;
jack_nframes_t rpos = 0;
float track_speed;
@@ -658,8 +656,8 @@ Editor::find_next_region (jack_nframes_t frame, RegionPoint point, int32_t dir,
for (i = tracks.begin(); i != tracks.end(); ++i) {
jack_nframes_t distance;
- Region* r;
-
+ boost::shared_ptr<Region> r;
+
track_speed = 1.0f;
if ( (atav = dynamic_cast<AudioTimeAxisView*>(*i)) != 0 ) {
if (atav->get_diskstream()!=0)
@@ -708,7 +706,7 @@ Editor::find_next_region (jack_nframes_t frame, RegionPoint point, int32_t dir,
void
Editor::cursor_to_region_point (Cursor* cursor, RegionPoint point, int32_t dir)
{
- Region* r;
+ boost::shared_ptr<Region> r;
jack_nframes_t pos = cursor->current_frame;
if (!session) {
@@ -1326,9 +1324,9 @@ Editor::add_location_from_audio_region ()
}
RegionView* rv = *(selection->regions.begin());
- Region& region = rv->region();
+ boost::shared_ptr<Region> region = rv->region();
- Location *location = new Location (region.position(), region.last_frame(), region.name());
+ Location *location = new Location (region->position(), region->last_frame(), region->name());
session->begin_reversible_command (_("add marker"));
XMLNode &before = session->locations()->get_state();
session->locations()->add (location, true);
@@ -1459,10 +1457,10 @@ Editor::set_selection_from_audio_region ()
}
RegionView* rv = *(selection->regions.begin());
- Region& region = rv->region();
+ boost::shared_ptr<Region> region = rv->region();
begin_reversible_command (_("set selection from region"));
- selection->set (0, region.position(), region.last_frame());
+ selection->set (0, region->position(), region->last_frame());
commit_reversible_command ();
set_mouse_mode (Editing::MouseRange, false);
@@ -1793,7 +1791,7 @@ Editor::clear_locations ()
/* INSERT/REPLACE */
void
-Editor::insert_region_list_drag (AudioRegion& region, int x, int y)
+Editor::insert_region_list_drag (boost::shared_ptr<AudioRegion> region, int x, int y)
{
double wx, wy;
double cx, cy;
@@ -1834,7 +1832,7 @@ Editor::insert_region_list_drag (AudioRegion& region, int x, int y)
begin_reversible_command (_("insert dragged region"));
XMLNode &before = playlist->get_state();
- playlist->add_region (*(new AudioRegion (region)), where, 1.0);
+ playlist->add_region (RegionFactory::create (region), where, 1.0);
session->add_command(new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
commit_reversible_command ();
}
@@ -1866,11 +1864,11 @@ Editor::insert_region_list_selection (float times)
}
TreeModel::iterator i = region_list_display.get_selection()->get_selected();
- Region* region = (*i)[region_list_columns.region];
+ boost::shared_ptr<Region> region = (*i)[region_list_columns.region];
begin_reversible_command (_("insert region"));
XMLNode &before = playlist->get_state();
- playlist->add_region (*(createRegion (*region)), edit_cursor->current_frame, times);
+ playlist->add_region ((RegionFactory::create (region)), edit_cursor->current_frame, times);
session->add_command(new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
commit_reversible_command ();
}
@@ -1946,7 +1944,7 @@ Editor::play_selected_region ()
if (!selection->regions.empty()) {
RegionView *rv = *(selection->regions.begin());
- session->request_bounded_roll (rv->region().position(), rv->region().last_frame());
+ session->request_bounded_roll (rv->region()->position(), rv->region()->last_frame());
}
}
@@ -1959,7 +1957,7 @@ Editor::loop_selected_region ()
if ((tll = transport_loop_location()) != 0) {
- tll->set (rv->region().position(), rv->region().last_frame());
+ tll->set (rv->region()->position(), rv->region()->last_frame());
// enable looping, reposition and start rolling
@@ -2002,9 +2000,9 @@ void
Editor::toggle_region_mute ()
{
if (clicked_regionview) {
- clicked_regionview->region().set_muted (!clicked_regionview->region().muted());
+ clicked_regionview->region()->set_muted (!clicked_regionview->region()->muted());
} else if (!selection->regions.empty()) {
- bool yn = ! (*selection->regions.begin())->region().muted();
+ bool yn = ! (*selection->regions.begin())->region()->muted();
selection->foreach_region (&Region::set_muted, yn);
}
}
@@ -2013,9 +2011,9 @@ void
Editor::toggle_region_opaque ()
{
if (clicked_regionview) {
- clicked_regionview->region().set_opaque (!clicked_regionview->region().opaque());
+ clicked_regionview->region()->set_opaque (!clicked_regionview->region()->opaque());
} else if (!selection->regions.empty()) {
- bool yn = ! (*selection->regions.begin())->region().opaque();
+ bool yn = ! (*selection->regions.begin())->region()->opaque();
selection->foreach_region (&Region::set_opaque, yn);
}
}
@@ -2093,7 +2091,7 @@ Editor::rename_region ()
Main::run ();
if (region_renamed) {
- (*selection->regions.begin())->region().set_name (entry.get_text());
+ (*selection->regions.begin())->region()->set_name (entry.get_text());
redisplay_regions ();
}
}
@@ -2107,7 +2105,7 @@ Editor::rename_region_finished (bool status)
}
void
-Editor::audition_playlist_region_via_route (Region& region, Route& route)
+Editor::audition_playlist_region_via_route (boost::shared_ptr<Region> region, Route& route)
{
if (session->is_auditioning()) {
session->cancel_audition ();
@@ -2120,7 +2118,7 @@ Editor::audition_playlist_region_via_route (Region& region, Route& route)
route.set_solo (true, this);
- session->request_bounded_roll (region.position(), region.position() + region.length());
+ session->request_bounded_roll (region->position(), region->position() + region->length());
/* XXX how to unset the solo state ? */
}
@@ -2135,7 +2133,7 @@ Editor::audition_selected_region ()
}
void
-Editor::audition_playlist_region_standalone (Region& region)
+Editor::audition_playlist_region_standalone (boost::shared_ptr<Region> region)
{
session->audition_region (region);
}
@@ -2185,9 +2183,8 @@ Editor::region_from_selection ()
jack_nframes_t selection_cnt = end - start + 1;
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
- AudioRegion *region;
- AudioRegion *current;
- Region* current_r;
+ boost::shared_ptr<AudioRegion> current;
+ boost::shared_ptr<Region> current_r;
Playlist *pl;
jack_nframes_t internal_start;
@@ -2201,18 +2198,18 @@ Editor::region_from_selection ()
continue;
}
- current = dynamic_cast<AudioRegion*> (current_r);
+ current = boost::dynamic_pointer_cast<AudioRegion> (current_r);
// FIXME: audio only
if (current != 0) {
internal_start = start - current->position();
session->region_name (new_name, current->name(), true);
- region = new AudioRegion (*current, internal_start, selection_cnt, new_name);
+ boost::shared_ptr<Region> region (RegionFactory::create (current, internal_start, selection_cnt, new_name));
}
}
}
void
-Editor::create_region_from_selection (vector<AudioRegion *>& new_regions)
+Editor::create_region_from_selection (vector<boost::shared_ptr<AudioRegion> >& new_regions)
{
if (selection->time.empty() || selection->tracks.empty()) {
return;
@@ -2223,8 +2220,8 @@ Editor::create_region_from_selection (vector<AudioRegion *>& new_regions)
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
- AudioRegion* current;
- Region* current_r;
+ boost::shared_ptr<AudioRegion> current;
+ boost::shared_ptr<Region> current_r;
Playlist* playlist;
jack_nframes_t internal_start;
string new_name;
@@ -2237,14 +2234,14 @@ Editor::create_region_from_selection (vector<AudioRegion *>& new_regions)
continue;
}
- if ((current = dynamic_cast<AudioRegion*>(current_r)) == 0) {
+ if ((current = boost::dynamic_pointer_cast<AudioRegion>(current_r)) == 0) {
continue;
}
internal_start = start - current->position();
session->region_name (new_name, current->name(), true);
- new_regions.push_back (new AudioRegion (*current, internal_start, end - start + 1, new_name));
+ new_regions.push_back (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (current, internal_start, end - start + 1, new_name)));
}
}
@@ -2255,11 +2252,11 @@ Editor::split_multichannel_region ()
AudioRegionView* clicked_arv = dynamic_cast<AudioRegionView*>(clicked_regionview);
- if (!clicked_arv || clicked_arv->audio_region().n_channels() < 2) {
+ if (!clicked_arv || clicked_arv->audio_region()->n_channels() < 2) {
return;
}
- clicked_arv->audio_region().separate_by_channel (*session, v);
+ clicked_arv->audio_region()->separate_by_channel (*session, v);
/* nothing else to do, really */
}
@@ -2414,7 +2411,7 @@ Editor::crop_region_to_selection ()
for (vector<Playlist*>::iterator i = playlists.begin(); i != playlists.end(); ++i) {
- Region *region;
+ boost::shared_ptr<Region> region;
start = selection->time.start();
@@ -2455,27 +2452,27 @@ Editor::region_fill_track ()
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
- Region& region ((*i)->region());
+ boost::shared_ptr<Region> region ((*i)->region());
// FIXME
- AudioRegion* const ar = dynamic_cast<AudioRegion*>(&region);
+ boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion>(region);
if (!ar)
continue;
- Playlist* pl = region.playlist();
+ Playlist* pl = region->playlist();
- if (end <= region.last_frame()) {
+ if (end <= region->last_frame()) {
return;
}
- double times = (double) (end - region.last_frame()) / (double) region.length();
+ double times = (double) (end - region->last_frame()) / (double) region->length();
if (times == 0) {
return;
}
XMLNode &before = pl->get_state();
- pl->add_region (*(new AudioRegion (*ar)), ar->last_frame(), times);
+ pl->add_region (RegionFactory::create (ar), ar->last_frame(), times);
session->add_command (new MementoCommand<Playlist>(*pl, &before, &pl->get_state()));
}
@@ -2493,7 +2490,6 @@ Editor::region_fill_selection ()
return;
}
- Region *region;
Glib::RefPtr<TreeSelection> selected = region_list_display.get_selection();
@@ -2502,7 +2498,7 @@ Editor::region_fill_selection ()
}
TreeModel::iterator i = region_list_display.get_selection()->get_selected();
- region = (*i)[region_list_columns.region];
+ boost::shared_ptr<Region> region = (*i)[region_list_columns.region];
jack_nframes_t start = selection->time[clicked_selection].start;
jack_nframes_t end = selection->time[clicked_selection].end;
@@ -2525,7 +2521,7 @@ Editor::region_fill_selection ()
}
XMLNode &before = playlist->get_state();
- playlist->add_region (*(createRegion (*region)), start, times);
+ playlist->add_region (RegionFactory::create (region), start, times);
session->add_command (new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
}
@@ -2533,18 +2529,18 @@ Editor::region_fill_selection ()
}
void
-Editor::set_a_regions_sync_position (Region& region, jack_nframes_t position)
+Editor::set_a_regions_sync_position (boost::shared_ptr<Region> region, jack_nframes_t position)
{
- if (!region.covers (position)) {
+ if (!region->covers (position)) {
error << _("Programming error. that region doesn't cover that position") << __FILE__ << " +" << __LINE__ << endmsg;
return;
}
begin_reversible_command (_("set region sync position"));
- XMLNode &before = region.playlist()->get_state();
- region.set_sync_position (position);
- XMLNode &after = region.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(region.playlist()), &before, &after));
+ XMLNode &before = region->playlist()->get_state();
+ region->set_sync_position (position);
+ XMLNode &after = region->playlist()->get_state();
+ session->add_command(new MementoCommand<Playlist>(*(region->playlist()), &before, &after));
commit_reversible_command ();
}
@@ -2555,17 +2551,17 @@ Editor::set_region_sync_from_edit_cursor ()
return;
}
- if (!clicked_regionview->region().covers (edit_cursor->current_frame)) {
+ if (!clicked_regionview->region()->covers (edit_cursor->current_frame)) {
error << _("Place the edit cursor at the desired sync point") << endmsg;
return;
}
- Region& region (clicked_regionview->region());
+ boost::shared_ptr<Region> region (clicked_regionview->region());
begin_reversible_command (_("set sync from edit cursor"));
- XMLNode &before = region.playlist()->get_state();
- region.set_sync_position (edit_cursor->current_frame);
- XMLNode &after = region.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(region.playlist()), &before, &after));
+ XMLNode &before = region->playlist()->get_state();
+ region->set_sync_position (edit_cursor->current_frame);
+ XMLNode &after = region->playlist()->get_state();
+ session->add_command(new MementoCommand<Playlist>(*(region->playlist()), &before, &after));
commit_reversible_command ();
}
@@ -2573,12 +2569,12 @@ void
Editor::remove_region_sync ()
{
if (clicked_regionview) {
- Region& region (clicked_regionview->region());
+ boost::shared_ptr<Region> region (clicked_regionview->region());
begin_reversible_command (_("remove sync"));
- XMLNode &before = region.playlist()->get_state();
- region.clear_sync_position ();
- XMLNode &after = region.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(region.playlist()), &before, &after));
+ XMLNode &before = region->playlist()->get_state();
+ region->clear_sync_position ();
+ XMLNode &after = region->playlist()->get_state();
+ session->add_command(new MementoCommand<Playlist>(*(region->playlist()), &before, &after));
commit_reversible_command ();
}
}
@@ -2591,10 +2587,10 @@ Editor::naturalize ()
}
begin_reversible_command (_("naturalize"));
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
- XMLNode &before = (*i)->region().get_state();
- (*i)->region().move_to_natural_position (this);
- XMLNode &after = (*i)->region().get_state();
- session->add_command (new MementoCommand<Region>((*i)->region(), &before, &after));
+ XMLNode &before = (*i)->region()->get_state();
+ (*i)->region()->move_to_natural_position (this);
+ XMLNode &after = (*i)->region()->get_state();
+ session->add_command (new MementoCommand<Region>(*((*i)->region().get()), &before, &after));
}
commit_reversible_command ();
}
@@ -2613,7 +2609,7 @@ Editor::align_relative (RegionPoint what)
struct RegionSortByTime {
bool operator() (const AudioRegionView* a, const AudioRegionView* b) {
- return a->region().position() < b->region().position();
+ return a->region()->position() < b->region()->position();
}
};
@@ -2630,19 +2626,19 @@ Editor::align_selection_relative (RegionPoint point, jack_nframes_t position)
list<RegionView*> sorted;
selection->regions.by_position (sorted);
- Region& r ((*sorted.begin())->region());
+ boost::shared_ptr<Region> r ((*sorted.begin())->region());
switch (point) {
case Start:
- pos = r.first_frame ();
+ pos = r->first_frame ();
break;
case End:
- pos = r.last_frame();
+ pos = r->last_frame();
break;
case SyncPoint:
- pos = r.adjust_to_sync (r.first_frame());
+ pos = r->adjust_to_sync (r->first_frame());
break;
}
@@ -2658,18 +2654,18 @@ Editor::align_selection_relative (RegionPoint point, jack_nframes_t position)
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
- Region& region ((*i)->region());
+ boost::shared_ptr<Region> region ((*i)->region());
- XMLNode &before = region.playlist()->get_state();
+ XMLNode &before = region->playlist()->get_state();
if (dir > 0) {
- region.set_position (region.position() + distance, this);
+ region->set_position (region->position() + distance, this);
} else {
- region.set_position (region.position() - distance, this);
+ region->set_position (region->position() - distance, this);
}
- XMLNode &after = region.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(region.playlist()), &before, &after));
+ XMLNode &after = region->playlist()->get_state();
+ session->add_command(new MementoCommand<Playlist>(*(region->playlist()), &before, &after));
}
@@ -2693,7 +2689,7 @@ Editor::align_selection (RegionPoint point, jack_nframes_t position)
}
void
-Editor::align_region (Region& region, RegionPoint point, jack_nframes_t position)
+Editor::align_region (boost::shared_ptr<Region> region, RegionPoint point, jack_nframes_t position)
{
begin_reversible_command (_("align region"));
align_region_internal (region, point, position);
@@ -2701,28 +2697,28 @@ Editor::align_region (Region& region, RegionPoint point, jack_nframes_t position
}
void
-Editor::align_region_internal (Region& region, RegionPoint point, jack_nframes_t position)
+Editor::align_region_internal (boost::shared_ptr<Region> region, RegionPoint point, jack_nframes_t position)
{
- XMLNode &before = region.playlist()->get_state();
+ XMLNode &before = region->playlist()->get_state();
switch (point) {
case SyncPoint:
- region.set_position (region.adjust_to_sync (position), this);
+ region->set_position (region->adjust_to_sync (position), this);
break;
case End:
- if (position > region.length()) {
- region.set_position (position - region.length(), this);
+ if (position > region->length()) {
+ region->set_position (position - region->length(), this);
}
break;
case Start:
- region.set_position (position, this);
+ region->set_position (position, this);
break;
}
- XMLNode &after = region.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(region.playlist()), &before, &after));
+ XMLNode &after = region->playlist()->get_state();
+ session->add_command(new MementoCommand<Playlist>(*(region->playlist()), &before, &after));
}
void
@@ -2732,7 +2728,7 @@ Editor::trim_region_to_edit_cursor ()
return;
}
- Region& region (clicked_regionview->region());
+ boost::shared_ptr<Region> region (clicked_regionview->region());
float speed = 1.0f;
AudioTimeAxisView *atav;
@@ -2744,10 +2740,10 @@ Editor::trim_region_to_edit_cursor ()
}
begin_reversible_command (_("trim to edit"));
- XMLNode &before = region.playlist()->get_state();
- region.trim_end( session_frame_to_track_frame(edit_cursor->current_frame, speed), this);
- XMLNode &after = region.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(region.playlist()), &before, &after));
+ XMLNode &before = region->playlist()->get_state();
+ region->trim_end( session_frame_to_track_frame(edit_cursor->current_frame, speed), this);
+ XMLNode &after = region->playlist()->get_state();
+ session->add_command(new MementoCommand<Playlist>(*(region->playlist()), &before, &after));
commit_reversible_command ();
}
@@ -2758,7 +2754,7 @@ Editor::trim_region_from_edit_cursor ()
return;
}
- Region& region (clicked_regionview->region());
+ boost::shared_ptr<Region> region (clicked_regionview->region());
float speed = 1.0f;
AudioTimeAxisView *atav;
@@ -2770,10 +2766,10 @@ Editor::trim_region_from_edit_cursor ()
}
begin_reversible_command (_("trim to edit"));
- XMLNode &before = region.playlist()->get_state();
- region.trim_front ( session_frame_to_track_frame(edit_cursor->current_frame, speed), this);
- XMLNode &after = region.playlist()->get_state();
- session->add_command(new MementoCommand<Playlist>(*(region.playlist()), &before, &after));
+ XMLNode &before = region->playlist()->get_state();
+ region->trim_front ( session_frame_to_track_frame(edit_cursor->current_frame, speed), this);
+ XMLNode &after = region->playlist()->get_state();
+ session->add_command(new MementoCommand<Playlist>(*(region->playlist()), &before, &after));
commit_reversible_command ();
}
@@ -2998,10 +2994,10 @@ Editor::cut_copy_regions (CutCopyOp op)
pair<set<Playlist*>::iterator,bool> insert_result;
for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
- first_position = min ((*x)->region().position(), first_position);
+ first_position = min ((*x)->region()->position(), first_position);
if (op == Cut || op == Clear) {
- AudioPlaylist *pl = dynamic_cast<AudioPlaylist*>((*x)->region().playlist());
+ AudioPlaylist *pl = dynamic_cast<AudioPlaylist*>((*x)->region()->playlist());
if (pl) {
insert_result = freezelist.insert (pl);
if (insert_result.second) {
@@ -3014,7 +3010,7 @@ Editor::cut_copy_regions (CutCopyOp op)
for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ) {
- AudioPlaylist *pl = dynamic_cast<AudioPlaylist*>((*x)->region().playlist());
+ AudioPlaylist *pl = dynamic_cast<AudioPlaylist*>((*x)->region()->playlist());
AudioPlaylist* npl;
RegionSelection::iterator tmp;
@@ -3034,23 +3030,23 @@ Editor::cut_copy_regions (CutCopyOp op)
}
// FIXME
- AudioRegion* const ar = dynamic_cast<AudioRegion*>(&(*x)->region());
+ boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion>((*x)->region());
switch (op) {
case Cut:
if (!ar) break;
- npl->add_region (*(new AudioRegion (*ar)), (*x)->region().position() - first_position);
- pl->remove_region (&((*x)->region()));
+ npl->add_region (RegionFactory::create (ar), (*x)->region()->position() - first_position);
+ pl->remove_region (((*x)->region()));
break;
case Copy:
if (!ar) break;
- npl->add_region (*(new AudioRegion (*ar)), (*x)->region().position() - first_position);
+ npl->add_region (RegionFactory::create (ar), (*x)->region()->position() - first_position);
break;
case Clear:
- pl->remove_region (&((*x)->region()));
+ pl->remove_region (((*x)->region()));
break;
}
}
@@ -3207,15 +3203,15 @@ Editor::duplicate_some_regions (RegionSelection& regions, float times)
for (RegionSelection::iterator i = sel.begin(); i != sel.end(); ++i) {
- Region& r ((*i)->region());
+ boost::shared_ptr<Region> r ((*i)->region());
TimeAxisView& tv = (*i)->get_time_axis_view();
AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (&tv);
sigc::connection c = atv->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_new_region_view));
- playlist = (*i)->region().playlist();
+ playlist = (*i)->region()->playlist();
XMLNode &before = playlist->get_state();
- playlist->duplicate (r, r.last_frame(), times);
+ playlist->duplicate (r, r->last_frame(), times);
session->add_command(new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
c.disconnect ();
@@ -3237,8 +3233,8 @@ Editor::duplicate_selection (float times)
}
Playlist *playlist;
- vector<AudioRegion*> new_regions;
- vector<AudioRegion*>::iterator ri;
+ vector<boost::shared_ptr<AudioRegion> > new_regions;
+ vector<boost::shared_ptr<AudioRegion> >::iterator ri;
create_region_from_selection (new_regions);
@@ -3255,7 +3251,7 @@ Editor::duplicate_selection (float times)
continue;
}
XMLNode &before = playlist->get_state();
- playlist->duplicate (**ri, selection->time[clicked_selection].end, times);
+ playlist->duplicate (*ri, selection->time[clicked_selection].end, times);
XMLNode &after = playlist->get_state();
session->add_command (new MementoCommand<Playlist>(*playlist, &before, &after));
@@ -3399,9 +3395,9 @@ Editor::normalize_region ()
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*r);
if (!arv)
continue;
- XMLNode &before = arv->region().get_state();
- arv->audio_region().normalize_to (0.0f);
- session->add_command (new MementoCommand<Region>(arv->region(), &before, &arv->region().get_state()));
+ XMLNode &before = arv->region()->get_state();
+ arv->audio_region()->normalize_to (0.0f);
+ session->add_command (new MementoCommand<Region>(*(arv->region().get()), &before, &arv->region()->get_state()));
}
commit_reversible_command ();
@@ -3426,9 +3422,9 @@ Editor::denormalize_region ()
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*r);
if (!arv)
continue;
- XMLNode &before = arv->region().get_state();
- arv->audio_region().set_scale_amplitude (1.0f);
- session->add_command (new MementoCommand<Region>(arv->region(), &before, &arv->region().get_state()));
+ XMLNode &before = arv->region()->get_state();
+ arv->audio_region()->set_scale_amplitude (1.0f);
+ session->add_command (new MementoCommand<Region>(*(arv->region().get()), &before, &arv->region()->get_state()));
}
commit_reversible_command ();
@@ -3463,17 +3459,17 @@ Editor::apply_filter (AudioFilter& filter, string command)
if (!arv)
continue;
- Playlist* playlist = arv->region().playlist();
+ Playlist* playlist = arv->region()->playlist();
RegionSelection::iterator tmp;
tmp = r;
++tmp;
- if (arv->audio_region().apply (filter) == 0) {
+ if (arv->audio_region()->apply (filter) == 0) {
XMLNode &before = playlist->get_state();
- playlist->replace_region (arv->region(), *(filter.results.front()), arv->region().position());
+ playlist->replace_region (arv->region(), filter.results.front(), arv->region()->position());
XMLNode &after = playlist->get_state();
session->add_command(new MementoCommand<Playlist>(*playlist, &before, &after));
} else {
@@ -3494,7 +3490,8 @@ void
Editor::region_selection_op (void (Region::*pmf)(void))
{
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
- ((*i)->region().*pmf)();
+ Region* region = (*i)->region().get();
+ (region->*pmf)();
}
}
@@ -3503,7 +3500,8 @@ void
Editor::region_selection_op (void (Region::*pmf)(void*), void *arg)
{
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
- ((*i)->region().*pmf)(arg);
+ Region* region = (*i)->region().get();
+ (region->*pmf)(arg);
}
}
@@ -3511,7 +3509,8 @@ void
Editor::region_selection_op (void (Region::*pmf)(bool), bool yn)
{
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
- ((*i)->region().*pmf)(yn);
+ Region* region = (*i)->region().get();
+ (region->*pmf)(yn);
}
}
@@ -3562,6 +3561,6 @@ Editor::toggle_gain_envelope_active ()
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*i);
if (arv)
- arv->audio_region().set_envelope_active (true);
+ arv->audio_region()->set_envelope_active (true);
}
}
diff --git a/gtk2_ardour/editor_region_list.cc b/gtk2_ardour/editor_region_list.cc
index 5cf099433b..09a56e9af5 100644
--- a/gtk2_ardour/editor_region_list.cc
+++ b/gtk2_ardour/editor_region_list.cc
@@ -48,14 +48,14 @@ using namespace Glib;
using namespace Editing;
void
-Editor::handle_audio_region_removed (AudioRegion* region)
+Editor::handle_audio_region_removed (boost::shared_ptr<AudioRegion> region)
{
ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_audio_region_removed), region));
redisplay_regions ();
}
void
-Editor::handle_new_audio_region (AudioRegion *region)
+Editor::handle_new_audio_region (boost::shared_ptr<AudioRegion> region)
{
ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_new_audio_region), region));
@@ -67,7 +67,7 @@ Editor::handle_new_audio_region (AudioRegion *region)
}
void
-Editor::region_hidden (Region* r)
+Editor::region_hidden (boost::shared_ptr<Region> r)
{
ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::region_hidden), r));
@@ -75,7 +75,7 @@ Editor::region_hidden (Region* r)
}
void
-Editor::add_audio_region_to_region_display (AudioRegion *region)
+Editor::add_audio_region_to_region_display (boost::shared_ptr<AudioRegion> region)
{
string str;
TreeModel::Row row;
@@ -96,7 +96,7 @@ Editor::add_audio_region_to_region_display (AudioRegion *region)
parent = *(region_list_model->append());
parent[region_list_columns.name] = _("Hidden");
- parent[region_list_columns.region] = 0;
+ /// XXX FIX ME parent[region_list_columns.region]->reset ();
} else {
@@ -104,7 +104,7 @@ Editor::add_audio_region_to_region_display (AudioRegion *region)
parent = *(region_list_model->insert(iter));
parent[region_list_columns.name] = _("Hidden");
- parent[region_list_columns.region] = 0;
+ /// XXX FIX ME parent[region_list_columns.region]->reset ();
} else {
parent = *iter;
@@ -151,11 +151,11 @@ Editor::add_audio_region_to_region_display (AudioRegion *region)
for (i = rows.begin(); i != rows.end(); ++i) {
- Region* rr = (*i)[region_list_columns.region];
- AudioRegion* r = dynamic_cast<AudioRegion*>(rr);
+ boost::shared_ptr<Region> rr = (*i)[region_list_columns.region];
+ boost::shared_ptr<AudioRegion> r = boost::dynamic_pointer_cast<AudioRegion>(rr);
if (r && r->whole_file()) {
- if (region->source_equivalent (*r)) {
+ if (region->source_equivalent (r)) {
row = *(region_list_model->append ((*i).children()));
found_parent = true;
break;
@@ -200,13 +200,13 @@ Editor::region_list_selection_changed()
*/
if ((iter = region_list_model->get_iter (*i))) {
- set_selected_regionview_from_region_list (*((*iter)[region_list_columns.region]), Selection::Set);
+ set_selected_regionview_from_region_list (((*iter)[region_list_columns.region]), Selection::Set);
}
}
}
void
-Editor::insert_into_tmp_audio_regionlist(AudioRegion* region)
+Editor::insert_into_tmp_audio_regionlist(boost::shared_ptr<AudioRegion> region)
{
/* keep all whole files at the beginning */
@@ -232,7 +232,7 @@ Editor::redisplay_regions ()
tmp_audio_region_list.clear();
session->foreach_audio_region (this, &Editor::insert_into_tmp_audio_regionlist);
- for (list<AudioRegion*>::iterator r = tmp_audio_region_list.begin(); r != tmp_audio_region_list.end(); ++r) {
+ for (list<boost::shared_ptr<AudioRegion> >::iterator r = tmp_audio_region_list.begin(); r != tmp_audio_region_list.end(); ++r) {
add_audio_region_to_region_display (*r);
}
@@ -323,7 +323,7 @@ Editor::region_list_display_key_release (GdkEventKey* ev)
bool
Editor::region_list_display_button_press (GdkEventButton *ev)
{
- Region* region;
+ boost::shared_ptr<Region> region;
TreeIter iter;
TreeModel::Path path;
TreeViewColumn* column;
@@ -341,7 +341,7 @@ Editor::region_list_display_button_press (GdkEventButton *ev)
}
if (Keyboard::is_delete_event (ev)) {
- session->remove_region_from_region_list (*region);
+ session->remove_region_from_region_list (region);
return true;
}
@@ -354,7 +354,7 @@ Editor::region_list_display_button_press (GdkEventButton *ev)
case 1:
/* audition on double click */
if (ev->type == GDK_2BUTTON_PRESS) {
- consider_auditioning (*region);
+ consider_auditioning (region);
return true;
}
return false;
@@ -362,7 +362,7 @@ Editor::region_list_display_button_press (GdkEventButton *ev)
case 2:
if (!Keyboard::modifier_state_equals (ev->state, Keyboard::Control)) {
- consider_auditioning (*region);
+ consider_auditioning (region);
}
return true;
break;
@@ -382,7 +382,7 @@ Editor::region_list_display_button_release (GdkEventButton *ev)
TreeViewColumn* column;
int cellx;
int celly;
- Region* region = 0;
+ boost::shared_ptr<Region> region;
if (region_list_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
if ((iter = region_list_model->get_iter (path))) {
@@ -391,7 +391,7 @@ Editor::region_list_display_button_release (GdkEventButton *ev)
}
if (region && Keyboard::is_delete_event (ev)) {
- session->remove_region_from_region_list (*region);
+ session->remove_region_from_region_list (region);
return true;
}
@@ -399,9 +399,9 @@ Editor::region_list_display_button_release (GdkEventButton *ev)
}
void
-Editor::consider_auditioning (Region& region)
+Editor::consider_auditioning (boost::shared_ptr<Region> region)
{
- AudioRegion* r = dynamic_cast<AudioRegion*> (&region);
+ boost::shared_ptr<AudioRegion> r = boost::dynamic_pointer_cast<AudioRegion> (region);
if (r == 0) {
session->cancel_audition ();
@@ -415,7 +415,7 @@ Editor::consider_auditioning (Region& region)
}
}
- session->audition_region (*r);
+ session->audition_region (r);
last_audition_region = r;
}
@@ -424,8 +424,8 @@ Editor::region_list_sorter (TreeModel::iterator a, TreeModel::iterator b)
{
int cmp = 0;
- Region* r1 = (*a)[region_list_columns.region];
- Region* r2 = (*b)[region_list_columns.region];
+ boost::shared_ptr<Region> r1 = (*a)[region_list_columns.region];
+ boost::shared_ptr<Region> r2 = (*b)[region_list_columns.region];
/* handle rows without regions, like "Hidden" */
@@ -437,8 +437,8 @@ Editor::region_list_sorter (TreeModel::iterator a, TreeModel::iterator b)
return 1;
}
- AudioRegion* region1 = dynamic_cast<AudioRegion*> (r1);
- AudioRegion* region2 = dynamic_cast<AudioRegion*> (r2);
+ boost::shared_ptr<AudioRegion> region1 = boost::dynamic_pointer_cast<AudioRegion> (r1);
+ boost::shared_ptr<AudioRegion> region2 = boost::dynamic_pointer_cast<AudioRegion> (r2);
if (region1 == 0 || region2 == 0) {
Glib::ustring s1;
@@ -524,7 +524,7 @@ Editor::reset_region_list_sort_direction (bool up)
}
void
-Editor::region_list_selection_mapover (slot<void,Region&> sl)
+Editor::region_list_selection_mapover (slot<void,boost::shared_ptr<Region> > sl)
{
Glib::RefPtr<TreeSelection> selection = region_list_display.get_selection();
TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
@@ -538,19 +538,19 @@ Editor::region_list_selection_mapover (slot<void,Region&> sl)
TreeIter iter;
if ((iter = region_list_model->get_iter (*i))) {
- sl (*((*iter)[region_list_columns.region]));
+ sl (((*iter)[region_list_columns.region]));
}
}
}
void
-Editor::hide_a_region (Region& r)
+Editor::hide_a_region (boost::shared_ptr<Region> r)
{
- r.set_hidden (true);
+ r->set_hidden (true);
}
void
-Editor::remove_a_region (Region& r)
+Editor::remove_a_region (boost::shared_ptr<Region> r)
{
session->remove_region_from_region_list (r);
}
@@ -593,5 +593,7 @@ Editor::region_list_selection_filter (const RefPtr<TreeModel>& model, const Tree
{
/* not possible to select rows that do not represent regions, like "Hidden" */
- return (*(model->get_iter (path)))[region_list_columns.region] != 0;
+ /// XXXX FIXME boost::shared_ptr<Region> r = ((model->get_iter (path)))[region_list_columns.region];
+ /// return r != 0;
+ return true;
}
diff --git a/gtk2_ardour/editor_timefx.cc b/gtk2_ardour/editor_timefx.cc
index caa9698b8c..188960c962 100644
--- a/gtk2_ardour/editor_timefx.cc
+++ b/gtk2_ardour/editor_timefx.cc
@@ -160,21 +160,18 @@ Editor::do_timestretch (TimeStretchDialog& dialog)
{
Track* t;
Playlist* playlist;
- Region* new_region;
-
+ boost::shared_ptr<Region> new_region;
for (RegionSelection::iterator i = dialog.regions.begin(); i != dialog.regions.end(); ) {
AudioRegionView* arv = dynamic_cast<AudioRegionView*>(*i);
if (!arv)
continue;
- AudioRegion& region (arv->audio_region());
+ boost::shared_ptr<AudioRegion> region (arv->audio_region());
TimeAxisView* tv = &(arv->get_time_axis_view());
RouteTimeAxisView* rtv;
RegionSelection::iterator tmp;
- cerr << "stretch " << region.name() << endl;
-
tmp = i;
++tmp;
@@ -193,7 +190,7 @@ Editor::do_timestretch (TimeStretchDialog& dialog)
continue;
}
- dialog.request.region = &region;
+ dialog.request.region = region;
if (!dialog.request.running) {
/* we were cancelled */
@@ -208,7 +205,7 @@ Editor::do_timestretch (TimeStretchDialog& dialog)
}
XMLNode &before = playlist->get_state();
- playlist->replace_region (region, *new_region, region.position());
+ playlist->replace_region (region, new_region, region->position());
XMLNode &after = playlist->get_state();
session->add_command (new MementoCommand<Playlist>(*playlist, &before, &after));
@@ -217,6 +214,7 @@ Editor::do_timestretch (TimeStretchDialog& dialog)
dialog.status = 0;
dialog.request.running = false;
+ dialog.request.region.reset ();
}
void*
diff --git a/gtk2_ardour/export_dialog.cc b/gtk2_ardour/export_dialog.cc
index b5a4757090..ac4afb0b16 100644
--- a/gtk2_ardour/export_dialog.cc
+++ b/gtk2_ardour/export_dialog.cc
@@ -392,7 +392,7 @@ void
ExportDialog::connect_to_session (Session *s)
{
session = s;
- session->going_away.connect (mem_fun(*this, &Window::hide_all));
+ session->GoingAway.connect (mem_fun(*this, &Window::hide_all));
switch (session->frame_rate()) {
case 22050:
diff --git a/gtk2_ardour/export_region_dialog.cc b/gtk2_ardour/export_region_dialog.cc
index 1964fabbfe..3ed282761d 100644
--- a/gtk2_ardour/export_region_dialog.cc
+++ b/gtk2_ardour/export_region_dialog.cc
@@ -28,11 +28,10 @@
#include "i18n.h"
-ExportRegionDialog::ExportRegionDialog (PublicEditor& editor, ARDOUR::Region* region)
+ExportRegionDialog::ExportRegionDialog (PublicEditor& editor, boost::shared_ptr<ARDOUR::Region> region)
: ExportDialog(editor)
{
- // FIXME
- ARDOUR::AudioRegion* audio_region = dynamic_cast<ARDOUR::AudioRegion*>(region);
+ boost::shared_ptr<ARDOUR::AudioRegion> audio_region = boost::dynamic_pointer_cast<ARDOUR::AudioRegion>(region);
assert(audio_region);
do_not_allow_track_and_master_selection();
diff --git a/gtk2_ardour/export_region_dialog.h b/gtk2_ardour/export_region_dialog.h
index e8afe97d6b..a0457b7331 100644
--- a/gtk2_ardour/export_region_dialog.h
+++ b/gtk2_ardour/export_region_dialog.h
@@ -27,7 +27,7 @@
class ExportRegionDialog : public ExportDialog
{
public:
- ExportRegionDialog (PublicEditor&, ARDOUR::Region*);
+ ExportRegionDialog (PublicEditor&, boost::shared_ptr<ARDOUR::Region>);
static void* _export_region_thread (void *);
void export_region ();
@@ -36,7 +36,7 @@ class ExportRegionDialog : public ExportDialog
void export_audio_data();
private:
- ARDOUR::AudioRegion* audio_region;
+ boost::shared_ptr<ARDOUR::AudioRegion> audio_region;
};
diff --git a/gtk2_ardour/io_selector.cc b/gtk2_ardour/io_selector.cc
index f754435112..fda4a32acb 100644
--- a/gtk2_ardour/io_selector.cc
+++ b/gtk2_ardour/io_selector.cc
@@ -21,6 +21,8 @@
#include <map>
#include <vector>
+#include <sigc++/bind.h>
+
#include <gtkmm/messagedialog.h>
#include <glibmm/thread.h>
@@ -827,9 +829,9 @@ PortInsertWindow::PortInsertWindow (Session& sess, boost::shared_ptr<PortInsert>
}
void
-PortInsertWindow::plugin_going_away (ARDOUR::Redirect* ignored)
+PortInsertWindow::plugin_going_away ()
{
- ENSURE_GUI_THREAD(bind (mem_fun(*this, &PortInsertWindow::plugin_going_away), ignored));
+ ENSURE_GUI_THREAD(mem_fun(*this, &PortInsertWindow::plugin_going_away));
delete_when_idle (this);
}
diff --git a/gtk2_ardour/io_selector.h b/gtk2_ardour/io_selector.h
index 993d4aa1ad..b0175644a4 100644
--- a/gtk2_ardour/io_selector.h
+++ b/gtk2_ardour/io_selector.h
@@ -198,7 +198,7 @@ class PortInsertWindow : public ArdourDialog
void cancel ();
void accept ();
- void plugin_going_away (ARDOUR::Redirect*);
+ void plugin_going_away ();
};
diff --git a/gtk2_ardour/location_ui.cc b/gtk2_ardour/location_ui.cc
index 12e7079de2..125ed8df5d 100644
--- a/gtk2_ardour/location_ui.cc
+++ b/gtk2_ardour/location_ui.cc
@@ -836,7 +836,7 @@ LocationUI::set_session(ARDOUR::Session* sess)
session->locations()->StateChanged.connect (mem_fun(*this, &LocationUI::refresh_location_list_s));
session->locations()->added.connect (mem_fun(*this, &LocationUI::location_added));
session->locations()->removed.connect (mem_fun(*this, &LocationUI::location_removed));
- session->going_away.connect (mem_fun(*this, &LocationUI::session_gone));
+ session->GoingAway.connect (mem_fun(*this, &LocationUI::session_gone));
}
refresh_location_list ();
}
diff --git a/gtk2_ardour/meter_bridge.cc b/gtk2_ardour/meter_bridge.cc
index 65434d5e82..b871561563 100644
--- a/gtk2_ardour/meter_bridge.cc
+++ b/gtk2_ardour/meter_bridge.cc
@@ -101,7 +101,7 @@ MeterBridge::set_session (Session *s)
// (refs vs. ptrs)
// session->foreach_route (this, &MeterBridge::add_route);
session->RouteAdded.connect (mem_fun(*this, &MeterBridge::add_route));
- session->going_away.connect (mem_fun(*this, &MeterBridge::session_gone));
+ session->GoingAway.connect (mem_fun(*this, &MeterBridge::session_gone));
start_metering ();
}
}
@@ -171,7 +171,7 @@ MeterBridge::add_route (ARDOUR::Route* route)
meter->set_meter_on(true);
- session->going_away.connect (mem_fun(*this, &MeterBridge::session_gone));
+ session->GoingAway.connect (mem_fun(*this, &MeterBridge::session_gone));
}
void
diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc
index 84fade5472..9bc5f3d1a0 100644
--- a/gtk2_ardour/mixer_ui.cc
+++ b/gtk2_ardour/mixer_ui.cc
@@ -353,7 +353,7 @@ Mixer_UI::connect_to_session (Session* sess)
initial_track_display ();
- session->going_away.connect (mem_fun(*this, &Mixer_UI::disconnect_from_session));
+ session->GoingAway.connect (mem_fun(*this, &Mixer_UI::disconnect_from_session));
session->RouteAdded.connect (mem_fun(*this, &Mixer_UI::add_strip));
session->mix_group_added.connect (mem_fun(*this, &Mixer_UI::add_mix_group));
session->mix_group_removed.connect (mem_fun(*this, &Mixer_UI::mix_groups_changed));
diff --git a/gtk2_ardour/playlist_selector.cc b/gtk2_ardour/playlist_selector.cc
index 68227d193c..ffeaf8f5e9 100644
--- a/gtk2_ardour/playlist_selector.cc
+++ b/gtk2_ardour/playlist_selector.cc
@@ -205,7 +205,7 @@ PlaylistSelector::set_session (Session* s)
session = s;
if (session) {
- session->going_away.connect (bind (mem_fun(*this, &PlaylistSelector::set_session), static_cast<Session*> (0)));
+ session->GoingAway.connect (bind (mem_fun(*this, &PlaylistSelector::set_session), static_cast<Session*> (0)));
}
}
diff --git a/gtk2_ardour/plugin_selector.cc b/gtk2_ardour/plugin_selector.cc
index 6c72767b11..69f6f56690 100644
--- a/gtk2_ardour/plugin_selector.cc
+++ b/gtk2_ardour/plugin_selector.cc
@@ -244,7 +244,7 @@ PluginSelector::set_session (Session* s)
session = s;
if (session) {
- session->going_away.connect (bind (mem_fun(*this, &PluginSelector::set_session), static_cast<Session*> (0)));
+ session->GoingAway.connect (bind (mem_fun(*this, &PluginSelector::set_session), static_cast<Session*> (0)));
}
}
diff --git a/gtk2_ardour/plugin_ui.cc b/gtk2_ardour/plugin_ui.cc
index 154c2fd3cf..9cf054fbe2 100644
--- a/gtk2_ardour/plugin_ui.cc
+++ b/gtk2_ardour/plugin_ui.cc
@@ -131,9 +131,9 @@ PluginUIWindow::on_key_release_event (GdkEventKey* event)
}
void
-PluginUIWindow::plugin_going_away (ARDOUR::Redirect* ignored)
+PluginUIWindow::plugin_going_away ()
{
- ENSURE_GUI_THREAD(bind (mem_fun(*this, &PluginUIWindow::plugin_going_away), ignored));
+ ENSURE_GUI_THREAD(mem_fun(*this, &PluginUIWindow::plugin_going_away));
_pluginui->stop_updating(0);
delete_when_idle (this);
diff --git a/gtk2_ardour/plugin_ui.h b/gtk2_ardour/plugin_ui.h
index fd5516cee1..c1d538b3d1 100644
--- a/gtk2_ardour/plugin_ui.h
+++ b/gtk2_ardour/plugin_ui.h
@@ -207,7 +207,7 @@ class PluginUIWindow : public ArdourDialog
private:
PlugUIBase* _pluginui;
- void plugin_going_away (ARDOUR::Redirect*);
+ void plugin_going_away ();
};
#ifdef VST_SUPPORT
diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h
index f85210327c..142273ebd3 100644
--- a/gtk2_ardour/public_editor.h
+++ b/gtk2_ardour/public_editor.h
@@ -11,6 +11,8 @@
#include <jack/types.h>
#include <sigc++/signal.h>
+#include <pbd/statefuldestructible.h>
+
#include "editing.h"
#include "keyboard_target.h"
#include "canvas.h"
@@ -51,7 +53,7 @@ class ImageFrameView;
class ImageFrameTimeAxis;
class MarkerView;
-class PublicEditor : public Gtk::Window, public Stateful {
+class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible {
public:
PublicEditor();
virtual ~PublicEditor();
@@ -75,7 +77,7 @@ class PublicEditor : public Gtk::Window, public Stateful {
virtual void connect_to_image_compositor() = 0;
virtual void scroll_timeaxis_to_imageframe_item(const TimeAxisViewItem* item) = 0;
virtual TimeAxisView* get_named_time_axis(const string & name) = 0;
- virtual void consider_auditioning (ARDOUR::Region&) = 0;
+ virtual void consider_auditioning (boost::shared_ptr<ARDOUR::Region>) = 0;
virtual void set_show_waveforms (bool yn) = 0;
virtual bool show_waveforms() const = 0;
virtual void set_show_waveforms_recording (bool yn) = 0;
diff --git a/gtk2_ardour/region_gain_line.cc b/gtk2_ardour/region_gain_line.cc
index e2b1d6c826..467f24bd94 100644
--- a/gtk2_ardour/region_gain_line.cc
+++ b/gtk2_ardour/region_gain_line.cc
@@ -47,9 +47,9 @@ void
AudioRegionGainLine::start_drag (ControlPoint* cp, float fraction)
{
AutomationLine::start_drag(cp,fraction);
- if (!rv.audio_region().envelope_active()) {
- trackview.session().add_command(new MementoCommand<AudioRegion>(rv.audio_region(), &rv.audio_region().get_state(), 0));
- rv.audio_region().set_envelope_active(false);
+ if (!rv.audio_region()->envelope_active()) {
+ trackview.session().add_command(new MementoCommand<AudioRegion>(*(rv.audio_region().get()), &rv.audio_region()->get_state(), 0));
+ rv.audio_region()->set_envelope_active(false);
}
}
@@ -64,11 +64,11 @@ AudioRegionGainLine::remove_point (ControlPoint& cp)
trackview.editor.current_session()->begin_reversible_command (_("remove control point"));
XMLNode &before = get_state();
- if (!rv.audio_region().envelope_active()) {
- XMLNode &before = rv.audio_region().get_state();
- rv.audio_region().set_envelope_active(true);
- XMLNode &after = rv.audio_region().get_state();
- trackview.session().add_command(new MementoCommand<AudioRegion>(rv.audio_region(), &before, &after));
+ if (!rv.audio_region()->envelope_active()) {
+ XMLNode &before = rv.audio_region()->get_state();
+ rv.audio_region()->set_envelope_active(true);
+ XMLNode &after = rv.audio_region()->get_state();
+ trackview.session().add_command(new MementoCommand<AudioRegion>(*(rv.audio_region().get()), &before, &after));
}
alist.erase (mr.start, mr.end);
@@ -81,9 +81,9 @@ AudioRegionGainLine::remove_point (ControlPoint& cp)
void
AudioRegionGainLine::end_drag (ControlPoint* cp)
{
- if (!rv.audio_region().envelope_active()) {
- rv.audio_region().set_envelope_active(true);
- trackview.session().add_command(new MementoCommand<AudioRegion>(rv.audio_region(), 0, &rv.audio_region().get_state()));
+ if (!rv.audio_region()->envelope_active()) {
+ rv.audio_region()->set_envelope_active(true);
+ trackview.session().add_command(new MementoCommand<AudioRegion>(*(rv.audio_region().get()), 0, &rv.audio_region()->get_state()));
}
AutomationLine::end_drag(cp);
}
diff --git a/gtk2_ardour/region_selection.cc b/gtk2_ardour/region_selection.cc
index f8c9f384a9..7f7148d2b1 100644
--- a/gtk2_ardour/region_selection.cc
+++ b/gtk2_ardour/region_selection.cc
@@ -102,12 +102,12 @@ RegionSelection::add (RegionView* rv, bool dosort)
rv->RegionViewGoingAway.connect (mem_fun(*this, &RegionSelection::remove_it));
- if (rv->region().first_frame() < _current_start || empty()) {
- _current_start = rv->region().first_frame();
+ if (rv->region()->first_frame() < _current_start || empty()) {
+ _current_start = rv->region()->first_frame();
}
- if (rv->region().last_frame() > _current_end || empty()) {
- _current_end = rv->region().last_frame();
+ if (rv->region()->last_frame() > _current_end || empty()) {
+ _current_end = rv->region()->last_frame();
}
insert (rv);
@@ -142,17 +142,17 @@ RegionSelection::remove (RegionView* rv)
} else {
- Region& region ((*i)->region());
+ boost::shared_ptr<Region> region ((*i)->region());
- if (region.first_frame() == _current_start) {
+ if (region->first_frame() == _current_start) {
/* reset current start */
jack_nframes_t ref = max_frames;
for (i = begin (); i != end(); ++i) {
- if (region.first_frame() < ref) {
- ref = region.first_frame();
+ if (region->first_frame() < ref) {
+ ref = region->first_frame();
}
}
@@ -160,15 +160,15 @@ RegionSelection::remove (RegionView* rv)
}
- if (region.last_frame() == _current_end) {
+ if (region->last_frame() == _current_end) {
/* reset current end */
jack_nframes_t ref = 0;
for (i = begin (); i != end(); ++i) {
- if (region.first_frame() > ref) {
- ref = region.first_frame();
+ if (region->first_frame() > ref) {
+ ref = region->first_frame();
}
}
@@ -191,7 +191,7 @@ RegionSelection::add_to_layer (RegionView * rv)
for (i = _bylayer.begin(); i != _bylayer.end(); ++i)
{
- if (rv->region().layer() < (*i)->region().layer()) {
+ if (rv->region()->layer() < (*i)->region()->layer()) {
_bylayer.insert(i, rv);
return;
}
@@ -203,7 +203,7 @@ RegionSelection::add_to_layer (RegionView * rv)
struct RegionSortByTime {
bool operator() (const RegionView* a, const RegionView* b) {
- return a->region().position() < b->region().position();
+ return a->region()->position() < b->region()->position();
}
};
diff --git a/gtk2_ardour/region_view.cc b/gtk2_ardour/region_view.cc
index 8e80b147e5..4c63c89152 100644
--- a/gtk2_ardour/region_view.cc
+++ b/gtk2_ardour/region_view.cc
@@ -59,33 +59,33 @@ sigc::signal<void,RegionView*> RegionView::RegionViewGoingAway;
RegionView::RegionView (ArdourCanvas::Group* parent,
TimeAxisView& tv,
- ARDOUR::Region& r,
+ boost::shared_ptr<ARDOUR::Region> r,
double spu,
Gdk::Color& basic_color)
- : TimeAxisViewItem (r.name(), *parent, tv, spu, basic_color, r.position(), r.length(),
- TimeAxisViewItem::Visibility (TimeAxisViewItem::ShowNameText|
- TimeAxisViewItem::ShowNameHighlight|
- TimeAxisViewItem::ShowFrame))
- , _region (r)
- , sync_mark(0)
- , no_wave_msg(0)
- , editor(0)
- , current_visible_sync_position(0.0)
- , valid(false)
- , _pixel_width(1.0)
- , _height(1.0)
- , in_destructor(false)
- , wait_for_data(false)
+ : TimeAxisViewItem (r->name(), *parent, tv, spu, basic_color, r->position(), r->length(),
+ TimeAxisViewItem::Visibility (TimeAxisViewItem::ShowNameText|
+ TimeAxisViewItem::ShowNameHighlight|
+ TimeAxisViewItem::ShowFrame))
+ , _region (r)
+ , sync_mark(0)
+ , no_wave_msg(0)
+ , editor(0)
+ , current_visible_sync_position(0.0)
+ , valid(false)
+ , _pixel_width(1.0)
+ , _height(1.0)
+ , in_destructor(false)
+ , wait_for_data(false)
{
}
RegionView::RegionView (ArdourCanvas::Group* parent,
TimeAxisView& tv,
- ARDOUR::Region& r,
+ boost::shared_ptr<ARDOUR::Region> r,
double spu,
Gdk::Color& basic_color,
TimeAxisViewItem::Visibility visibility)
- : TimeAxisViewItem (r.name(), *parent, tv, spu, basic_color, r.position(), r.length(), visibility)
+ : TimeAxisViewItem (r->name(), *parent, tv, spu, basic_color, r->position(), r->length(), visibility)
, _region (r)
, sync_mark(0)
, no_wave_msg(0)
@@ -129,7 +129,7 @@ RegionView::init (Gdk::Color& basic_color, bool wfd)
sync_mark->property_fill_color_rgba() = fill_color;
sync_mark->hide();
- reset_width_dependent_items ((double) _region.length() / samples_per_unit);
+ reset_width_dependent_items ((double) _region->length() / samples_per_unit);
set_height (trackview.height);
@@ -138,7 +138,7 @@ RegionView::init (Gdk::Color& basic_color, bool wfd)
region_resized (BoundsChanged);
region_locked ();
- _region.StateChanged.connect (mem_fun(*this, &RegionView::region_changed));
+ _region->StateChanged.connect (mem_fun(*this, &RegionView::region_changed));
group->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_region_view_event), group, this));
name_highlight->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_region_view_name_highlight_event), name_highlight, this));
@@ -182,7 +182,7 @@ RegionView::_lock_toggle (ArdourCanvas::Item* item, GdkEvent* ev, void* arg)
void
RegionView::lock_toggle ()
{
- _region.set_locked (!_region.locked());
+ _region->set_locked (!_region->locked());
}
void
@@ -227,14 +227,14 @@ RegionView::region_resized (Change what_changed)
double unit_length;
if (what_changed & ARDOUR::PositionChanged) {
- set_position (_region.position(), 0);
+ set_position (_region->position(), 0);
}
if (what_changed & Change (StartChanged|LengthChanged)) {
- set_duration (_region.length(), 0);
+ set_duration (_region->length(), 0);
- unit_length = _region.length() / samples_per_unit;
+ unit_length = _region->length() / samples_per_unit;
reset_width_dependent_items (unit_length);
@@ -277,25 +277,25 @@ RegionView::region_opacity ()
void
RegionView::raise ()
{
- _region.raise ();
+ _region->raise ();
}
void
RegionView::raise_to_top ()
{
- _region.raise_to_top ();
+ _region->raise_to_top ();
}
void
RegionView::lower ()
{
- _region.lower ();
+ _region->lower ();
}
void
RegionView::lower_to_bottom ()
{
- _region.lower_to_bottom ();
+ _region->lower_to_bottom ();
}
bool
@@ -328,7 +328,7 @@ RegionView::set_samples_per_unit (gdouble spu)
for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
(*i)->set_samples_per_unit (spu);
- (*i)->set_duration (_region.length() / samples_per_unit);
+ (*i)->set_duration (_region->length() / samples_per_unit);
}
region_sync_changed ();
@@ -342,7 +342,7 @@ RegionView::set_duration (jack_nframes_t frames, void *src)
}
for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
- (*i)->set_duration (_region.length() / samples_per_unit);
+ (*i)->set_duration (_region->length() / samples_per_unit);
}
return true;
@@ -367,7 +367,7 @@ RegionView::set_colors ()
void
RegionView::set_frame_color ()
{
- if (_region.opaque()) {
+ if (_region->opaque()) {
fill_opacity = 180;
} else {
fill_opacity = 100;
@@ -389,19 +389,19 @@ RegionView::region_renamed ()
{
string str;
- if (_region.locked()) {
+ if (_region->locked()) {
str += '>';
- str += _region.name();
+ str += _region->name();
str += '<';
} else {
- str = _region.name();
+ str = _region->name();
}
- if (_region.speed_mismatch (trackview.session().frame_rate())) {
+ if (_region->speed_mismatch (trackview.session().frame_rate())) {
str = string ("*") + str;
}
- if (_region.muted()) {
+ if (_region->muted()) {
str = string ("!") + str;
}
@@ -419,10 +419,10 @@ RegionView::region_sync_changed ()
int sync_dir;
jack_nframes_t sync_offset;
- sync_offset = _region.sync_offset (sync_dir);
+ sync_offset = _region->sync_offset (sync_dir);
/* this has to handle both a genuine change of position, a change of samples_per_unit,
- and a change in the bounds of the _region.
+ and a change in the bounds of the _region->
*/
if (sync_offset == 0) {
@@ -433,7 +433,7 @@ RegionView::region_sync_changed ()
} else {
- if ((sync_dir < 0) || ((sync_dir > 0) && (sync_offset > _region.length()))) {
+ if ((sync_dir < 0) || ((sync_dir > 0) && (sync_offset > _region->length()))) {
/* no sync mark - its out of the bounds of the region */
@@ -462,7 +462,7 @@ RegionView::region_sync_changed ()
void
RegionView::move (double x_delta, double y_delta)
{
- if (_region.locked() || (x_delta == 0 && y_delta == 0)) {
+ if (_region->locked() || (x_delta == 0 && y_delta == 0)) {
return;
}
diff --git a/gtk2_ardour/region_view.h b/gtk2_ardour/region_view.h
index fdc69ea70e..6f77a48cc8 100644
--- a/gtk2_ardour/region_view.h
+++ b/gtk2_ardour/region_view.h
@@ -43,7 +43,7 @@ class RegionView : public TimeAxisViewItem
public:
RegionView (ArdourCanvas::Group* parent,
TimeAxisView& time_view,
- ARDOUR::Region& region,
+ boost::shared_ptr<ARDOUR::Region> region,
double samples_per_unit,
Gdk::Color& basic_color);
@@ -51,7 +51,7 @@ class RegionView : public TimeAxisViewItem
virtual void init (Gdk::Color& base_color, bool wait_for_data);
- ARDOUR::Region& region() const { return _region; }
+ boost::shared_ptr<ARDOUR::Region> region() const { return _region; }
bool is_valid() const { return valid; }
void set_valid (bool yn) { valid = yn; }
@@ -91,11 +91,11 @@ class RegionView : public TimeAxisViewItem
* to the TimeAxisViewItem parent class
*/
RegionView (ArdourCanvas::Group *,
- TimeAxisView&,
- ARDOUR::Region&,
- double samples_per_unit,
- Gdk::Color& basic_color,
- TimeAxisViewItem::Visibility);
+ TimeAxisView&,
+ boost::shared_ptr<ARDOUR::Region>,
+ double samples_per_unit,
+ Gdk::Color& basic_color,
+ TimeAxisViewItem::Visibility);
virtual void region_resized (ARDOUR::Change);
void region_moved (void *);
@@ -116,7 +116,7 @@ class RegionView : public TimeAxisViewItem
virtual void color_handler (ColorID, uint32_t) {}
- ARDOUR::Region& _region;
+ boost::shared_ptr<ARDOUR::Region> _region;
ArdourCanvas::Polygon* sync_mark; ///< polgyon for sync position
ArdourCanvas::Text* no_wave_msg;
@@ -130,11 +130,11 @@ class RegionView : public TimeAxisViewItem
double _pixel_width;
double _height;
bool in_destructor;
-
+
bool wait_for_data;
- sigc::connection data_ready_connection;
+ sigc::connection data_ready_connection;
- vector<GhostRegion*> ghosts;
+ vector<GhostRegion*> ghosts;
};
#endif /* __gtk_ardour_region_view_h__ */
diff --git a/gtk2_ardour/route_params_ui.cc b/gtk2_ardour/route_params_ui.cc
index c23ed272e1..5f61b0528c 100644
--- a/gtk2_ardour/route_params_ui.cc
+++ b/gtk2_ardour/route_params_ui.cc
@@ -361,7 +361,7 @@ RouteParams_UI::set_session (Session *sess)
if (session) {
boost::shared_ptr<Session::RouteList> r = session->get_routes();
add_routes (*r);
- session->going_away.connect (mem_fun(*this, &ArdourDialog::session_gone));
+ session->GoingAway.connect (mem_fun(*this, &ArdourDialog::session_gone));
session->RouteAdded.connect (mem_fun(*this, &RouteParams_UI::add_routes));
start_updating ();
} else {
@@ -537,7 +537,7 @@ RouteParams_UI::redirect_selected (boost::shared_ptr<ARDOUR::Redirect> redirect,
if (place == PreFader) {
cleanup_pre_view();
- _pre_plugin_conn = send->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
+ _pre_plugin_conn = send->GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_going_away), redirect));
_active_pre_view = send_ui;
pre_redir_hpane.add2 (*_active_pre_view);
@@ -545,7 +545,7 @@ RouteParams_UI::redirect_selected (boost::shared_ptr<ARDOUR::Redirect> redirect,
}
else {
cleanup_post_view();
- _post_plugin_conn = send->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
+ _post_plugin_conn = send->GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_going_away), redirect));
_active_post_view = send_ui;
post_redir_hpane.add2 (*_active_post_view);
@@ -586,7 +586,7 @@ RouteParams_UI::redirect_selected (boost::shared_ptr<ARDOUR::Redirect> redirect,
if (place == PreFader) {
cleanup_pre_view();
- _pre_plugin_conn = port_insert->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
+ _pre_plugin_conn = port_insert->GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_going_away), redirect));
_active_pre_view = portinsert_ui;
pre_redir_hpane.pack2 (*_active_pre_view);
portinsert_ui->redisplay();
@@ -594,7 +594,7 @@ RouteParams_UI::redirect_selected (boost::shared_ptr<ARDOUR::Redirect> redirect,
}
else {
cleanup_post_view();
- _post_plugin_conn = port_insert->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
+ _post_plugin_conn = port_insert->GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_going_away), redirect));
_active_post_view = portinsert_ui;
post_redir_hpane.pack2 (*_active_post_view);
portinsert_ui->redisplay();
@@ -615,9 +615,9 @@ RouteParams_UI::redirect_selected (boost::shared_ptr<ARDOUR::Redirect> redirect,
}
void
-RouteParams_UI::plugin_going_away (Plugin *plugin, Placement place)
+RouteParams_UI::plugin_going_away (Placement place)
{
- ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), plugin, place));
+ ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), place));
// delete the current view without calling finish
@@ -632,18 +632,17 @@ RouteParams_UI::plugin_going_away (Plugin *plugin, Placement place)
}
void
-RouteParams_UI::redirect_going_away (ARDOUR::Redirect *plugin)
+RouteParams_UI::redirect_going_away (boost::shared_ptr<ARDOUR::Redirect> redirect)
{
- ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::redirect_going_away), plugin));
+ ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::redirect_going_away), redirect));
printf ("redirect going away\n");
// delete the current view without calling finish
- if (plugin == _pre_redirect.get()) {
+ if (redirect == _pre_redirect) {
cleanup_pre_view (false);
_pre_redirect.reset ((Redirect*) 0);
- }
- else if (plugin == _post_redirect.get()) {
+ } else if (redirect == _post_redirect) {
cleanup_post_view (false);
_post_redirect.reset ((Redirect*) 0);
}
diff --git a/gtk2_ardour/route_params_ui.h b/gtk2_ardour/route_params_ui.h
index eff31023f7..394383de6b 100644
--- a/gtk2_ardour/route_params_ui.h
+++ b/gtk2_ardour/route_params_ui.h
@@ -182,8 +182,8 @@ class RouteParams_UI : public ArdourDialog
void redirect_selected (boost::shared_ptr<ARDOUR::Redirect>, ARDOUR::Placement);
- void plugin_going_away (ARDOUR::Plugin *foo, ARDOUR::Placement);
- void redirect_going_away (ARDOUR::Redirect *foo);
+ void plugin_going_away (ARDOUR::Placement);
+ void redirect_going_away (boost::shared_ptr<ARDOUR::Redirect>);
gint edit_input_configuration (GdkEventButton *ev);
gint edit_output_configuration (GdkEventButton *ev);
diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc
index e7a6df2f27..27d1739fd4 100644
--- a/gtk2_ardour/route_time_axis.cc
+++ b/gtk2_ardour/route_time_axis.cc
@@ -1010,7 +1010,7 @@ RouteTimeAxisView::hide_click ()
editor.hide_track_in_display (*this);
}
-Region*
+boost::shared_ptr<Region>
RouteTimeAxisView::find_next_region (jack_nframes_t pos, RegionPoint point, int32_t dir)
{
boost::shared_ptr<Diskstream> stream;
@@ -1020,7 +1020,7 @@ RouteTimeAxisView::find_next_region (jack_nframes_t pos, RegionPoint point, int3
return playlist->find_next_region (pos, point, dir);
}
- return 0;
+ return boost::shared_ptr<Region> ();
}
bool
diff --git a/gtk2_ardour/route_time_axis.h b/gtk2_ardour/route_time_axis.h
index d305fd390c..f3643de68b 100644
--- a/gtk2_ardour/route_time_axis.h
+++ b/gtk2_ardour/route_time_axis.h
@@ -81,7 +81,7 @@ public:
void get_selectables (jack_nframes_t start, jack_nframes_t end, double top, double bot, list<Selectable *>&);
void get_inverted_selectables (Selection&, list<Selectable*>&);
- ARDOUR::Region* find_next_region (jack_nframes_t pos, ARDOUR::RegionPoint, int32_t dir);
+ boost::shared_ptr<ARDOUR::Region> find_next_region (jack_nframes_t pos, ARDOUR::RegionPoint, int32_t dir);
/* Editing operations */
bool cut_copy_clear (Selection&, Editing::CutCopyOp);
diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc
index aa7fdbe30f..9d171e484d 100644
--- a/gtk2_ardour/selection.cc
+++ b/gtk2_ardour/selection.cc
@@ -84,7 +84,7 @@ Selection::dump_region_layers()
{
cerr << "region selection layer dump" << endl;
for (RegionSelection::iterator i = regions.begin(); i != regions.end(); ++i) {
- cerr << "layer: " << (int)(*i)->region().layer() << endl;
+ cerr << "layer: " << (int)(*i)->region()->layer() << endl;
}
}
diff --git a/gtk2_ardour/selection_templates.h b/gtk2_ardour/selection_templates.h
index 9511db7d61..5440112ad6 100644
--- a/gtk2_ardour/selection_templates.h
+++ b/gtk2_ardour/selection_templates.h
@@ -34,33 +34,17 @@
inline void
Selection::foreach_region (void (ARDOUR::Region::*method)(void)) {
for (RegionSelection::iterator i = regions.begin(); i != regions.end(); ++i) {
- ((*i)->region().*(method))();
+ ARDOUR::Region* region = (*i)->region().get();
+ (region->*(method))();
}
}
template<class A> inline void
Selection::foreach_region (void (ARDOUR::Region::*method)(A), A arg) {
for (RegionSelection::iterator i = regions.begin(); i != regions.end(); ++i) {
- ((*i)->region().*(method))(arg);
+ ARDOUR::Region* region = (*i)->region().get();
+ (region->*(method))(arg);
}
}
-#if 0
-
-template<class A> inline void
-Selection::foreach_route (void (ARDOUR::Route::*method)(A), A arg) {
- for (list<ARDOUR::Route*>::iterator i = routes.begin(); i != routes.end(); ++i) {
- ((*i)->region().*(method))(arg);
- }
-}
-
-template<class A1, class A2> inline void
-Selection::foreach_route (void (ARDOUR::Route::*method)(A1,A2), A1 arg1, A2 arg2) {
- for (list<ARDOUR::Route*>::iterator i = routes.begin(); i != routes.end(); ++i) {
- ((*i)->region().*(method))(arg1, arg2);
- }
-}
-
-#endif
-
#endif /* __ardour_gtk_selection_templates_h__ */
diff --git a/gtk2_ardour/send_ui.cc b/gtk2_ardour/send_ui.cc
index 9925ff51d4..897f5f3847 100644
--- a/gtk2_ardour/send_ui.cc
+++ b/gtk2_ardour/send_ui.cc
@@ -98,9 +98,9 @@ SendUI::outs_changed (IOChange change, void* ignored)
}
void
-SendUI::send_going_away (Redirect *ignored)
+SendUI::send_going_away ()
{
- ENSURE_GUI_THREAD (bind (mem_fun (*this, &SendUI::send_going_away), ignored));
+ ENSURE_GUI_THREAD (mem_fun (*this, &SendUI::send_going_away))
delete this;
}
@@ -143,9 +143,9 @@ SendUIWindow::~SendUIWindow ()
}
void
-SendUIWindow::send_going_away (Redirect *ignored)
+SendUIWindow::send_going_away ()
{
- ENSURE_GUI_THREAD(bind (mem_fun (*this, &SendUIWindow::send_going_away), ignored));
+ ENSURE_GUI_THREAD (mem_fun (*this, &SendUIWindow::send_going_away));
delete this;
}
diff --git a/gtk2_ardour/send_ui.h b/gtk2_ardour/send_ui.h
index 1d5a74e102..c8576cab9e 100644
--- a/gtk2_ardour/send_ui.h
+++ b/gtk2_ardour/send_ui.h
@@ -54,7 +54,7 @@ class SendUI : public Gtk::HBox
sigc::connection screen_update_connection;
sigc::connection fast_screen_update_connection;
- void send_going_away (ARDOUR::Redirect*);
+ void send_going_away ();
void ins_changed (ARDOUR::IOChange, void*);
void outs_changed (ARDOUR::IOChange, void*);
};
@@ -71,7 +71,7 @@ class SendUIWindow : public Gtk::Window
Gtk::VBox vpacker;
Gtk::HBox hpacker;
- void send_going_away (ARDOUR::Redirect*);
+ void send_going_away ();
};
#endif /* __ardour_gtk_send_ui_h__ */
diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc
index d9ded04d2b..34dcf56ec3 100644
--- a/gtk2_ardour/sfdb_ui.cc
+++ b/gtk2_ardour/sfdb_ui.cc
@@ -32,6 +32,7 @@
#include <ardour/audio_library.h>
#include <ardour/audioregion.h>
#include <ardour/audiofilesource.h>
+#include <ardour/region_factory.h>
#include "ardour_ui.h"
#include "gui_thread.h"
@@ -187,10 +188,10 @@ SoundFileBox::play_btn_clicked ()
return;
}
- static std::map<string, AudioRegion*> region_cache;
+ static std::map<string, boost::shared_ptr<AudioRegion> > region_cache;
if (region_cache.find (path) == region_cache.end()) {
- AudioRegion::SourceList srclist;
+ SourceList srclist;
AudioFileSource* afs;
for (int n = 0; n < sf_info.channels; ++n) {
@@ -208,16 +209,18 @@ SoundFileBox::play_btn_clicked ()
return;
}
- string result;
- _session->region_name (result, Glib::path_get_basename(srclist[0]->name()), false);
- AudioRegion* a_region = new AudioRegion(srclist, 0, srclist[0]->length(), result, 0, Region::DefaultFlags, false);
- region_cache[path] = a_region;
+ pair<string,boost::shared_ptr<AudioRegion> > newpair;
+
+ _session->region_name (newpair.first, Glib::path_get_basename(srclist[0]->name()), false);
+ newpair.second = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (srclist, 0, srclist[0]->length(), newpair.first, 0, Region::DefaultFlags, false));
+
+ region_cache.insert (newpair);
}
play_btn.hide();
stop_btn.show();
- _session->audition_region(*region_cache[path]);
+ _session->audition_region(region_cache[path]);
}
void
diff --git a/gtk2_ardour/streamview.cc b/gtk2_ardour/streamview.cc
index 733e27c4ab..555112e081 100644
--- a/gtk2_ardour/streamview.cc
+++ b/gtk2_ardour/streamview.cc
@@ -158,18 +158,18 @@ StreamView::set_samples_per_unit (gdouble spp)
}
void
-StreamView::add_region_view (Region *r)
+StreamView::add_region_view (boost::shared_ptr<Region> r)
{
add_region_view_internal (r, true);
}
void
-StreamView::remove_region_view (Region *r)
+StreamView::remove_region_view (boost::shared_ptr<Region> r)
{
ENSURE_GUI_THREAD (bind (mem_fun (*this, &StreamView::remove_region_view), r));
for (list<RegionView *>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
- if (&((*i)->region()) == r) {
+ if (((*i)->region()) == r) {
delete *i;
region_views.erase (i);
break;
@@ -178,7 +178,7 @@ StreamView::remove_region_view (Region *r)
}
void
-StreamView::remove_rec_region (Region *r)
+StreamView::remove_rec_region (boost::shared_ptr<Region> r)
{
ENSURE_GUI_THREAD(bind (mem_fun (*this, &StreamView::remove_rec_region), r));
@@ -187,7 +187,7 @@ StreamView::remove_rec_region (Region *r)
/*NOTREACHED*/
}
- for (list<Region *>::iterator i = rec_regions.begin(); i != rec_regions.end(); ++i) {
+ for (list<boost::shared_ptr<Region> >::iterator i = rec_regions.begin(); i != rec_regions.end(); ++i) {
if (*i == r) {
rec_regions.erase (i);
break;
@@ -303,7 +303,7 @@ StreamView::region_layered (RegionView* rv)
/* this used to be + 1, but regions to the left ended up below
..something.. and couldn't receive events. why? good question.
*/
- rv->get_canvas_group()->raise (rv->region().layer() + 2);
+ rv->get_canvas_group()->raise (rv->region()->layer() + 2);
}
void
@@ -354,11 +354,11 @@ StreamView::update_rec_box ()
}
RegionView*
-StreamView::find_view (const Region& region)
+StreamView::find_view (boost::shared_ptr<const Region> region)
{
for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
- if (&(*i)->region() == &region) {
+ if ((*i)->region() == region) {
return *i;
}
}
@@ -398,7 +398,7 @@ void
StreamView::get_selectables (jack_nframes_t start, jack_nframes_t end, list<Selectable*>& results)
{
for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
- if ((*i)->region().coverage(start, end) != OverlapNone) {
+ if ((*i)->region()->coverage(start, end) != OverlapNone) {
results.push_back (*i);
}
}
diff --git a/gtk2_ardour/streamview.h b/gtk2_ardour/streamview.h
index 8f7fb416be..64a1ef74c1 100644
--- a/gtk2_ardour/streamview.h
+++ b/gtk2_ardour/streamview.h
@@ -83,14 +83,14 @@ public:
Gdk::Color get_region_color () const { return region_color; }
void apply_color (Gdk::Color&, ColorTarget t);
- RegionView* find_view (const ARDOUR::Region&);
+ RegionView* find_view (boost::shared_ptr<const ARDOUR::Region>);
void foreach_regionview (sigc::slot<void,RegionView*> slot);
void set_selected_regionviews (RegionSelection&);
void get_selectables (jack_nframes_t start, jack_nframes_t end, list<Selectable* >&);
void get_inverted_selectables (Selection&, list<Selectable* >& results);
- void add_region_view (ARDOUR::Region*);
+ void add_region_view (boost::shared_ptr<ARDOUR::Region>);
void region_layered (RegionView*);
sigc::signal<void,RegionView*> RegionViewAdded;
@@ -107,9 +107,9 @@ protected:
void update_rec_box ();
virtual void update_rec_regions () = 0;
- virtual void add_region_view_internal (ARDOUR::Region*, bool wait_for_waves) = 0;
- virtual void remove_region_view (ARDOUR::Region* );
- void remove_rec_region (ARDOUR::Region*);
+ virtual void add_region_view_internal (boost::shared_ptr<ARDOUR::Region>, bool wait_for_waves) = 0;
+ virtual void remove_region_view (boost::shared_ptr<ARDOUR::Region> );
+ void remove_rec_region (boost::shared_ptr<ARDOUR::Region>);
void display_diskstream (boost::shared_ptr<ARDOUR::Diskstream>);
virtual void undisplay_diskstream ();
@@ -134,7 +134,7 @@ protected:
sigc::connection screen_update_connection;
vector<RecBoxInfo> rec_rects;
- list<ARDOUR::Region* > rec_regions;
+ list<boost::shared_ptr<ARDOUR::Region> > rec_regions;
bool rec_updating;
bool rec_active;
bool use_rec_regions;
diff --git a/gtk2_ardour/tape_region_view.cc b/gtk2_ardour/tape_region_view.cc
index bd5ce8af02..e71429ed3a 100644
--- a/gtk2_ardour/tape_region_view.cc
+++ b/gtk2_ardour/tape_region_view.cc
@@ -50,12 +50,12 @@ const TimeAxisViewItem::Visibility TapeAudioRegionView::default_tape_visibility
TimeAxisViewItem::FullWidthNameHighlight);
TapeAudioRegionView::TapeAudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv,
- AudioRegion& r,
+ boost::shared_ptr<AudioRegion> r,
double spu,
Gdk::Color& basic_color)
: AudioRegionView (parent, tv, r, spu, basic_color,
- TimeAxisViewItem::Visibility ((r.position() != 0) ? default_tape_visibility :
+ TimeAxisViewItem::Visibility ((r->position() != 0) ? default_tape_visibility :
TimeAxisViewItem::Visibility (default_tape_visibility|TimeAxisViewItem::HideFrameLeft)))
{
}
@@ -67,8 +67,8 @@ TapeAudioRegionView::init (Gdk::Color& basic_color, bool wfw)
/* every time the wave data changes and peaks are ready, redraw */
- for (uint32_t n = 0; n < audio_region().n_channels(); ++n) {
- audio_region().source(n).PeaksReady.connect (bind (mem_fun(*this, &TapeAudioRegionView::update), n));
+ for (uint32_t n = 0; n < audio_region()->n_channels(); ++n) {
+ audio_region()->source(n).PeaksReady.connect (bind (mem_fun(*this, &TapeAudioRegionView::update), n));
}
}
@@ -90,7 +90,7 @@ TapeAudioRegionView::update (uint32_t n)
/* this triggers a cache invalidation and redraw in the waveview */
- waves[n]->property_data_src() = &_region;
+ waves[n]->property_data_src() = _region.get();
}
void
diff --git a/gtk2_ardour/tape_region_view.h b/gtk2_ardour/tape_region_view.h
index ed3852e3a9..fbedf19ebc 100644
--- a/gtk2_ardour/tape_region_view.h
+++ b/gtk2_ardour/tape_region_view.h
@@ -30,7 +30,7 @@ class TapeAudioRegionView : public AudioRegionView
public:
TapeAudioRegionView (ArdourCanvas::Group *,
RouteTimeAxisView&,
- ARDOUR::AudioRegion&,
+ boost::shared_ptr<ARDOUR::AudioRegion>,
double initial_samples_per_unit,
Gdk::Color& base_color);
~TapeAudioRegionView ();
diff --git a/gtk2_ardour/time_axis_view.h b/gtk2_ardour/time_axis_view.h
index 31ff3d84ee..e5d2be52e6 100644
--- a/gtk2_ardour/time_axis_view.h
+++ b/gtk2_ardour/time_axis_view.h
@@ -186,8 +186,8 @@ class TimeAxisView : public virtual AxisView
virtual void set_selected_regionviews (RegionSelection&) {}
virtual void set_selected_points (PointSelection&) {}
- virtual ARDOUR::Region* find_next_region (jack_nframes_t pos, ARDOUR::RegionPoint, int32_t dir) {
- return 0;
+ virtual boost::shared_ptr<ARDOUR::Region> find_next_region (jack_nframes_t pos, ARDOUR::RegionPoint, int32_t dir) {
+ return boost::shared_ptr<ARDOUR::Region> ();
}
void order_selection_trims (ArdourCanvas::Item *item, bool put_start_on_top);
diff --git a/libs/ardour/SConscript b/libs/ardour/SConscript
index 44cec8638c..09fd5e9b8e 100644
--- a/libs/ardour/SConscript
+++ b/libs/ardour/SConscript
@@ -70,6 +70,7 @@ port.cc
recent_sessions.cc
redirect.cc
region.cc
+region_factory.cc
reverse.cc
route.cc
route_group.cc
diff --git a/libs/ardour/ardour/audio_diskstream.h b/libs/ardour/ardour/audio_diskstream.h
index 18f8328cfd..eaa69e00d8 100644
--- a/libs/ardour/ardour/audio_diskstream.h
+++ b/libs/ardour/ardour/audio_diskstream.h
@@ -141,8 +141,6 @@ class AudioDiskstream : public Diskstream
}
}
- std::list<Region*>& last_capture_regions () { return _last_capture_regions; }
-
XMLNode* deprecated_io_node;
protected:
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 0c08392325..ad8672a269 100644
--- a/libs/ardour/ardour/audioregion.h
+++ b/libs/ardour/ardour/audioregion.h
@@ -57,8 +57,6 @@ struct AudioRegionState : public RegionState
class AudioRegion : public Region
{
public:
- typedef vector<AudioSource *> SourceList;
-
static Change FadeInChanged;
static Change FadeOutChanged;
static Change FadeInActiveChanged;
@@ -67,16 +65,9 @@ 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 source_equivalent (const Region&) const;
+ bool source_equivalent (boost::shared_ptr<const Region>) const;
bool speed_mismatch (float) const;
@@ -152,7 +143,7 @@ class AudioRegion : public Region
int exportme (ARDOUR::Session&, ARDOUR::AudioExportSpecification&);
- Region* get_parent();
+ boost::shared_ptr<Region> get_parent();
/* xfade/fade interactions */
@@ -162,7 +153,15 @@ class AudioRegion : public Region
void resume_fade_out ();
private:
- friend class Playlist;
+ friend class RegionFactory;
+
+ AudioRegion (AudioSource&, jack_nframes_t start, jack_nframes_t length);
+ AudioRegion (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 (AudioSource&, const XMLNode&);
+ AudioRegion (SourceList &, const XMLNode&);
private:
void set_default_fades ();
diff --git a/libs/ardour/ardour/auditioner.h b/libs/ardour/ardour/auditioner.h
index 434ec32f97..c693589864 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<AudioRegion>);
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 bcd418b452..f9463a3320 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 {
@@ -135,7 +135,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);
@@ -225,7 +225,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 b116a58b97..1248f60e0f 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>
@@ -59,7 +59,7 @@ class Panner;
* 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:
@@ -70,7 +70,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();
int input_minimum() const { return _input_minimum; }
int 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/playlist.h b/libs/ardour/ardour/playlist.h
index b389258860..36c3ae3492 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>
@@ -45,16 +47,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&, bool hidden = false);
Playlist (Session&, string name, 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;
@@ -79,17 +81,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);
@@ -99,25 +101,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;
@@ -128,10 +129,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; }
@@ -142,7 +143,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;
@@ -212,8 +213,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 ();
@@ -221,11 +222,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 ();
@@ -236,11 +237,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);
@@ -249,9 +250,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);
@@ -264,7 +265,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,
@@ -273,7 +274,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 e5a81f1ef9..4800bc35fc 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>
@@ -77,8 +77,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&);
@@ -140,7 +139,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 658cab5d3b..5f63fad8c8 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 3773a3b893..958b4d419c 100644
--- a/libs/ardour/ardour/region.h
+++ b/libs/ardour/ardour/region.h
@@ -21,7 +21,10 @@
#ifndef __ardour_region_h__
#define __ardour_region_h__
+#include <boost/shared_ptr.hpp>
+
#include <pbd/undo.h>
+#include <pbd/statefuldestructible.h>
#include <ardour/ardour.h>
#include <ardour/state_manager.h>
@@ -53,7 +56,7 @@ struct RegionState : public StateManager::State
mutable RegionEditState _first_edit;
};
-class Region : public Stateful, public StateManager
+class Region : public PBD::StatefulDestructible, public StateManager
{
public:
enum Flag {
@@ -89,11 +92,6 @@ class Region : public Stateful, public StateManager
static Change LayerChanged;
static Change HiddenChanged;
- Region (jack_nframes_t start, jack_nframes_t length,
- const string& name, 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 (const XMLNode&);
virtual ~Region();
const PBD::ID& id() const { return _id; }
@@ -139,11 +137,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;
- virtual bool source_equivalent (const Region&) const = 0;
+ 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;
+ virtual bool source_equivalent (boost::shared_ptr<const Region>) const = 0;
virtual bool speed_mismatch (float) const = 0;
@@ -193,24 +191,22 @@ 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;
-
- virtual Region* get_parent() = 0;
+ virtual boost::shared_ptr<Region> get_parent() = 0;
uint64_t last_layer_op() const { return _last_layer_op; }
void set_last_layer_op (uint64_t when);
protected:
+ friend class RegionFactory;
+
+ Region (jack_nframes_t start, jack_nframes_t length,
+ const string& name, 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 (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..d4033680ee 100644
--- a/libs/ardour/ardour/region_factory.h
+++ b/libs/ardour/ardour/region_factory.h
@@ -10,12 +10,28 @@ 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 (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 ff7aa6184c..2191439744 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 78f6011369..2a29b0e56e 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -37,11 +37,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>
@@ -94,11 +96,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 StatefulDestructible
{
private:
@@ -324,11 +325,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 */
@@ -366,7 +365,7 @@ class Session : public sigc::trackable, public Stateful
int wipe ();
- 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(); }
@@ -615,19 +614,19 @@ class Session : public sigc::trackable, public Stateful
/* region info */
- sigc::signal<void,AudioRegion *> AudioRegionAdded;
- sigc::signal<void,AudioRegion *> AudioRegionRemoved;
+ sigc::signal<void,boost::shared_ptr<AudioRegion> > AudioRegionAdded;
+ sigc::signal<void,boost::shared_ptr<AudioRegion> > AudioRegionRemoved;
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);
- AudioRegion* find_whole_file_parent (AudioRegion&);
- void find_equivalent_playlist_regions (Region&, std::vector<Region*>& result);
+ boost::shared_ptr<AudioRegion> find_whole_file_parent (boost::shared_ptr<AudioRegion>);
+ void find_equivalent_playlist_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >& result);
- AudioRegion *XMLRegionFactory (const XMLNode&, bool full);
+ boost::shared_ptr<AudioRegion> XMLRegionFactory (const XMLNode&, bool full);
- template<class T> void foreach_audio_region (T *obj, void (T::*func)(AudioRegion *));
+ template<class T> void foreach_audio_region (T *obj, void (T::*func)(boost::shared_ptr<AudioRegion>));
/* source management */
@@ -641,7 +640,7 @@ class Session : public sigc::trackable, public Stateful
string pathname;
/* result */
- std::vector<AudioRegion*> new_regions;
+ std::vector<boost::shared_ptr<AudioRegion> > new_regions;
};
@@ -667,8 +666,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 ();
@@ -728,7 +727,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;
@@ -840,12 +839,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;
@@ -915,17 +917,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);
@@ -1540,13 +1542,13 @@ class Session : public sigc::trackable, public Stateful
/* REGION MANAGEMENT */
mutable Glib::Mutex region_lock;
- typedef map<PBD::ID,AudioRegion *> AudioRegionList;
+ typedef map<PBD::ID,boost::shared_ptr<AudioRegion> > AudioRegionList;
AudioRegionList audio_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);
@@ -1603,9 +1605,9 @@ class Session : public sigc::trackable, public Stateful
/* AUDITIONING */
boost::shared_ptr<Auditioner> auditioner;
- void set_audition (AudioRegion*);
+ void set_audition (boost::shared_ptr<AudioRegion>);
void non_realtime_set_audition ();
- AudioRegion *pending_audition_region;
+ boost::shared_ptr<AudioRegion> pending_audition_region;
/* EXPORT */
@@ -1674,7 +1676,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 4f0fb92e3b..9217d4cb41 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_audio_region (T *obj, void (T::*func)(AudioRegion *))
+template<class T> void Session::foreach_audio_region (T *obj, void (T::*func)(boost::shared_ptr<AudioRegion>))
{
Glib::Mutex::Lock lm (region_lock);
for (AudioRegionList::iterator i = audio_regions.begin(); i != audio_regions.end(); i++) {
diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h
index f57ea79854..dee75a2300 100644
--- a/libs/ardour/ardour/source.h
+++ b/libs/ardour/ardour/source.h
@@ -25,13 +25,13 @@
#include <sigc++/signal.h>
-#include <pbd/stateful.h>
+#include <pbd/statefuldestructible.h>
#include <ardour/ardour.h>
namespace ARDOUR {
-class Source : public Stateful, public sigc::trackable
+class Source : public PBD::StatefulDestructible, public sigc::trackable
{
public:
Source (std::string name);
@@ -53,7 +53,6 @@ class Source : public Stateful, public sigc::trackable
XMLNode& get_state ();
int set_state (const XMLNode&);
- sigc::signal<void,Source *> GoingAway;
protected:
string _name;
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 0a3a7b731c..9c92b49ed0 100644
--- a/libs/ardour/ardour/types.h
+++ b/libs/ardour/ardour/types.h
@@ -26,6 +26,7 @@
#endif
#include <istream>
+#include <vector>
#include <inttypes.h>
#include <jack/types.h>
@@ -42,6 +43,7 @@ typedef int intptr_t;
namespace ARDOUR {
class Source;
+ class AudioSource;
typedef jack_default_audio_sample_t Sample;
typedef float pan_t;
@@ -250,6 +252,8 @@ namespace ARDOUR {
VST
};
+ typedef std::vector<AudioSource *> SourceList;
+
} // namespace ARDOUR
std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf);
diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc
index baefeff377..24363e3594 100644
--- a/libs/ardour/audio_diskstream.cc
+++ b/libs/ardour/audio_diskstream.cc
@@ -44,6 +44,7 @@
#include <ardour/audiofilesource.h>
#include <ardour/destructive_filesource.h>
#include <ardour/send.h>
+#include <ardour/region_factory.h>
#include <ardour/audioplaylist.h>
#include <ardour/cycle_timer.h>
#include <ardour/audioregion.h>
@@ -188,8 +189,8 @@ AudioDiskstream::allocate_working_buffers()
void
AudioDiskstream::free_working_buffers()
{
- delete _mixdown_buffer;
- delete _gain_buffer;
+ delete [] _mixdown_buffer;
+ delete [] _gain_buffer;
_working_buffers_size = 0;
_mixdown_buffer = 0;
_gain_buffer = 0;
@@ -367,7 +368,7 @@ AudioDiskstream::use_copy_playlist ()
void
AudioDiskstream::setup_destructive_playlist ()
{
- AudioRegion::SourceList srcs;
+ SourceList srcs;
for (ChannelList::iterator chan = channels.begin(); chan != channels.end(); ++chan) {
srcs.push_back ((*chan).write_source);
@@ -377,8 +378,8 @@ AudioDiskstream::setup_destructive_playlist ()
cerr << "setup DS using " << srcs.front()->natural_position () << endl;
- AudioRegion* region = new AudioRegion (srcs, 0, max_frames, _name);
- _playlist->add_region (*region, srcs.front()->natural_position());
+ boost::shared_ptr<Region> region (RegionFactory::create (srcs, 0, max_frames, _name));
+ _playlist->add_region (region, srcs.front()->natural_position());
}
void
@@ -393,7 +394,7 @@ AudioDiskstream::use_destructive_playlist ()
return;
}
- AudioRegion* region = dynamic_cast<AudioRegion*> (rl->front());
+ boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion> (rl->front());
if (region == 0) {
throw failed_constructor();
@@ -1449,10 +1450,10 @@ AudioDiskstream::transport_stopped (struct tm& when, time_t twhen, bool abort_ca
uint32_t buffer_position;
bool more_work = true;
int err = 0;
- AudioRegion* region = 0;
+ boost::shared_ptr<AudioRegion> region;
jack_nframes_t total_capture;
- AudioRegion::SourceList srcs;
- AudioRegion::SourceList::iterator src;
+ SourceList srcs;
+ SourceList::iterator src;
ChannelList::iterator chan;
vector<CaptureInfo*>::iterator ci;
uint32_t n = 0;
@@ -1561,10 +1562,11 @@ AudioDiskstream::transport_stopped (struct tm& when, time_t twhen, bool abort_ca
*/
try {
- region = new AudioRegion (srcs, channels[0].write_source->last_capture_start_frame(), total_capture,
- region_name_from_path (channels[0].write_source->name()),
- 0, AudioRegion::Flag (AudioRegion::DefaultFlags|AudioRegion::Automatic|AudioRegion::WholeFile));
-
+ boost::shared_ptr<Region> rx (RegionFactory::create (srcs, channels[0].write_source->last_capture_start_frame(), total_capture,
+ region_name_from_path (channels[0].write_source->name()),
+ 0, AudioRegion::Flag (AudioRegion::DefaultFlags|AudioRegion::Automatic|AudioRegion::WholeFile)));
+
+ region = boost::dynamic_pointer_cast<AudioRegion> (rx);
region->special_set_position (capture_info.front()->start);
}
@@ -1586,10 +1588,11 @@ 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 a region\n";
+ cerr << _name << ": based on ci of " << (*ci)->start << " for " << (*ci)->frames << " add region " << region_name << endl;
try {
- region = new AudioRegion (srcs, buffer_position, (*ci)->frames, region_name);
+ boost::shared_ptr<Region> rx (RegionFactory::create (srcs, buffer_position, (*ci)->frames, region_name));
+ region = boost::dynamic_pointer_cast<AudioRegion> (rx);
}
catch (failed_constructor& err) {
@@ -1602,7 +1605,7 @@ AudioDiskstream::transport_stopped (struct tm& when, time_t twhen, bool abort_ca
// cerr << "add new region, buffer position = " << buffer_position << " @ " << (*ci)->start << endl;
i_am_the_modifier++;
- _playlist->add_region (*region, (*ci)->start);
+ _playlist->add_region (region, (*ci)->start);
i_am_the_modifier--;
buffer_position += (*ci)->frames;
@@ -2165,7 +2168,7 @@ AudioDiskstream::use_pending_capture_data (XMLNode& node)
XMLNodeIterator niter;
AudioFileSource* fs;
AudioFileSource* first_fs = 0;
- AudioRegion::SourceList pending_sources;
+ SourceList pending_sources;
jack_nframes_t position;
if ((prop = node.property (X_("at"))) == 0) {
@@ -2218,13 +2221,12 @@ AudioDiskstream::use_pending_capture_data (XMLNode& node)
return -1;
}
- AudioRegion* region;
+ boost::shared_ptr<AudioRegion> region;
try {
- region = new AudioRegion (pending_sources, 0, first_fs->length(),
- region_name_from_path (first_fs->name()),
- 0, AudioRegion::Flag (AudioRegion::DefaultFlags|AudioRegion::Automatic|AudioRegion::WholeFile));
-
+ region = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (pending_sources, 0, first_fs->length(),
+ region_name_from_path (first_fs->name()),
+ 0, AudioRegion::Flag (AudioRegion::DefaultFlags|AudioRegion::Automatic|AudioRegion::WholeFile)));
region->special_set_position (0);
}
@@ -2237,7 +2239,7 @@ AudioDiskstream::use_pending_capture_data (XMLNode& node)
}
try {
- region = new AudioRegion (pending_sources, 0, first_fs->length(), region_name_from_path (first_fs->name()));
+ region = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (pending_sources, 0, first_fs->length(), region_name_from_path (first_fs->name())));
}
catch (failed_constructor& err) {
@@ -2248,7 +2250,7 @@ AudioDiskstream::use_pending_capture_data (XMLNode& node)
return -1;
}
- _playlist->add_region (*region, position);
+ _playlist->add_region (region, position);
return 0;
}
diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc
index 328c9b25f5..1136476358 100644
--- a/libs/ardour/audio_playlist.cc
+++ b/libs/ardour/audio_playlist.cc
@@ -73,28 +73,28 @@ AudioPlaylist::AudioPlaylist (const AudioPlaylist& other, string name, bool hidd
{
save_state (_("initial state"));
- list<Region*>::const_iterator in_o = other.regions.begin();
- list<Region*>::iterator in_n = regions.begin();
+ RegionList::const_iterator in_o = other.regions.begin();
+ RegionList::iterator in_n = regions.begin();
while (in_o != other.regions.end()) {
- AudioRegion *ar = dynamic_cast<AudioRegion *>( (*in_o) );
+ boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion>(*in_o);
// We look only for crossfades which begin with the current region, so we don't get doubles
for (list<Crossfade *>::const_iterator xfades = other._crossfades.begin(); xfades != other._crossfades.end(); ++xfades) {
- if ( &(*xfades)->in() == ar) {
+ if ((*xfades)->in() == ar) {
// We found one! Now copy it!
- list<Region*>::const_iterator out_o = other.regions.begin();
- list<Region*>::const_iterator out_n = regions.begin();
+ RegionList::const_iterator out_o = other.regions.begin();
+ RegionList::const_iterator out_n = regions.begin();
while (out_o != other.regions.end()) {
- AudioRegion *ar2 = dynamic_cast<AudioRegion *>( (*out_o) );
+ boost::shared_ptr<AudioRegion>ar2 = boost::dynamic_pointer_cast<AudioRegion>(*out_o);
- if ( &(*xfades)->out() == ar2) {
- AudioRegion *in = dynamic_cast<AudioRegion*>( (*in_n) );
- AudioRegion *out = dynamic_cast<AudioRegion*>( (*out_n) );
- Crossfade *new_fade = new Crossfade( *(*xfades), in, out);
+ if ((*xfades)->out() == ar2) {
+ boost::shared_ptr<AudioRegion>in = boost::dynamic_pointer_cast<AudioRegion>(*in_n);
+ boost::shared_ptr<AudioRegion>out = boost::dynamic_pointer_cast<AudioRegion>(*out_n);
+ Crossfade *new_fade = new Crossfade (*(*xfades), in, out);
add_crossfade(*new_fade);
break;
}
@@ -128,15 +128,11 @@ AudioPlaylist::~AudioPlaylist ()
set<Crossfade*> all_xfades;
set<Region*> all_regions;
- GoingAway (this);
+ GoingAway (); /* EMIT SIGNAL */
- /* find every region we've ever used, and add it to the set of
- all regions. same for xfades;
- */
+ /* drop connections to signals */
- for (RegionList::iterator x = regions.begin(); x != regions.end(); ++x) {
- all_regions.insert (*x);
- }
+ notify_callbacks ();
for (Crossfades::iterator x = _crossfades.begin(); x != _crossfades.end(); ++x) {
all_xfades.insert (*x);
@@ -146,23 +142,13 @@ AudioPlaylist::~AudioPlaylist ()
AudioPlaylist::State* apstate = dynamic_cast<AudioPlaylist::State*> (*i);
- for (RegionList::iterator r = apstate->regions.begin(); r != apstate->regions.end(); ++r) {
- all_regions.insert (*r);
- }
- for (Crossfades::iterator xf = apstate->crossfades.begin(); xf != apstate->crossfades.end(); ++xf) {
+ for (Crossfades::iterator xf = apstate->crossfades.begin(); xf != apstate->crossfades.end(); ++xf) {
all_xfades.insert (*xf);
}
delete apstate;
}
- /* delete every region */
-
- for (set<Region *>::iterator ar = all_regions.begin(); ar != all_regions.end(); ++ar) {
- (*ar)->unlock_sources ();
- delete *ar;
- }
-
/* delete every crossfade */
for (set<Crossfade *>::iterator axf = all_xfades.begin(); axf != all_xfades.end(); ++axf) {
@@ -171,7 +157,7 @@ AudioPlaylist::~AudioPlaylist ()
}
struct RegionSortByLayer {
- bool operator() (Region *a, Region *b) {
+ bool operator() (boost::shared_ptr<Region>a, boost::shared_ptr<Region>b) {
return a->layer() < b->layer();
}
};
@@ -212,7 +198,7 @@ AudioPlaylist::read (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, ja
skip_frames = 0;
_read_data_count = 0;
- map<uint32_t,vector<Region*> > relevant_regions;
+ map<uint32_t,vector<boost::shared_ptr<Region> > > relevant_regions;
map<uint32_t,vector<Crossfade*> > relevant_xfades;
vector<uint32_t> relevant_layers;
@@ -243,12 +229,11 @@ AudioPlaylist::read (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, ja
for (vector<uint32_t>::iterator l = relevant_layers.begin(); l != relevant_layers.end(); ++l) {
- // FIXME: Should be vector<AudioRegion*>
- vector<Region*>& r (relevant_regions[*l]);
+ vector<boost::shared_ptr<Region> > r (relevant_regions[*l]);
vector<Crossfade*>& x (relevant_xfades[*l]);
- for (vector<Region*>::iterator i = r.begin(); i != r.end(); ++i) {
- AudioRegion* const ar = dynamic_cast<AudioRegion*>(*i);
+ for (vector<boost::shared_ptr<Region> >::iterator i = r.begin(); i != r.end(); ++i) {
+ boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion>(*i);
assert(ar);
ar->read_at (buf, mixdown_buffer, gain_buffer, start, cnt, chan_n, read_frames, skip_frames);
_read_data_count += ar->read_data_count();
@@ -268,10 +253,10 @@ AudioPlaylist::read (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, ja
void
-AudioPlaylist::remove_dependents (Region& region)
+AudioPlaylist::remove_dependents (boost::shared_ptr<Region> region)
{
Crossfades::iterator i, tmp;
- AudioRegion* r = dynamic_cast<AudioRegion*> (&region);
+ boost::shared_ptr<AudioRegion> r = boost::dynamic_pointer_cast<AudioRegion> (region);
if (r == 0) {
fatal << _("programming error: non-audio Region passed to remove_overlap in audio playlist")
@@ -283,7 +268,7 @@ AudioPlaylist::remove_dependents (Region& region)
tmp = i;
tmp++;
- if ((*i)->involves (*r)) {
+ if ((*i)->involves (r)) {
/* do not delete crossfades */
_crossfades.erase (i);
}
@@ -315,9 +300,9 @@ AudioPlaylist::flush_notifications ()
}
void
-AudioPlaylist::refresh_dependents (Region& r)
+AudioPlaylist::refresh_dependents (boost::shared_ptr<Region> r)
{
- AudioRegion* ar = dynamic_cast<AudioRegion*>(&r);
+ boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion>(r);
set<Crossfade*> updated;
if (ar == 0) {
@@ -333,7 +318,7 @@ AudioPlaylist::refresh_dependents (Region& r)
/* only update them once */
- if ((*x)->involves (*ar)) {
+ if ((*x)->involves (ar)) {
if (find (updated.begin(), updated.end(), *x) == updated.end()) {
if ((*x)->refresh ()) {
@@ -348,11 +333,11 @@ AudioPlaylist::refresh_dependents (Region& r)
}
void
-AudioPlaylist::finalize_split_region (Region *o, Region *l, Region *r)
+AudioPlaylist::finalize_split_region (boost::shared_ptr<Region> o, boost::shared_ptr<Region> l, boost::shared_ptr<Region> r)
{
- AudioRegion *orig = dynamic_cast<AudioRegion*>(o);
- AudioRegion *left = dynamic_cast<AudioRegion*>(l);
- AudioRegion *right = dynamic_cast<AudioRegion*>(r);
+ boost::shared_ptr<AudioRegion> orig = boost::dynamic_pointer_cast<AudioRegion>(o);
+ boost::shared_ptr<AudioRegion> left = boost::dynamic_pointer_cast<AudioRegion>(l);
+ boost::shared_ptr<AudioRegion> right = boost::dynamic_pointer_cast<AudioRegion>(r);
for (Crossfades::iterator x = _crossfades.begin(); x != _crossfades.end();) {
Crossfades::iterator tmp;
@@ -363,24 +348,24 @@ AudioPlaylist::finalize_split_region (Region *o, Region *l, Region *r)
if ((*x)->_in == orig) {
if (! (*x)->covers(right->position())) {
- fade = new Crossfade( *(*x), left, (*x)->_out);
+ fade = new Crossfade (**x, left, (*x)->_out);
} else {
// Overlap, the crossfade is copied on the left side of the right region instead
- fade = new Crossfade( *(*x), right, (*x)->_out);
+ fade = new Crossfade (**x, right, (*x)->_out);
}
}
if ((*x)->_out == orig) {
if (! (*x)->covers(right->position())) {
- fade = new Crossfade( *(*x), (*x)->_in, right);
+ fade = new Crossfade (**x, (*x)->_in, right);
} else {
// Overlap, the crossfade is copied on the right side of the left region instead
- fade = new Crossfade( *(*x), (*x)->_in, left);
+ fade = new Crossfade (**x, (*x)->_in, left);
}
}
if (fade) {
- _crossfades.remove( (*x) );
+ _crossfades.remove (*x);
add_crossfade (*fade);
}
x = tmp;
@@ -388,19 +373,19 @@ AudioPlaylist::finalize_split_region (Region *o, Region *l, Region *r)
}
void
-AudioPlaylist::check_dependents (Region& r, bool norefresh)
+AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh)
{
- AudioRegion* other;
- AudioRegion* region;
- AudioRegion* top;
- AudioRegion* bottom;
+ boost::shared_ptr<AudioRegion> other;
+ boost::shared_ptr<AudioRegion> region;
+ boost::shared_ptr<AudioRegion> top;
+ boost::shared_ptr<AudioRegion> bottom;
Crossfade* xfade;
if (in_set_state || in_partition) {
return;
}
- if ((region = dynamic_cast<AudioRegion*> (&r)) == 0) {
+ if ((region = boost::dynamic_pointer_cast<AudioRegion> (r)) == 0) {
fatal << _("programming error: non-audio Region tested for overlap in audio playlist")
<< endmsg;
return;
@@ -416,7 +401,7 @@ AudioPlaylist::check_dependents (Region& r, bool norefresh)
for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
- other = dynamic_cast<AudioRegion*> (*i);
+ other = boost::dynamic_pointer_cast<AudioRegion> (*i);
if (other == region) {
continue;
@@ -458,14 +443,14 @@ AudioPlaylist::check_dependents (Region& r, bool norefresh)
jack_nframes_t xfade_length = min ((jack_nframes_t) 720, top->length());
/* in, out */
- xfade = new Crossfade (*top, *bottom, xfade_length, top->first_frame(), StartOfIn);
+ xfade = new Crossfade (top, bottom, xfade_length, top->first_frame(), StartOfIn);
add_crossfade (*xfade);
- xfade = new Crossfade (*bottom, *top, xfade_length, top->last_frame() - xfade_length, EndOfOut);
+ xfade = new Crossfade (bottom, top, xfade_length, top->last_frame() - xfade_length, EndOfOut);
add_crossfade (*xfade);
} else {
- xfade = new Crossfade (*other, *region, _session.get_xfade_model(), _session.get_crossfades_active());
+ xfade = new Crossfade (other, region, _session.get_xfade_model(), _session.get_crossfades_active());
add_crossfade (*xfade);
}
}
@@ -519,8 +504,8 @@ AudioPlaylist::crossfade_invalidated (Crossfade* xfade)
{
Crossfades::iterator i;
- xfade->in().resume_fade_in ();
- xfade->out().resume_fade_out ();
+ xfade->in()->resume_fade_in ();
+ xfade->out()->resume_fade_out ();
if ((i = find (_crossfades.begin(), _crossfades.end(), xfade)) != _crossfades.end()) {
_crossfades.erase (i);
@@ -586,7 +571,7 @@ void
AudioPlaylist::drop_all_states ()
{
set<Crossfade*> all_xfades;
- set<Region*> all_regions;
+ set<boost::shared_ptr<Region> > all_regions;
/* find every region we've ever used, and add it to the set of
all regions. same for xfades;
@@ -599,6 +584,7 @@ AudioPlaylist::drop_all_states ()
for (RegionList::iterator r = apstate->regions.begin(); r != apstate->regions.end(); ++r) {
all_regions.insert (*r);
}
+
for (Crossfades::iterator xf = apstate->crossfades.begin(); xf != apstate->crossfades.end(); ++xf) {
all_xfades.insert (*xf);
}
@@ -606,8 +592,8 @@ AudioPlaylist::drop_all_states ()
/* now remove from the "all" lists every region that is in the current list. */
- for (list<Region*>::iterator i = regions.begin(); i != regions.end(); ++i) {
- set<Region*>::iterator x = all_regions.find (*i);
+ for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
+ set<boost::shared_ptr<Region> >::iterator x = all_regions.find (*i);
if (x != all_regions.end()) {
all_regions.erase (x);
}
@@ -624,9 +610,8 @@ AudioPlaylist::drop_all_states ()
/* delete every region that is left - these are all things that are part of our "history" */
- for (set<Region *>::iterator ar = all_regions.begin(); ar != all_regions.end(); ++ar) {
+ for (set<boost::shared_ptr<Region> >::iterator ar = all_regions.begin(); ar != all_regions.end(); ++ar) {
(*ar)->unlock_sources ();
- delete *ar;
}
/* delete every crossfade that is left (ditto as per regions) */
@@ -694,17 +679,11 @@ AudioPlaylist::get_memento () const
}
void
-AudioPlaylist::clear (bool with_delete, bool with_save)
+AudioPlaylist::clear (bool with_save)
{
- if (with_delete) {
- for (Crossfades::iterator i = _crossfades.begin(); i != _crossfades.end(); ++i) {
- delete *i;
- }
- }
-
_crossfades.clear ();
- Playlist::clear (with_delete, with_save);
+ Playlist::clear (with_save);
}
XMLNode&
@@ -724,7 +703,7 @@ AudioPlaylist::state (bool full_state)
void
AudioPlaylist::dump () const
{
- Region *r;
+ boost::shared_ptr<Region>r;
Crossfade *x;
cerr << "Playlist \"" << _name << "\" " << endl
@@ -746,9 +725,9 @@ AudioPlaylist::dump () const
for (Crossfades::const_iterator i = _crossfades.begin(); i != _crossfades.end(); ++i) {
x = *i;
cerr << " xfade ["
- << x->out().name()
+ << x->out()->name()
<< ','
- << x->in().name()
+ << x->in()->name()
<< " @ "
<< x->position()
<< " length = "
@@ -760,9 +739,9 @@ AudioPlaylist::dump () const
}
bool
-AudioPlaylist::destroy_region (Region* region)
+AudioPlaylist::destroy_region (boost::shared_ptr<Region> region)
{
- AudioRegion* r = dynamic_cast<AudioRegion*> (region);
+ boost::shared_ptr<AudioRegion> r = boost::dynamic_pointer_cast<AudioRegion> (region);
bool changed = false;
Crossfades::iterator c, ctmp;
set<Crossfade*> unique_xfades;
@@ -798,7 +777,7 @@ AudioPlaylist::destroy_region (Region* region)
ctmp = c;
++ctmp;
- if ((*c)->involves (*r)) {
+ if ((*c)->involves (r)) {
unique_xfades.insert (*c);
_crossfades.erase (c);
}
@@ -819,7 +798,7 @@ AudioPlaylist::destroy_region (Region* region)
ctmp = c;
++ctmp;
- if ((*c)->involves (*r)) {
+ if ((*c)->involves (r)) {
unique_xfades.insert (*c);
_crossfades.erase (c);
}
@@ -883,7 +862,7 @@ AudioPlaylist::crossfade_changed (Change ignored)
}
bool
-AudioPlaylist::region_changed (Change what_changed, Region* region)
+AudioPlaylist::region_changed (Change what_changed, boost::shared_ptr<Region> region)
{
if (in_flush || in_set_state) {
return false;
diff --git a/libs/ardour/audio_track.cc b/libs/ardour/audio_track.cc
index 98a2262f86..60400a046c 100644
--- a/libs/ardour/audio_track.cc
+++ b/libs/ardour/audio_track.cc
@@ -28,6 +28,7 @@
#include <ardour/redirect.h>
#include <ardour/audioregion.h>
#include <ardour/audiosource.h>
+#include <ardour/region_factory.h>
#include <ardour/route_group_specialized.h>
#include <ardour/insert.h>
#include <ardour/audioplaylist.h>
@@ -746,7 +747,6 @@ AudioTrack::freeze (InterThreadInfo& itt)
string new_playlist_name;
Playlist* new_playlist;
string dir;
- AudioRegion* region;
string region_name;
boost::shared_ptr<AudioDiskstream> diskstream = audio_diskstream();
@@ -813,13 +813,13 @@ AudioTrack::freeze (InterThreadInfo& itt)
/* create a new region from all filesources, keep it private */
- region = new AudioRegion (srcs, 0, srcs[0]->length(),
- region_name, 0,
- (AudioRegion::Flag) (AudioRegion::WholeFile|AudioRegion::DefaultFlags),
- false);
+ boost::shared_ptr<Region> region (RegionFactory::create (srcs, 0, srcs[0]->length(),
+ region_name, 0,
+ (AudioRegion::Flag) (AudioRegion::WholeFile|AudioRegion::DefaultFlags),
+ false));
new_playlist->set_orig_diskstream_id (diskstream->id());
- new_playlist->add_region (*region, 0);
+ new_playlist->add_region (region, 0);
new_playlist->set_frozen (true);
region->set_locked (true);
diff --git a/libs/ardour/audiofilter.cc b/libs/ardour/audiofilter.cc
index a26d9674bd..3e9c36ddd2 100644
--- a/libs/ardour/audiofilter.cc
+++ b/libs/ardour/audiofilter.cc
@@ -26,6 +26,7 @@
#include <ardour/session.h>
#include <ardour/audioregion.h>
#include <ardour/audiofilter.h>
+#include <ardour/region_factory.h>
#include "i18n.h"
@@ -33,16 +34,16 @@ using namespace ARDOUR;
using namespace PBD;
int
-AudioFilter::make_new_sources (AudioRegion& region, AudioRegion::SourceList& nsrcs)
+AudioFilter::make_new_sources (boost::shared_ptr<AudioRegion> region, SourceList& nsrcs)
{
- vector<string> names = region.master_source_names();
+ vector<string> names = region->master_source_names();
- for (uint32_t i = 0; i < region.n_channels(); ++i) {
+ for (uint32_t i = 0; i < region->n_channels(); ++i) {
string path = session.path_from_region_name (PBD::basename_nosuffix (names[i]), string (""));
if (path.length() == 0) {
- error << string_compose (_("audiofilter: error creating name for new audio file based on %1"), region.name())
+ error << string_compose (_("audiofilter: error creating name for new audio file based on %1"), region->name())
<< endmsg;
return -1;
}
@@ -64,7 +65,7 @@ AudioFilter::make_new_sources (AudioRegion& region, AudioRegion::SourceList& nsr
}
int
-AudioFilter::finish (AudioRegion& region, AudioRegion::SourceList& nsrcs)
+AudioFilter::finish (boost::shared_ptr<AudioRegion> region, SourceList& nsrcs)
{
string region_name;
@@ -76,19 +77,19 @@ AudioFilter::finish (AudioRegion& region, AudioRegion::SourceList& nsrcs)
time (&xnow);
now = localtime (&xnow);
- for (AudioRegion::SourceList::iterator si = nsrcs.begin(); si != nsrcs.end(); ++si) {
+ for (SourceList::iterator si = nsrcs.begin(); si != nsrcs.end(); ++si) {
AudioFileSource* afs = dynamic_cast<AudioFileSource*>(*si);
if (afs) {
- afs->update_header (region.position(), *now, xnow);
+ afs->update_header (region->position(), *now, xnow);
}
}
/* create a new region */
- region_name = session.new_region_name (region.name());
+ region_name = session.new_region_name (region->name());
results.clear ();
- results.push_back (new AudioRegion (nsrcs, 0, region.length(), region_name, 0,
- Region::Flag (Region::WholeFile|Region::DefaultFlags)));
-
+ results.push_back (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (nsrcs, 0, region->length(), region_name, 0,
+ Region::Flag (Region::WholeFile|Region::DefaultFlags))));
+
return 0;
}
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc
index 4b07599924..5cedb246ba 100644
--- a/libs/ardour/audioregion.cc
+++ b/libs/ardour/audioregion.cc
@@ -64,7 +64,7 @@ AudioRegionState::AudioRegionState (string why)
{
}
-AudioRegion::AudioRegion (AudioSource& src, jack_nframes_t start, jack_nframes_t length, bool announce)
+AudioRegion::AudioRegion (AudioSource& src, jack_nframes_t start, jack_nframes_t length)
: Region (start, length, PBD::basename_nosuffix(src.name()), 0, Region::Flag(Region::DefaultFlags|Region::External)),
_fade_in (0.0, 2.0, 1.0, false),
_fade_out (0.0, 2.0, 1.0, false),
@@ -74,7 +74,7 @@ AudioRegion::AudioRegion (AudioSource& src, jack_nframes_t start, jack_nframes_t
sources.push_back (&src);
master_sources.push_back (&src);
- src.GoingAway.connect (mem_fun (*this, &AudioRegion::source_deleted));
+ src.GoingAway.connect (bind (mem_fun (*this, &AudioRegion::source_deleted), &src));
_scale_amplitude = 1.0;
@@ -84,13 +84,9 @@ AudioRegion::AudioRegion (AudioSource& src, jack_nframes_t start, jack_nframes_t
save_state ("initial state");
_envelope.StateChanged.connect (mem_fun (*this, &AudioRegion::envelope_changed));
-
- if (announce) {
- CheckNewRegion (this); /* EMIT SIGNAL */
- }
}
-AudioRegion::AudioRegion (AudioSource& src, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t layer, Flag flags, bool announce)
+AudioRegion::AudioRegion (AudioSource& src, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t layer, Flag flags)
: Region (start, length, name, layer, flags),
_fade_in (0.0, 2.0, 1.0, false),
_fade_out (0.0, 2.0, 1.0, false),
@@ -100,7 +96,7 @@ AudioRegion::AudioRegion (AudioSource& src, jack_nframes_t start, jack_nframes_t
sources.push_back (&src);
master_sources.push_back (&src);
- src.GoingAway.connect (mem_fun (*this, &AudioRegion::source_deleted));
+ src.GoingAway.connect (bind (mem_fun (*this, &AudioRegion::source_deleted), &src));
_scale_amplitude = 1.0;
@@ -109,13 +105,9 @@ AudioRegion::AudioRegion (AudioSource& src, jack_nframes_t start, jack_nframes_t
save_state ("initial state");
_envelope.StateChanged.connect (mem_fun (*this, &AudioRegion::envelope_changed));
-
- if (announce) {
- CheckNewRegion (this); /* EMIT SIGNAL */
- }
}
-AudioRegion::AudioRegion (SourceList& srcs, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t layer, Flag flags, bool announce)
+AudioRegion::AudioRegion (SourceList& srcs, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t layer, Flag flags)
: Region (start, length, name, layer, flags),
_fade_in (0.0, 2.0, 1.0, false),
_fade_out (0.0, 2.0, 1.0, false),
@@ -126,7 +118,7 @@ AudioRegion::AudioRegion (SourceList& srcs, jack_nframes_t start, jack_nframes_t
for (SourceList::iterator i=srcs.begin(); i != srcs.end(); ++i) {
sources.push_back (*i);
master_sources.push_back (*i);
- (*i)->GoingAway.connect (mem_fun (*this, &AudioRegion::source_deleted));
+ (*i)->GoingAway.connect (bind (mem_fun (*this, &AudioRegion::source_deleted), (*i)));
}
_scale_amplitude = 1.0;
@@ -136,32 +128,28 @@ AudioRegion::AudioRegion (SourceList& srcs, jack_nframes_t start, jack_nframes_t
save_state ("initial state");
_envelope.StateChanged.connect (mem_fun (*this, &AudioRegion::envelope_changed));
-
- if (announce) {
- CheckNewRegion (this); /* EMIT SIGNAL */
- }
}
-AudioRegion::AudioRegion (const AudioRegion& other, jack_nframes_t offset, jack_nframes_t length, const string& name, layer_t layer, Flag flags, bool announce)
+AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other, jack_nframes_t offset, jack_nframes_t length, const string& name, layer_t layer, Flag flags)
: Region (other, offset, length, name, layer, flags),
- _fade_in (other._fade_in),
- _fade_out (other._fade_out),
- _envelope (other._envelope, (double) offset, (double) offset + length)
+ _fade_in (other->_fade_in),
+ _fade_out (other->_fade_out),
+ _envelope (other->_envelope, (double) offset, (double) offset + length)
{
/* create a new AudioRegion, that is part of an existing one */
set<AudioSource*> unique_srcs;
- for (SourceList::const_iterator i= other.sources.begin(); i != other.sources.end(); ++i) {
+ for (SourceList::const_iterator i= other->sources.begin(); i != other->sources.end(); ++i) {
sources.push_back (*i);
- (*i)->GoingAway.connect (mem_fun (*this, &AudioRegion::source_deleted));
+ (*i)->GoingAway.connect (bind (mem_fun (*this, &AudioRegion::source_deleted), *i));
unique_srcs.insert (*i);
}
- for (SourceList::const_iterator i = other.master_sources.begin(); i != other.master_sources.end(); ++i) {
+ for (SourceList::const_iterator i = other->master_sources.begin(); i != other->master_sources.end(); ++i) {
if (unique_srcs.find (*i) == unique_srcs.end()) {
- (*i)->GoingAway.connect (mem_fun (*this, &AudioRegion::source_deleted));
+ (*i)->GoingAway.connect (bind (mem_fun (*this, &AudioRegion::source_deleted), *i));
}
master_sources.push_back (*i);
}
@@ -175,7 +163,7 @@ AudioRegion::AudioRegion (const AudioRegion& other, jack_nframes_t offset, jack_
if (_fade_in.back()->when >= _length) {
set_default_fade_in ();
} else {
- _fade_in_disabled = other._fade_in_disabled;
+ _fade_in_disabled = other->_fade_in_disabled;
}
set_default_fade_out ();
_flags = Flag (_flags & ~Region::LeftOfSplit);
@@ -185,48 +173,44 @@ AudioRegion::AudioRegion (const AudioRegion& other, jack_nframes_t offset, jack_
if (_fade_out.back()->when >= _length) {
set_default_fade_out ();
} else {
- _fade_out_disabled = other._fade_out_disabled;
+ _fade_out_disabled = other->_fade_out_disabled;
}
set_default_fade_in ();
_flags = Flag (_flags & ~Region::RightOfSplit);
}
- _scale_amplitude = other._scale_amplitude;
+ _scale_amplitude = other->_scale_amplitude;
save_state ("initial state");
_envelope.StateChanged.connect (mem_fun (*this, &AudioRegion::envelope_changed));
-
- if (announce) {
- CheckNewRegion (this); /* EMIT SIGNAL */
- }
}
-AudioRegion::AudioRegion (const AudioRegion &other)
+AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other)
: Region (other),
- _fade_in (other._fade_in),
- _fade_out (other._fade_out),
- _envelope (other._envelope)
+ _fade_in (other->_fade_in),
+ _fade_out (other->_fade_out),
+ _envelope (other->_envelope)
{
/* Pure copy constructor */
set<AudioSource*> unique_srcs;
- for (SourceList::const_iterator i = other.sources.begin(); i != other.sources.end(); ++i) {
+ for (SourceList::const_iterator i = other->sources.begin(); i != other->sources.end(); ++i) {
sources.push_back (*i);
- (*i)->GoingAway.connect (mem_fun (*this, &AudioRegion::source_deleted));
+ (*i)->GoingAway.connect (bind (mem_fun (*this, &AudioRegion::source_deleted), *i));
unique_srcs.insert (*i);
}
- for (SourceList::const_iterator i = other.master_sources.begin(); i != other.master_sources.end(); ++i) {
+ for (SourceList::const_iterator i = other->master_sources.begin(); i != other->master_sources.end(); ++i) {
master_sources.push_back (*i);
if (unique_srcs.find (*i) == unique_srcs.end()) {
- (*i)->GoingAway.connect (mem_fun (*this, &AudioRegion::source_deleted));
+ (*i)->GoingAway.connect (bind (mem_fun (*this, &AudioRegion::source_deleted), *i));
}
}
- _scale_amplitude = other._scale_amplitude;
- _envelope = other._envelope;
+ _scale_amplitude = other->_scale_amplitude;
+ _envelope = other->_envelope;
_fade_in_disabled = 0;
_fade_out_disabled = 0;
@@ -246,7 +230,7 @@ AudioRegion::AudioRegion (AudioSource& src, const XMLNode& node)
{
sources.push_back (&src);
master_sources.push_back (&src);
- src.GoingAway.connect (mem_fun (*this, &AudioRegion::source_deleted));
+ src.GoingAway.connect (bind (mem_fun (*this, &AudioRegion::source_deleted), &src));
set_default_fades ();
@@ -257,8 +241,6 @@ AudioRegion::AudioRegion (AudioSource& src, const XMLNode& node)
save_state ("initial state");
_envelope.StateChanged.connect (mem_fun (*this, &AudioRegion::envelope_changed));
-
- CheckNewRegion (this); /* EMIT SIGNAL */
}
AudioRegion::AudioRegion (SourceList& srcs, const XMLNode& node)
@@ -271,14 +253,14 @@ AudioRegion::AudioRegion (SourceList& srcs, const XMLNode& node)
for (SourceList::iterator i=srcs.begin(); i != srcs.end(); ++i) {
sources.push_back (*i);
- (*i)->GoingAway.connect (mem_fun (*this, &AudioRegion::source_deleted));
+ (*i)->GoingAway.connect (bind (mem_fun (*this, &AudioRegion::source_deleted), *i));
unique_srcs.insert (*i);
}
for (SourceList::iterator i = srcs.begin(); i != srcs.end(); ++i) {
master_sources.push_back (*i);
if (unique_srcs.find (*i) == unique_srcs.end()) {
- (*i)->GoingAway.connect (mem_fun (*this, &AudioRegion::source_deleted));
+ (*i)->GoingAway.connect (bind (mem_fun (*this, &AudioRegion::source_deleted), *i));
}
}
@@ -292,13 +274,11 @@ AudioRegion::AudioRegion (SourceList& srcs, const XMLNode& node)
save_state ("initial state");
_envelope.StateChanged.connect (mem_fun (*this, &AudioRegion::envelope_changed));
-
- CheckNewRegion (this); /* EMIT SIGNAL */
}
AudioRegion::~AudioRegion ()
{
- GoingAway (this);
+ GoingAway (); /* EMIT SIGNAL */
}
StateManager::State*
@@ -1133,9 +1113,10 @@ AudioRegion::master_source_names ()
}
bool
-AudioRegion::source_equivalent (const Region& o) const
+AudioRegion::source_equivalent (boost::shared_ptr<const Region> o) const
{
- const AudioRegion* other = dynamic_cast<const AudioRegion*>(&o);
+ boost::shared_ptr<const AudioRegion> other = boost::dynamic_pointer_cast<const AudioRegion>(o);
+
if (!other)
return false;
@@ -1160,7 +1141,7 @@ AudioRegion::source_equivalent (const Region& o) const
int
AudioRegion::apply (AudioFilter& filter)
{
- return filter.run (*this);
+ return filter.run (boost::shared_ptr<AudioRegion> (this));
}
int
@@ -1227,13 +1208,13 @@ AudioRegion::exportme (Session& session, AudioExportSpecification& spec)
return status;
}
-Region*
+boost::shared_ptr<Region>
AudioRegion::get_parent()
{
- Region* r = 0;
+ boost::shared_ptr<Region> r;
if (_playlist) {
- r = _playlist->session().find_whole_file_parent (*this);
+ r = _playlist->session().find_whole_file_parent (boost::shared_ptr<AudioRegion>(this));
}
return r;
diff --git a/libs/ardour/auditioner.cc b/libs/ardour/auditioner.cc
index dc08979458..91ed4d7efc 100644
--- a/libs/ardour/auditioner.cc
+++ b/libs/ardour/auditioner.cc
@@ -28,6 +28,7 @@
#include <ardour/audioplaylist.h>
#include <ardour/panner.h>
#include <ardour/data_type.h>
+#include <ardour/region_factory.h>
using namespace std;
using namespace ARDOUR;
@@ -57,7 +58,7 @@ Auditioner::Auditioner (Session& s)
IO::output_changed.connect (mem_fun (*this, &Auditioner::output_changed));
- the_region = 0;
+ the_region.reset ((AudioRegion*) 0);
g_atomic_int_set (&_active, 0);
}
@@ -72,7 +73,7 @@ Auditioner::prepare_playlist ()
AudioPlaylist* const apl = dynamic_cast<AudioPlaylist*>(_diskstream->playlist());
assert(apl);
- apl->clear (false, false);
+ apl->clear (false);
return *apl;
}
@@ -99,7 +100,7 @@ Auditioner::audition_current_playlist ()
}
void
-Auditioner::audition_region (AudioRegion& region)
+Auditioner::audition_region (boost::shared_ptr<AudioRegion> region)
{
if (g_atomic_int_get (&_active)) {
/* don't go via session for this, because we are going
@@ -110,11 +111,13 @@ Auditioner::audition_region (AudioRegion& region)
Glib::Mutex::Lock lm (lock);
- the_region = new AudioRegion (region);
+ /* copy it */
+
+ boost::shared_ptr<AudioRegion> the_region (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (region)));
the_region->set_position (0, this);
- _diskstream->playlist()->clear (true, false);
- _diskstream->playlist()->add_region (*the_region, 0, 1, false);
+ _diskstream->playlist()->clear (false);
+ _diskstream->playlist()->add_region (the_region, 0, 1, false);
while (_diskstream->n_channels() < the_region->n_channels()) {
audio_diskstream()->add_channel ();
diff --git a/libs/ardour/automation_event.cc b/libs/ardour/automation_event.cc
index ccfcef28f4..afdeecbbfe 100644
--- a/libs/ardour/automation_event.cc
+++ b/libs/ardour/automation_event.cc
@@ -136,6 +136,8 @@ AutomationList::~AutomationList()
std::set<ControlEvent*> all_events;
AutomationList::State* asp;
+ GoingAway ();
+
for (AutomationEventList::iterator x = events.begin(); x != events.end(); ++x) {
all_events.insert (*x);
}
diff --git a/libs/ardour/control_protocol_manager.cc b/libs/ardour/control_protocol_manager.cc
index 0370886a35..5c02936ba0 100644
--- a/libs/ardour/control_protocol_manager.cc
+++ b/libs/ardour/control_protocol_manager.cc
@@ -43,7 +43,7 @@ void
ControlProtocolManager::set_session (Session& s)
{
_session = &s;
- _session->going_away.connect (mem_fun (*this, &ControlProtocolManager::drop_session));
+ _session->GoingAway.connect (mem_fun (*this, &ControlProtocolManager::drop_session));
for (list<ControlProtocolInfo*>::iterator i = control_protocol_info.begin(); i != control_protocol_info.end(); ++i) {
if ((*i)->requested || (*i)->mandatory) {
diff --git a/libs/ardour/coreaudiosource.cc b/libs/ardour/coreaudiosource.cc
index f0fcac14e2..19b75619e3 100644
--- a/libs/ardour/coreaudiosource.cc
+++ b/libs/ardour/coreaudiosource.cc
@@ -141,7 +141,7 @@ CoreAudioSource::init (const string& idstr)
CoreAudioSource::~CoreAudioSource ()
{
- GoingAway (this); /* EMIT SIGNAL */
+ GoingAway (); /* EMIT SIGNAL */
if (af) {
ExtAudioFileDispose (af);
diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc
index 379c9333b0..fcd2158fd8 100644
--- a/libs/ardour/crossfade.cc
+++ b/libs/ardour/crossfade.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2003 Paul Davis
+ Copyright (C) 2003-2006 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
@@ -36,7 +36,7 @@ using namespace ARDOUR;
using namespace PBD;
jack_nframes_t Crossfade::_short_xfade_length = 0;
-Change Crossfade::ActiveChanged = ARDOUR::new_change();
+Change Crossfade::ActiveChanged = new_change();
/* XXX if and when we ever implement parallel processing of the process()
callback, these will need to be handled on a per-thread basis.
@@ -70,15 +70,15 @@ Crossfade::operator== (const Crossfade& other)
return (_in == other._in) && (_out == other._out);
}
-Crossfade::Crossfade (ARDOUR::AudioRegion& in, ARDOUR::AudioRegion& out,
+Crossfade::Crossfade (boost::shared_ptr<AudioRegion> in, boost::shared_ptr<AudioRegion> out,
jack_nframes_t length,
jack_nframes_t position,
AnchorPoint ap)
: _fade_in (0.0, 2.0, 1.0), // linear (gain coefficient) => -inf..+6dB
_fade_out (0.0, 2.0, 1.0) // linear (gain coefficient) => -inf..+6dB
{
- _in = &in;
- _out = &out;
+ _in = in;
+ _out = out;
_length = length;
_position = position;
_anchor_point = ap;
@@ -89,7 +89,7 @@ Crossfade::Crossfade (ARDOUR::AudioRegion& in, ARDOUR::AudioRegion& out,
initialize ();
}
-Crossfade::Crossfade (ARDOUR::AudioRegion& a, ARDOUR::AudioRegion& b, CrossfadeModel model, bool act)
+Crossfade::Crossfade (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioRegion> b, CrossfadeModel model, bool act)
: _fade_in (0.0, 2.0, 1.0), // linear (gain coefficient) => -inf..+6dB
_fade_out (0.0, 2.0, 1.0) // linear (gain coefficient) => -inf..+6dB
{
@@ -110,7 +110,7 @@ Crossfade::Crossfade (const Playlist& playlist, XMLNode& node)
: _fade_in (0.0, 2.0, 1.0), // linear (gain coefficient) => -inf..+6dB
_fade_out (0.0, 2.0, 1.0) // linear (gain coefficient) => -inf..+6dB
{
- Region* r;
+ boost::shared_ptr<Region> r;
XMLProperty* prop;
LocaleGuard lg (X_("POSIX"));
@@ -129,7 +129,7 @@ Crossfade::Crossfade (const Playlist& playlist, XMLNode& node)
throw failed_constructor();
}
- if ((_in = dynamic_cast<AudioRegion*> (r)) == 0) {
+ if ((_in = boost::dynamic_pointer_cast<AudioRegion> (r)) == 0) {
throw failed_constructor();
}
@@ -146,7 +146,7 @@ Crossfade::Crossfade (const Playlist& playlist, XMLNode& node)
throw failed_constructor();
}
- if ((_out = dynamic_cast<AudioRegion*> (r)) == 0) {
+ if ((_out = boost::dynamic_pointer_cast<AudioRegion> (r)) == 0) {
throw failed_constructor();
}
@@ -160,7 +160,7 @@ Crossfade::Crossfade (const Playlist& playlist, XMLNode& node)
save_state ("initial");
}
-Crossfade::Crossfade (const Crossfade &orig, ARDOUR::AudioRegion *newin, ARDOUR::AudioRegion *newout)
+Crossfade::Crossfade (const Crossfade &orig, boost::shared_ptr<AudioRegion> newin, boost::shared_ptr<AudioRegion> newout)
: _fade_in(orig._fade_in),
_fade_out(orig._fade_out)
{
@@ -236,20 +236,20 @@ Crossfade::initialize (bool savestate)
}
int
-Crossfade::compute (AudioRegion& a, AudioRegion& b, CrossfadeModel model)
+Crossfade::compute (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioRegion> b, CrossfadeModel model)
{
- AudioRegion* top;
- AudioRegion* bottom;
+ boost::shared_ptr<AudioRegion> top;
+ boost::shared_ptr<AudioRegion> bottom;
jack_nframes_t short_xfade_length;
short_xfade_length = _short_xfade_length;
- if (a.layer() < b.layer()) {
- top = &b;
- bottom = &a;
+ if (a->layer() < b->layer()) {
+ top = b;
+ bottom = a;
} else {
- top = &a;
- bottom = &b;
+ top = a;
+ bottom = b;
}
/* first check for matching ends */
@@ -605,7 +605,7 @@ Crossfade::member_changed (Change what_changed)
{
Change what_we_care_about = Change (Region::MuteChanged|
Region::LayerChanged|
- ARDOUR::BoundsChanged);
+ BoundsChanged);
if (what_changed & what_we_care_about) {
refresh ();
diff --git a/libs/ardour/diskstream.cc b/libs/ardour/diskstream.cc
index 151ff5bd3e..ea532d226a 100644
--- a/libs/ardour/diskstream.cc
+++ b/libs/ardour/diskstream.cc
@@ -32,6 +32,8 @@
#include <sys/stat.h>
#include <sys/mman.h>
+#include <sigc++/bind.h>
+
#include <pbd/error.h>
#include <pbd/basename.h>
#include <glibmm/thread.h>
@@ -332,7 +334,7 @@ Diskstream::use_playlist (Playlist* playlist)
plstate_connection = _playlist->StateChanged.connect (mem_fun (*this, &Diskstream::playlist_changed));
plmod_connection = _playlist->Modified.connect (mem_fun (*this, &Diskstream::playlist_modified));
- plgone_connection = _playlist->GoingAway.connect (mem_fun (*this, &Diskstream::playlist_deleted));
+ plgone_connection = _playlist->GoingAway.connect (bind (mem_fun (*this, &Diskstream::playlist_deleted), _playlist));
}
if (!overwrite_queued) {
diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc
index c68eb16aae..6c44185fce 100644
--- a/libs/ardour/import.cc
+++ b/libs/ardour/import.cc
@@ -40,6 +40,7 @@
#include <ardour/sndfilesource.h>
#include <ardour/sndfile_helpers.h>
#include <ardour/audioregion.h>
+#include <ardour/region_factory.h>
#include "i18n.h"
@@ -53,7 +54,7 @@ Session::import_audiofile (import_status& status)
{
SNDFILE *in;
AudioFileSource **newfiles = 0;
- AudioRegion::SourceList sources;
+ SourceList sources;
SF_INFO info;
float *data = 0;
Sample **channel_data = 0;
@@ -217,8 +218,8 @@ Session::import_audiofile (import_status& status)
sources.push_back(newfiles[n]);
}
- AudioRegion *r = new AudioRegion (sources, 0, newfiles[0]->length(), region_name_from_path (Glib::path_get_basename (basepath)),
- 0, AudioRegion::Flag (AudioRegion::DefaultFlags | AudioRegion::WholeFile));
+ boost::shared_ptr<AudioRegion> r (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (sources, 0, newfiles[0]->length(), region_name_from_path (Glib::path_get_basename (basepath)),
+ 0, AudioRegion::Flag (AudioRegion::DefaultFlags | AudioRegion::WholeFile))));
status.new_regions.push_back (r);
@@ -233,9 +234,9 @@ Session::import_audiofile (import_status& status)
did not bother to create whole-file AudioRegions for them. Do it now.
*/
- AudioRegion *r = new AudioRegion (*newfiles[n], 0, newfiles[n]->length(), region_name_from_path (Glib::path_get_basename (newfiles[n]->name())),
- 0, AudioRegion::Flag (AudioRegion::DefaultFlags | AudioRegion::WholeFile | AudioRegion::Import));
-
+ boost::shared_ptr<AudioRegion> r (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (*newfiles[n], 0, newfiles[n]->length(), region_name_from_path (Glib::path_get_basename (newfiles[n]->name())),
+ 0, AudioRegion::Flag (AudioRegion::DefaultFlags | AudioRegion::WholeFile | AudioRegion::Import))));
+
status.new_regions.push_back (r);
}
}
@@ -262,9 +263,8 @@ Session::import_audiofile (import_status& status)
}
if (status.cancel) {
- for (vector<AudioRegion *>::iterator i = status.new_regions.begin(); i != status.new_regions.end(); ++i) {
- delete *i;
- }
+
+ status.new_regions.clear ();
for (vector<string>::iterator i = new_paths.begin(); i != new_paths.end(); ++i) {
unlink ((*i).c_str());
diff --git a/libs/ardour/insert.cc b/libs/ardour/insert.cc
index 18727e8b5b..f9ead93dbc 100644
--- a/libs/ardour/insert.cc
+++ b/libs/ardour/insert.cc
@@ -172,7 +172,7 @@ PluginInsert::init ()
PluginInsert::~PluginInsert ()
{
- GoingAway (this); /* EMIT SIGNAL */
+ GoingAway (); /* EMIT SIGNAL */
}
void
@@ -897,7 +897,7 @@ PortInsert::PortInsert (Session& s, const XMLNode& node)
PortInsert::~PortInsert ()
{
- GoingAway (this);
+ GoingAway ();
}
void
diff --git a/libs/ardour/ladspa_plugin.cc b/libs/ardour/ladspa_plugin.cc
index 6b773b9e0b..310931102d 100644
--- a/libs/ardour/ladspa_plugin.cc
+++ b/libs/ardour/ladspa_plugin.cc
@@ -143,7 +143,7 @@ LadspaPlugin::~LadspaPlugin ()
deactivate ();
cleanup ();
- GoingAway (this); /* EMIT SIGNAL */
+ GoingAway (); /* EMIT SIGNAL */
/* XXX who should close a plugin? */
diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc
index ca88a2851b..58ef812d2e 100644
--- a/libs/ardour/location.cc
+++ b/libs/ardour/location.cc
@@ -51,6 +51,13 @@ Location::Location (const Location& other)
_flags = Flags (_flags & ~IsEnd);
}
+Location::Location (const XMLNode& node)
+{
+ if (set_state (node)) {
+ throw failed_constructor ();
+ }
+}
+
Location*
Location::operator= (const Location& other)
{
@@ -241,13 +248,16 @@ XMLNode&
Location::get_state (void)
{
XMLNode *node = new XMLNode ("Location");
- char buf[32];
+ char buf[64];
typedef map<string, string>::const_iterator CI;
+
for(CI m = cd_info.begin(); m != cd_info.end(); ++m){
node->add_child_nocopy(cd_info_node(m->first, m->second));
}
+ id().print (buf);
+ node->add_property("id", buf);
node->add_property ("name", name());
snprintf (buf, sizeof (buf), "%u", start());
node->add_property ("start", buf);
@@ -262,7 +272,6 @@ Location::get_state (void)
int
Location::set_state (const XMLNode& node)
{
- XMLPropertyList plist;
const XMLProperty *prop;
XMLNodeList cd_list = node.children();
@@ -272,14 +281,17 @@ Location::set_state (const XMLNode& node)
string cd_name;
string cd_value;
-
if (node.name() != "Location") {
error << _("incorrect XML node passed to Location::set_state") << endmsg;
return -1;
}
- plist = node.properties();
-
+ if ((prop = node.property ("id")) == 0) {
+ warning << _("XML node for Location has no ID information") << endmsg;
+ } else {
+ _id = prop->value ();
+ }
+
if ((prop = node.property ("name")) == 0) {
error << _("XML node for Location has no name information") << endmsg;
return -1;
@@ -582,16 +594,20 @@ Locations::set_state (const XMLNode& node)
Glib::Mutex::Lock lm (lock);
for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
- Location *loc = new Location;
- if (loc->set_state (**niter)) {
- delete loc;
- } else {
+ try {
+
+ Location *loc = new Location (**niter);
locations.push_back (loc);
}
+
+ catch (failed_constructor& err) {
+ error << _("could not load location from session file - ignored") << endmsg;
+ }
}
if (locations.size()) {
+
current_location = locations.front();
} else {
current_location = 0;
diff --git a/libs/ardour/osc.cc b/libs/ardour/osc.cc
index 5aaf9d5591..c43f254f6f 100644
--- a/libs/ardour/osc.cc
+++ b/libs/ardour/osc.cc
@@ -365,7 +365,7 @@ void
OSC::set_session (Session& s)
{
session = &s;
- session->going_away.connect (mem_fun (*this, &OSC::session_going_away));
+ session->GoingAway.connect (mem_fun (*this, &OSC::session_going_away));
}
void
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index 6d5e8f7847..b8a7a44f58 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -55,19 +55,19 @@ struct ShowMeTheList {
};
struct RegionSortByLayer {
- bool operator() (Region *a, Region *b) {
+ bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
return a->layer() < b->layer();
}
};
struct RegionSortByPosition {
- bool operator() (Region *a, Region *b) {
+ bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
return a->position() < b->position();
}
};
struct RegionSortByLastLayerOp {
- bool operator() (Region *a, Region *b) {
+ bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
return a->last_layer_op() < b->last_layer_op();
}
};
@@ -101,7 +101,7 @@ Playlist::Playlist (const Playlist& other, string namestr, bool hide)
in_set_state = true;
- for (list<Region*>::iterator x = tmp.begin(); x != tmp.end(); ++x) {
+ for (list<boost::shared_ptr<Region> >::iterator x = tmp.begin(); x != tmp.end(); ++x) {
add_region_internal( (*x), (*x)->position() );
}
@@ -135,8 +135,8 @@ Playlist::Playlist (const Playlist& other, jack_nframes_t start, jack_nframes_t
for (RegionList::const_iterator i = other.regions.begin(); i != other.regions.end(); i++) {
- Region *region;
- Region *new_region;
+ boost::shared_ptr<Region> region;
+ boost::shared_ptr<Region> new_region;
jack_nframes_t offset = 0;
jack_nframes_t position = 0;
jack_nframes_t len = 0;
@@ -178,7 +178,7 @@ Playlist::Playlist (const Playlist& other, jack_nframes_t start, jack_nframes_t
_session.region_name (new_name, region->name(), false);
- new_region = createRegion (*region, offset, len, new_name, region->layer(), region->flags());
+ new_region = RegionFactory::RegionFactory::create (region, offset, len, new_name, region->layer(), region->flags());
add_region_internal (new_region, position, true);
}
@@ -216,7 +216,7 @@ Playlist::copy_regions (RegionList& newlist) const
RegionLock rlock (const_cast<Playlist *> (this));
for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) {
- newlist.push_back (createRegion (**i));
+ newlist.push_back (RegionFactory::RegionFactory::create (*i));
}
}
@@ -259,6 +259,7 @@ Playlist::Playlist (Playlist& pl)
Playlist::~Playlist ()
{
+ /* GoingAway must be emitted by derived classes */
}
void
@@ -329,7 +330,7 @@ Playlist::notify_modified ()
}
void
-Playlist::notify_region_removed (Region *r)
+Playlist::notify_region_removed (boost::shared_ptr<Region> r)
{
if (holding_state ()) {
pending_removals.insert (pending_removals.end(), r);
@@ -344,7 +345,7 @@ Playlist::notify_region_removed (Region *r)
}
void
-Playlist::notify_region_added (Region *r)
+Playlist::notify_region_added (boost::shared_ptr<Region> r)
{
if (holding_state()) {
pending_adds.insert (pending_adds.end(), r);
@@ -374,7 +375,7 @@ Playlist::flush_notifications ()
{
RegionList::iterator r;
RegionList::iterator a;
- set<Region*> dependent_checks_needed;
+ set<boost::shared_ptr<Region> > dependent_checks_needed;
uint32_t n = 0;
if (in_flush) {
@@ -394,7 +395,7 @@ Playlist::flush_notifications ()
for (RegionList::iterator r = pending_bounds.begin(); r != pending_bounds.end(); ++r) {
if (_session.get_layer_model() == Session::MoveAddHigher) {
- timestamp_layer_op (**r);
+ timestamp_layer_op (*r);
}
pending_length = true;
n++;
@@ -411,12 +412,12 @@ Playlist::flush_notifications ()
n++;
}
- for (set<Region*>::iterator x = dependent_checks_needed.begin(); x != dependent_checks_needed.end(); ++x) {
- check_dependents (**x, false);
+ for (set<boost::shared_ptr<Region> >::iterator x = dependent_checks_needed.begin(); x != dependent_checks_needed.end(); ++x) {
+ check_dependents (*x, false);
}
for (r = pending_removals.begin(); r != pending_removals.end(); ++r) {
- remove_dependents (**r);
+ remove_dependents (*r);
RegionRemoved (*r); /* EMIT SIGNAL */
n++;
}
@@ -453,7 +454,7 @@ Playlist::flush_notifications ()
*************************************************************/
void
-Playlist::add_region (const Region& region, jack_nframes_t position, float times, bool with_save)
+Playlist::add_region (boost::shared_ptr<Region> region, jack_nframes_t position, float times, bool with_save)
{
RegionLock rlock (this);
@@ -464,8 +465,8 @@ Playlist::add_region (const Region& region, jack_nframes_t position, float times
jack_nframes_t pos = position;
if (itimes >= 1) {
- add_region_internal (const_cast<Region*>(&region), pos, true);
- pos += region.length();
+ add_region_internal (region, pos, true);
+ pos += region->length();
--itimes;
}
@@ -480,16 +481,16 @@ Playlist::add_region (const Region& region, jack_nframes_t position, float times
*/
for (int i = 0; i < itimes; ++i) {
- Region *copy = createRegion (region);
+ boost::shared_ptr<Region> copy = RegionFactory::create (region);
add_region_internal (copy, pos, true);
- pos += region.length();
+ pos += region->length();
}
if (floor (times) != times) {
- jack_nframes_t length = (jack_nframes_t) floor (region.length() * (times - floor (times)));
+ jack_nframes_t length = (jack_nframes_t) floor (region->length() * (times - floor (times)));
string name;
- _session.region_name (name, region.name(), false);
- Region *sub = createRegion (region, 0, length, name, region.layer(), region.flags());
+ _session.region_name (name, region->name(), false);
+ boost::shared_ptr<Region> sub = RegionFactory::create (region, 0, length, name, region->layer(), region->flags());
add_region_internal (sub, pos, true);
}
@@ -499,13 +500,11 @@ Playlist::add_region (const Region& region, jack_nframes_t position, float times
}
void
-Playlist::add_region_internal (Region *region, jack_nframes_t position, bool delay_sort)
+Playlist::add_region_internal (boost::shared_ptr<Region> region, jack_nframes_t position, bool delay_sort)
{
RegionSortByPosition cmp;
jack_nframes_t old_length = 0;
- // cerr << "adding region " << region->name() << " at " << position << endl;
-
if (!holding_state()) {
old_length = _get_maximum_extent();
}
@@ -514,7 +513,7 @@ Playlist::add_region_internal (Region *region, jack_nframes_t position, bool del
region->set_position (position, this);
region->lock_sources ();
- timestamp_layer_op (*region);
+ timestamp_layer_op (region);
regions.insert (upper_bound (regions.begin(), regions.end(), region, cmp), region);
@@ -528,7 +527,7 @@ Playlist::add_region_internal (Region *region, jack_nframes_t position, bool del
notify_region_added (region);
if (!holding_state ()) {
- check_dependents (*region, false);
+ check_dependents (region, false);
if (old_length != _get_maximum_extent()) {
notify_length_changed ();
}
@@ -538,12 +537,12 @@ Playlist::add_region_internal (Region *region, jack_nframes_t position, bool del
}
void
-Playlist::replace_region (Region& old, Region& newr, jack_nframes_t pos)
+Playlist::replace_region (boost::shared_ptr<Region> old, boost::shared_ptr<Region> newr, jack_nframes_t pos)
{
RegionLock rlock (this);
- remove_region_internal (&old);
- add_region_internal (&newr, pos);
+ remove_region_internal (old);
+ add_region_internal (newr, pos);
if (!holding_state ()) {
possibly_splice_unlocked ();
@@ -553,7 +552,7 @@ Playlist::replace_region (Region& old, Region& newr, jack_nframes_t pos)
}
void
-Playlist::remove_region (Region *region)
+Playlist::remove_region (boost::shared_ptr<Region> region)
{
RegionLock rlock (this);
remove_region_internal (region);
@@ -566,7 +565,7 @@ Playlist::remove_region (Region *region)
}
int
-Playlist::remove_region_internal (Region *region, bool delay_sort)
+Playlist::remove_region_internal (boost::shared_ptr<Region>region, bool delay_sort)
{
RegionList::iterator i;
jack_nframes_t old_length = 0;
@@ -584,7 +583,7 @@ Playlist::remove_region_internal (Region *region, bool delay_sort)
if (!holding_state ()) {
relayer ();
- remove_dependents (*region);
+ remove_dependents (region);
if (old_length != _get_maximum_extent()) {
notify_length_changed ();
@@ -599,7 +598,7 @@ Playlist::remove_region_internal (Region *region, bool delay_sort)
}
void
-Playlist::get_equivalent_regions (const Region& other, vector<Region*>& results)
+Playlist::get_equivalent_regions (boost::shared_ptr<Region> other, vector<boost::shared_ptr<Region> >& results)
{
for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
if (Config->get_use_overlap_equivalency()) {
@@ -613,7 +612,7 @@ Playlist::get_equivalent_regions (const Region& other, vector<Region*>& results)
}
void
-Playlist::get_region_list_equivalent_regions (const Region& other, vector<Region*>& results)
+Playlist::get_region_list_equivalent_regions (boost::shared_ptr<Region> other, vector<boost::shared_ptr<Region> >& results)
{
for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
@@ -641,8 +640,8 @@ void
Playlist::partition_internal (jack_nframes_t start, jack_nframes_t end, bool cutting, RegionList& thawlist)
{
RegionLock rlock (this);
- Region *region;
- Region *current;
+ boost::shared_ptr<Region> region;
+ boost::shared_ptr<Region> current;
string new_name;
RegionList::iterator tmp;
OverlapType overlap;
@@ -702,7 +701,7 @@ Playlist::partition_internal (jack_nframes_t start, jack_nframes_t end, bool cut
/* "middle" ++++++ */
_session.region_name (new_name, current->name(), false);
- region = createRegion (*current, pos2 - pos1, pos3 - pos2, new_name,
+ region = RegionFactory::create (current, pos2 - pos1, pos3 - pos2, new_name,
regions.size(), Region::Flag(current->flags()|Region::Automatic|Region::LeftOfSplit|Region::RightOfSplit));
add_region_internal (region, start, true);
new_regions.push_back (region);
@@ -711,7 +710,7 @@ Playlist::partition_internal (jack_nframes_t start, jack_nframes_t end, bool cut
/* "end" ====== */
_session.region_name (new_name, current->name(), false);
- region = createRegion (*current, pos3 - pos1, pos4 - pos3, new_name,
+ region = RegionFactory::create (current, pos3 - pos1, pos4 - pos3, new_name,
regions.size(), Region::Flag(current->flags()|Region::Automatic|Region::RightOfSplit));
add_region_internal (region, end, true);
@@ -741,7 +740,7 @@ Playlist::partition_internal (jack_nframes_t start, jack_nframes_t end, bool cut
/* end +++++ */
_session.region_name (new_name, current->name(), false);
- region = createRegion (*current, pos2 - pos1, pos4 - pos2, new_name, (layer_t) regions.size(),
+ region = RegionFactory::create (current, pos2 - pos1, pos4 - pos2, new_name, (layer_t) regions.size(),
Region::Flag(current->flags()|Region::Automatic|Region::LeftOfSplit));
add_region_internal (region, start, true);
new_regions.push_back (region);
@@ -775,7 +774,7 @@ Playlist::partition_internal (jack_nframes_t start, jack_nframes_t end, bool cut
/* front **** */
_session.region_name (new_name, current->name(), false);
- region = createRegion (*current, 0, pos3 - pos1, new_name,
+ region = RegionFactory::create (current, 0, pos3 - pos1, new_name,
regions.size(), Region::Flag(current->flags()|Region::Automatic|Region::RightOfSplit));
add_region_internal (region, pos1, true);
new_regions.push_back (region);
@@ -815,7 +814,7 @@ Playlist::partition_internal (jack_nframes_t start, jack_nframes_t end, bool cut
in_partition = false;
for (RegionList::iterator i = new_regions.begin(); i != new_regions.end(); ++i) {
- check_dependents (**i, false);
+ check_dependents (*i, false);
}
}
@@ -936,7 +935,7 @@ Playlist::paste (Playlist& other, jack_nframes_t position, float times)
while (itimes--) {
for (RegionList::iterator i = other.regions.begin(); i != other.regions.end(); ++i) {
- Region *copy_of_region = createRegion (**i);
+ boost::shared_ptr<Region> copy_of_region = RegionFactory::create (*i);
/* put these new regions on top of all existing ones, but preserve
the ordering they had in the original playlist.
@@ -966,7 +965,7 @@ Playlist::paste (Playlist& other, jack_nframes_t position, float times)
void
-Playlist::duplicate (Region& region, jack_nframes_t position, float times)
+Playlist::duplicate (boost::shared_ptr<Region> region, jack_nframes_t position, float times)
{
times = fabs (times);
@@ -975,16 +974,16 @@ Playlist::duplicate (Region& region, jack_nframes_t position, float times)
jack_nframes_t pos = position;
while (itimes--) {
- Region *copy = createRegion (region);
+ boost::shared_ptr<Region> copy = RegionFactory::create (region);
add_region_internal (copy, pos, true);
- pos += region.length();
+ pos += region->length();
}
if (floor (times) != times) {
- jack_nframes_t length = (jack_nframes_t) floor (region.length() * (times - floor (times)));
+ jack_nframes_t length = (jack_nframes_t) floor (region->length() * (times - floor (times)));
string name;
- _session.region_name (name, region.name(), false);
- Region *sub = createRegion (region, 0, length, name, region.layer(), region.flags());
+ _session.region_name (name, region->name(), false);
+ boost::shared_ptr<Region> sub = RegionFactory::create (region, 0, length, name, region->layer(), region->flags());
add_region_internal (sub, pos, true);
}
@@ -992,40 +991,40 @@ Playlist::duplicate (Region& region, jack_nframes_t position, float times)
}
void
-Playlist::split_region (Region& region, jack_nframes_t playlist_position)
+Playlist::split_region (boost::shared_ptr<Region> region, jack_nframes_t playlist_position)
{
RegionLock rl (this);
- if (!region.covers (playlist_position)) {
+ if (!region->covers (playlist_position)) {
return;
}
- if (region.position() == playlist_position ||
- region.last_frame() == playlist_position) {
+ if (region->position() == playlist_position ||
+ region->last_frame() == playlist_position) {
return;
}
- Region *left;
- Region *right;
+ boost::shared_ptr<Region> left;
+ boost::shared_ptr<Region> right;
jack_nframes_t before;
jack_nframes_t after;
string before_name;
string after_name;
- before = playlist_position - region.position();
- after = region.length() - before;
+ before = playlist_position - region->position();
+ after = region->length() - before;
- _session.region_name (before_name, region.name(), false);
- left = createRegion (region, 0, before, before_name, region.layer(), Region::Flag (region.flags()|Region::LeftOfSplit));
+ _session.region_name (before_name, region->name(), false);
+ left = RegionFactory::create (region, 0, before, before_name, region->layer(), Region::Flag (region->flags()|Region::LeftOfSplit));
- _session.region_name (after_name, region.name(), false);
- right = createRegion (region, before, after, after_name, region.layer(), Region::Flag (region.flags()|Region::RightOfSplit));
+ _session.region_name (after_name, region->name(), false);
+ right = RegionFactory::create (region, before, after, after_name, region->layer(), Region::Flag (region->flags()|Region::RightOfSplit));
- add_region_internal (left, region.position(), true);
- add_region_internal (right, region.position() + before);
+ add_region_internal (left, region->position(), true);
+ add_region_internal (right, region->position() + before);
- uint64_t orig_layer_op = region.last_layer_op();
+ uint64_t orig_layer_op = region->last_layer_op();
for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
if ((*i)->last_layer_op() > orig_layer_op) {
(*i)->set_last_layer_op( (*i)->last_layer_op() + 1 );
@@ -1037,9 +1036,9 @@ Playlist::split_region (Region& region, jack_nframes_t playlist_position)
layer_op_counter++;
- finalize_split_region (&region, left, right);
+ finalize_split_region (region, left, right);
- if (remove_region_internal (&region, true)) {
+ if (remove_region_internal (region, true)) {
return;
}
@@ -1103,7 +1102,7 @@ Playlist::core_splice ()
}
void
-Playlist::region_bounds_changed (Change what_changed, Region *region)
+Playlist::region_bounds_changed (Change what_changed, boost::shared_ptr<Region> region)
{
if (in_set_state || _splicing || _nudging) {
return;
@@ -1127,8 +1126,7 @@ Playlist::region_bounds_changed (Change what_changed, Region *region)
}
regions.erase (i);
- regions.insert (upper_bound (regions.begin(), regions.end(), region, cmp),
- region);
+ regions.insert (upper_bound (regions.begin(), regions.end(), region, cmp), region);
}
@@ -1139,11 +1137,11 @@ Playlist::region_bounds_changed (Change what_changed, Region *region)
} else {
if (_session.get_layer_model() == Session::MoveAddHigher) {
/* it moved or changed length, so change the timestamp */
- timestamp_layer_op (*region);
+ timestamp_layer_op (region);
}
possibly_splice ();
- check_dependents (*region, false);
+ check_dependents (region, false);
notify_length_changed ();
relayer ();
}
@@ -1151,7 +1149,7 @@ Playlist::region_bounds_changed (Change what_changed, Region *region)
}
void
-Playlist::region_changed_proxy (Change what_changed, Region* region)
+Playlist::region_changed_proxy (Change what_changed, boost::shared_ptr<Region> region)
{
/* this makes a virtual call to the right kind of playlist ... */
@@ -1159,7 +1157,7 @@ Playlist::region_changed_proxy (Change what_changed, Region* region)
}
bool
-Playlist::region_changed (Change what_changed, Region* region)
+Playlist::region_changed (Change what_changed, boost::shared_ptr<Region> region)
{
Change our_interests = Change (Region::MuteChanged|Region::LayerChanged|Region::OpacityChanged);
bool save = false;
@@ -1176,7 +1174,7 @@ Playlist::region_changed (Change what_changed, Region* region)
if ((what_changed & Region::MuteChanged) &&
!(what_changed & Change (ARDOUR::PositionChanged|ARDOUR::LengthChanged))) {
- check_dependents (*region, false);
+ check_dependents (region, false);
}
if (what_changed & our_interests) {
@@ -1188,7 +1186,7 @@ Playlist::region_changed (Change what_changed, Region* region)
}
void
-Playlist::clear (bool with_delete, bool with_save)
+Playlist::clear (bool with_save)
{
RegionList::iterator i;
RegionList tmp;
@@ -1201,9 +1199,6 @@ Playlist::clear (bool with_delete, bool with_save)
for (i = tmp.begin(); i != tmp.end(); ++i) {
notify_region_removed (*i);
- if (with_delete) {
- delete *i;
- }
}
if (with_save) {
@@ -1223,14 +1218,14 @@ Playlist::regions_at (jack_nframes_t frame)
return find_regions_at (frame);
}
-Region *
+boost::shared_ptr<Region>
Playlist::top_region_at (jack_nframes_t frame)
{
RegionLock rlock (this);
RegionList *rlist = find_regions_at (frame);
- Region *region = 0;
-
+ boost::shared_ptr<Region> region;
+
if (rlist->size()) {
RegionSortByLayer cmp;
rlist->sort (cmp);
@@ -1271,18 +1266,17 @@ Playlist::regions_touched (jack_nframes_t start, jack_nframes_t end)
}
-Region*
-
+boost::shared_ptr<Region>
Playlist::find_next_region (jack_nframes_t frame, RegionPoint point, int dir)
{
RegionLock rlock (this);
- Region* ret = 0;
+ boost::shared_ptr<Region> ret;
jack_nframes_t closest = max_frames;
for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
jack_nframes_t distance;
- Region* r = (*i);
+ boost::shared_ptr<Region> r = (*i);
jack_nframes_t pos = 0;
switch (point) {
@@ -1347,10 +1341,10 @@ Playlist::set_state (const XMLNode& node)
XMLPropertyList plist;
XMLPropertyConstIterator piter;
XMLProperty *prop;
- Region *region;
+ boost::shared_ptr<Region> region;
string region_name;
- clear (false, false);
+ clear (false);
if (node.name() != "Playlist") {
in_set_state = false;
@@ -1380,12 +1374,12 @@ Playlist::set_state (const XMLNode& node)
if (child->name() == "Region") {
- if ((region = createRegion (_session, *child, true)) == 0) {
+ if ((region = RegionFactory::create (_session, *child, true)) == 0) {
error << _("Playlist: cannot create region from state file") << endmsg;
continue;
}
- add_region (*region, region->position(), 1.0, false);
+ add_region (region, region->position(), 1.0, false);
// So that layer_op ordering doesn't get screwed up
region->set_last_layer_op( region->layer());
@@ -1399,7 +1393,7 @@ Playlist::set_state (const XMLNode& node)
*/
for (RegionList::iterator r = regions.begin(); r != regions.end(); ++r) {
- check_dependents (**r, false);
+ check_dependents (*r, false);
}
in_set_state = false;
@@ -1581,10 +1575,10 @@ Playlist::relayer ()
/* XXX these layer functions are all deprecated */
void
-Playlist::raise_region (Region& region)
+Playlist::raise_region (boost::shared_ptr<Region> region)
{
uint32_t rsz = regions.size();
- layer_t target = region.layer() + 1U;
+ layer_t target = region->layer() + 1U;
if (target >= rsz) {
/* its already at the effective top */
@@ -1595,20 +1589,20 @@ Playlist::raise_region (Region& region)
}
void
-Playlist::lower_region (Region& region)
+Playlist::lower_region (boost::shared_ptr<Region> region)
{
- if (region.layer() == 0) {
+ if (region->layer() == 0) {
/* its already at the bottom */
return;
}
- layer_t target = region.layer() - 1U;
+ layer_t target = region->layer() - 1U;
move_region_to_layer (target, region, -1);
}
void
-Playlist::raise_region_to_top (Region& region)
+Playlist::raise_region_to_top (boost::shared_ptr<Region> region)
{
/* does nothing useful if layering mode is later=higher */
if ((_session.get_layer_model() == Session::MoveAddHigher) ||
@@ -1619,21 +1613,21 @@ Playlist::raise_region_to_top (Region& region)
}
void
-Playlist::lower_region_to_bottom (Region& region)
+Playlist::lower_region_to_bottom (boost::shared_ptr<Region> region)
{
/* does nothing useful if layering mode is later=higher */
if ((_session.get_layer_model() == Session::MoveAddHigher) ||
(_session.get_layer_model() == Session::AddHigher)) {
- region.set_last_layer_op (0);
+ region->set_last_layer_op (0);
relayer ();
}
}
int
-Playlist::move_region_to_layer (layer_t target_layer, Region& region, int dir)
+Playlist::move_region_to_layer (layer_t target_layer, boost::shared_ptr<Region> region, int dir)
{
RegionList::iterator i;
- typedef pair<Region*,layer_t> LayerInfo;
+ typedef pair<boost::shared_ptr<Region>,layer_t> LayerInfo;
list<LayerInfo> layerinfo;
layer_t dest;
@@ -1642,7 +1636,7 @@ Playlist::move_region_to_layer (layer_t target_layer, Region& region, int dir)
for (i = regions.begin(); i != regions.end(); ++i) {
- if (&region == *i) {
+ if (region == *i) {
continue;
}
@@ -1652,7 +1646,7 @@ Playlist::move_region_to_layer (layer_t target_layer, Region& region, int dir)
down 1
*/
- if ((*i)->layer() > region.layer() && (*i)->layer() <= target_layer) {
+ if ((*i)->layer() > region->layer() && (*i)->layer() <= target_layer) {
dest = (*i)->layer() - 1;
} else {
/* not affected */
@@ -1664,7 +1658,7 @@ Playlist::move_region_to_layer (layer_t target_layer, Region& region, int dir)
up 1
*/
- if ((*i)->layer() < region.layer() && (*i)->layer() >= target_layer) {
+ if ((*i)->layer() < region->layer() && (*i)->layer() >= target_layer) {
dest = (*i)->layer() + 1;
} else {
/* not affected */
@@ -1687,12 +1681,12 @@ Playlist::move_region_to_layer (layer_t target_layer, Region& region, int dir)
x->first->set_layer (x->second);
}
- region.set_layer (target_layer);
+ region->set_layer (target_layer);
/* now check all dependents */
for (list<LayerInfo>::iterator x = layerinfo.begin(); x != layerinfo.end(); ++x) {
- check_dependents (*(x->first), false);
+ check_dependents (x->first, false);
}
check_dependents (region, false);
@@ -1747,19 +1741,20 @@ Playlist::nudge_after (jack_nframes_t start, jack_nframes_t distance, bool forwa
}
-Region*
+boost::shared_ptr<Region>
Playlist::find_region (const ID& id) const
{
RegionLock rlock (const_cast<Playlist*> (this));
RegionList::const_iterator i;
-
+ boost::shared_ptr<Region> ret;
+
for (i = regions.begin(); i != regions.end(); ++i) {
if ((*i)->id() == id) {
- return (*i);
+ ret = *i;
}
}
- return 0;
+ return ret;
}
void
@@ -1773,7 +1768,7 @@ Playlist::save_state (std::string why)
void
Playlist::dump () const
{
- Region *r;
+ boost::shared_ptr<Region> r;
cerr << "Playlist \"" << _name << "\" " << endl
<< regions.size() << " regions "
@@ -1798,11 +1793,11 @@ Playlist::set_frozen (bool yn)
}
void
-Playlist::timestamp_layer_op (Region& region)
+Playlist::timestamp_layer_op (boost::shared_ptr<Region> region)
{
// struct timeval tv;
// gettimeofday (&tv, 0);
- region.set_last_layer_op (++layer_op_counter);
+ region->set_last_layer_op (++layer_op_counter);
}
void
diff --git a/libs/ardour/playlist_factory.cc b/libs/ardour/playlist_factory.cc
index 7c7060dae8..05d9c76f7a 100644
--- a/libs/ardour/playlist_factory.cc
+++ b/libs/ardour/playlist_factory.cc
@@ -20,60 +20,14 @@
#include <pbd/error.h>
-#include <ardour/session.h>
-
#include <ardour/playlist.h>
#include <ardour/audioplaylist.h>
-#include <ardour/region_factory.h>
-#include <ardour/region.h>
-#include <ardour/audioregion.h>
-
#include "i18n.h"
using namespace ARDOUR;
using namespace PBD;
-Region*
-ARDOUR::createRegion (const Region& region, jack_nframes_t start,
- jack_nframes_t length, std::string name,
- layer_t layer, Region::Flag flags)
-{
- const AudioRegion* ar;
-
- if ((ar = dynamic_cast<const AudioRegion*>(&region)) != 0) {
- AudioRegion* ret;
- ret = new AudioRegion (*ar, start, length, name, layer, flags);
- return ret;
- } else {
- fatal << _("programming error: Playlist::createRegion called with unknown Region type")
- << endmsg;
- /*NOTREACHED*/
- return 0;
- }
-}
-
-Region*
-ARDOUR::createRegion (const Region& region)
-{
- const AudioRegion* ar;
-
- if ((ar = dynamic_cast<const AudioRegion*>(&region)) != 0) {
- return new AudioRegion (*ar);
- } else {
- fatal << _("programming error: Playlist::createRegion called with unknown Region type")
- << endmsg;
- /*NOTREACHED*/
- return 0;
- }
-}
-
-Region*
-ARDOUR::createRegion (Session& session, XMLNode& node, bool yn)
-{
- return session.XMLRegionFactory (node, yn);
-}
-
Playlist*
Playlist::copyPlaylist (const Playlist& playlist, jack_nframes_t start, jack_nframes_t length,
string name, bool result_is_hidden)
diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc
index 037c844324..f81cb3bed5 100644
--- a/libs/ardour/region.cc
+++ b/libs/ardour/region.cc
@@ -47,8 +47,6 @@ Change Region::LockChanged = ARDOUR::new_change ();
Change Region::LayerChanged = ARDOUR::new_change ();
Change Region::HiddenChanged = ARDOUR::new_change ();
-sigc::signal<void,Region *> Region::CheckNewRegion;
-
Region::Region (jack_nframes_t start, jack_nframes_t length, const string& name, layer_t layer, Region::Flag flags)
{
/* basic Region constructor */
@@ -71,7 +69,7 @@ Region::Region (jack_nframes_t start, jack_nframes_t length, const string& name,
_last_layer_op = 0;
}
-Region::Region (const Region& other, jack_nframes_t offset, jack_nframes_t length, const string& name, layer_t layer, Flag flags)
+Region::Region (boost::shared_ptr<const Region> other, jack_nframes_t offset, jack_nframes_t length, const string& name, layer_t layer, Flag flags)
{
/* create a new Region from part of an existing one */
@@ -80,9 +78,9 @@ Region::Region (const Region& other, jack_nframes_t offset, jack_nframes_t lengt
_playlist = 0;
_read_data_count = 0;
- _start = other._start + offset;
- if (other._sync_position < offset) {
- _sync_position = other._sync_position;
+ _start = other->_start + offset;
+ if (other->_sync_position < offset) {
+ _sync_position = other->_sync_position;
} else {
_sync_position = _start;
}
@@ -96,7 +94,7 @@ Region::Region (const Region& other, jack_nframes_t offset, jack_nframes_t lengt
_last_layer_op = 0;
}
-Region::Region (const Region &other)
+Region::Region (boost::shared_ptr<const Region> other)
{
/* Pure copy constructor */
@@ -106,23 +104,23 @@ Region::Region (const Region &other)
_read_data_count = 0;
_first_edit = EditChangesID;
- other._first_edit = EditChangesName;
+ other->_first_edit = EditChangesName;
- if (other._extra_xml) {
- _extra_xml = new XMLNode (*other._extra_xml);
+ if (other->_extra_xml) {
+ _extra_xml = new XMLNode (*other->_extra_xml);
} else {
_extra_xml = 0;
}
- _start = other._start;
- _sync_position = other._sync_position;
- _length = other._length;
- _name = other._name;
- _position = other._position;
- _layer = other._layer;
- _flags = Flag (other._flags & ~Locked);
+ _start = other->_start;
+ _sync_position = other->_sync_position;
+ _length = other->_length;
+ _name = other->_name;
+ _position = other->_position;
+ _layer = other->_layer;
+ _flags = Flag (other->_flags & ~Locked);
_current_state_id = 0;
- _last_layer_op = other._last_layer_op;
+ _last_layer_op = other->_last_layer_op;
}
Region::Region (const XMLNode& node)
@@ -148,6 +146,9 @@ Region::Region (const XMLNode& node)
Region::~Region ()
{
+ notify_callbacks ();
+
+ /* derived classes must emit GoingAway */
}
void
@@ -273,7 +274,7 @@ Region::first_edit ()
_first_edit = EditChangesNothing;
send_change (NameChanged);
- CheckNewRegion (this);
+ /// XXX CheckNewRegion (boost::shared_ptr<Region>(this));
}
}
@@ -284,7 +285,7 @@ Region::move_to_natural_position (void *src)
return;
}
- Region* whole_file_region = get_parent();
+ boost::shared_ptr<Region> whole_file_region = get_parent();
if (whole_file_region) {
set_position (whole_file_region->position() + _start, src);
@@ -342,7 +343,7 @@ Region::set_position_on_top (jack_nframes_t pos, void *src)
}
}
- _playlist->raise_region_to_top (*this);
+ _playlist->raise_region_to_top (boost::shared_ptr<Region>(this));
/* do this even if the position is the same. this helps out
a GUI that has moved its representation already.
@@ -784,7 +785,7 @@ Region::raise ()
return;
}
- _playlist->raise_region (*this);
+ _playlist->raise_region (boost::shared_ptr<Region>(this));
}
void
@@ -794,7 +795,7 @@ Region::lower ()
return;
}
- _playlist->lower_region (*this);
+ _playlist->lower_region (boost::shared_ptr<Region>(this));
}
void
@@ -805,7 +806,7 @@ Region::raise_to_top ()
return;
}
- _playlist->raise_region_to_top (*this);
+ _playlist->raise_region_to_top (boost::shared_ptr<Region>(this));
}
void
@@ -815,7 +816,7 @@ Region::lower_to_bottom ()
return;
}
- _playlist->lower_region_to_bottom (*this);
+ _playlist->lower_region_to_bottom (boost::shared_ptr<Region>(this));
}
void
@@ -992,28 +993,28 @@ Region::set_last_layer_op (uint64_t when)
}
bool
-Region::overlap_equivalent (const Region& other) const
+Region::overlap_equivalent (boost::shared_ptr<const Region> other) const
{
- return coverage (other.first_frame(), other.last_frame()) != OverlapNone;
+ return coverage (other->first_frame(), other->last_frame()) != OverlapNone;
}
bool
-Region::equivalent (const Region& other) const
+Region::equivalent (boost::shared_ptr<const Region> other) const
{
- return _start == other._start &&
- _position == other._position &&
- _length == other._length;
+ return _start == other->_start &&
+ _position == other->_position &&
+ _length == other->_length;
}
bool
-Region::size_equivalent (const Region& other) const
+Region::size_equivalent (boost::shared_ptr<const Region> other) const
{
- return _start == other._start &&
- _length == other._length;
+ return _start == other->_start &&
+ _length == other->_length;
}
bool
-Region::region_list_equivalent (const Region& other) const
+Region::region_list_equivalent (boost::shared_ptr<const Region> other) const
{
- return size_equivalent (other) && source_equivalent (other) && _name == other._name;
+ return size_equivalent (other) && source_equivalent (other) && _name == other->_name;
}
diff --git a/libs/ardour/reverse.cc b/libs/ardour/reverse.cc
index 3fe6aaa630..4d8dd22aa4 100644
--- a/libs/ardour/reverse.cc
+++ b/libs/ardour/reverse.cc
@@ -43,10 +43,10 @@ Reverse::~Reverse ()
}
int
-Reverse::run (AudioRegion& region)
+Reverse::run (boost::shared_ptr<AudioRegion> region)
{
- AudioRegion::SourceList nsrcs;
- AudioRegion::SourceList::iterator si;
+ SourceList nsrcs;
+ SourceList::iterator si;
const jack_nframes_t blocksize = 256 * 1048;
Sample buf[blocksize];
jack_nframes_t fpos;
@@ -61,8 +61,8 @@ Reverse::run (AudioRegion& region)
goto out;
}
- fend = region.start() + region.length();
- fstart = region.start();
+ fend = region->start() + region->length();
+ fstart = region->start();
if (blocksize < fend) {
fpos =max(fstart, fend - blocksize);
@@ -70,7 +70,7 @@ Reverse::run (AudioRegion& region)
fpos = fstart;
}
- to_read = min (region.length(), blocksize);
+ to_read = min (region->length(), blocksize);
/* now read it backwards */
@@ -78,11 +78,11 @@ Reverse::run (AudioRegion& region)
uint32_t n;
- for (n = 0, si = nsrcs.begin(); n < region.n_channels(); ++n, ++si) {
+ for (n = 0, si = nsrcs.begin(); n < region->n_channels(); ++n, ++si) {
/* read it in */
- if (region.source (n).read (buf, fpos, to_read) != to_read) {
+ if (region->source (n).read (buf, fpos, to_read) != to_read) {
goto out;
}
diff --git a/libs/ardour/send.cc b/libs/ardour/send.cc
index 2b72fb9bdb..a8e239d49b 100644
--- a/libs/ardour/send.cc
+++ b/libs/ardour/send.cc
@@ -65,7 +65,7 @@ Send::Send (const Send& other)
Send::~Send ()
{
- GoingAway (this);
+ GoingAway ();
}
XMLNode&
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 91a3bfcc46..21b0cf5fa7 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -372,9 +372,23 @@ Session::~Session ()
_state_of_the_state = StateOfTheState (CannotSave|Deletion);
_engine.remove_session ();
+
+ GoingAway (); /* EMIT SIGNAL */
- going_away (); /* EMIT SIGNAL */
+ /* do this */
+
+ notify_callbacks ();
+
+ /* clear history so that no references to objects are held any more */
+
+ history.clear ();
+
+ /* clear state tree so that no references to objects are held any more */
+ if (state_tree) {
+ delete state_tree;
+ }
+
terminate_butler_thread ();
terminate_midi_thread ();
@@ -433,16 +447,12 @@ Session::~Session ()
#ifdef TRACK_DESTRUCTION
cerr << "delete audio regions\n";
#endif /* TRACK_DESTRUCTION */
- for (AudioRegionList::iterator i = audio_regions.begin(); i != audio_regions.end(); ) {
- AudioRegionList::iterator tmp;
-
- tmp =i;
- ++tmp;
-
- delete i->second;
-
- i = tmp;
+
+ for (AudioRegionList::iterator i = audio_regions.begin(); i != audio_regions.end(); ++i) {
+ i->second->drop_references ();
}
+
+ audio_regions.clear ();
#ifdef TRACK_DESTRUCTION
cerr << "delete routes\n";
@@ -450,12 +460,8 @@ Session::~Session ()
{
RCUWriter<RouteList> writer (routes);
boost::shared_ptr<RouteList> r = writer.get_copy ();
- for (RouteList::iterator i = r->begin(); i != r->end(); ) {
- RouteList::iterator tmp;
- tmp = i;
- ++tmp;
+ for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
(*i)->drop_references ();
- i = tmp;
}
r->clear ();
/* writer goes out of scope and updates master */
@@ -552,10 +558,6 @@ Session::~Session ()
if (mmc) {
delete mmc;
}
-
- if (state_tree) {
- delete state_tree;
- }
}
void
@@ -2497,24 +2499,24 @@ Session::region_name (string& result, string base, bool newlevel) const
}
void
-Session::add_region (Region* region)
+Session::add_region (boost::shared_ptr<Region> region)
{
- AudioRegion* ar = 0;
- AudioRegion* oar = 0;
+ boost::shared_ptr<AudioRegion> ar;
+ boost::shared_ptr<AudioRegion> oar;
bool added = false;
{
Glib::Mutex::Lock lm (region_lock);
- if ((ar = dynamic_cast<AudioRegion*> (region)) != 0) {
+ if ((ar = boost::dynamic_pointer_cast<AudioRegion> (region)) != 0) {
AudioRegionList::iterator x;
for (x = audio_regions.begin(); x != audio_regions.end(); ++x) {
- oar = dynamic_cast<AudioRegion*> (x->second);
+ oar = boost::dynamic_pointer_cast<AudioRegion> (x->second);
- if (ar->region_list_equivalent (*oar)) {
+ if (ar->region_list_equivalent (oar)) {
break;
}
}
@@ -2527,6 +2529,7 @@ Session::add_region (Region* region)
entry.second = ar;
pair<AudioRegionList::iterator,bool> x = audio_regions.insert (entry);
+
if (!x.second) {
return;
@@ -2552,14 +2555,14 @@ Session::add_region (Region* region)
set_dirty();
if (added) {
- region->GoingAway.connect (mem_fun (*this, &Session::remove_region));
+ region->GoingAway.connect (sigc::bind (mem_fun (*this, &Session::remove_region), region));
region->StateChanged.connect (sigc::bind (mem_fun (*this, &Session::region_changed), region));
AudioRegionAdded (ar); /* EMIT SIGNAL */
}
}
void
-Session::region_changed (Change what_changed, Region* region)
+Session::region_changed (Change what_changed, boost::shared_ptr<Region> region)
{
if (what_changed & Region::HiddenChanged) {
/* relay hidden changes */
@@ -2568,22 +2571,22 @@ Session::region_changed (Change what_changed, Region* region)
}
void
-Session::region_renamed (Region* region)
+Session::region_renamed (boost::shared_ptr<Region> region)
{
add_region (region);
}
void
-Session::remove_region (Region* region)
+Session::remove_region (boost::shared_ptr<Region> region)
{
AudioRegionList::iterator i;
- AudioRegion* ar = 0;
+ boost::shared_ptr<AudioRegion> ar;
bool removed = false;
{
Glib::Mutex::Lock lm (region_lock);
- if ((ar = dynamic_cast<AudioRegion*> (region)) != 0) {
+ if ((ar = boost::dynamic_pointer_cast<AudioRegion> (region)) != 0) {
if ((i = audio_regions.find (region->id())) != audio_regions.end()) {
audio_regions.erase (i);
removed = true;
@@ -2609,11 +2612,11 @@ Session::remove_region (Region* region)
}
}
-AudioRegion*
-Session::find_whole_file_parent (AudioRegion& child)
+boost::shared_ptr<AudioRegion>
+Session::find_whole_file_parent (boost::shared_ptr<AudioRegion> child)
{
AudioRegionList::iterator i;
- AudioRegion* region;
+ boost::shared_ptr<AudioRegion> region;
Glib::Mutex::Lock lm (region_lock);
for (i = audio_regions.begin(); i != audio_regions.end(); ++i) {
@@ -2622,28 +2625,28 @@ Session::find_whole_file_parent (AudioRegion& child)
if (region->whole_file()) {
- if (child.source_equivalent (*region)) {
+ if (child->source_equivalent (region)) {
return region;
}
}
}
- return 0;
+ return boost::shared_ptr<AudioRegion> ((AudioRegion*) 0);
}
void
-Session::find_equivalent_playlist_regions (Region& region, vector<Region*>& result)
+Session::find_equivalent_playlist_regions (boost::shared_ptr<Region> region, vector<boost::shared_ptr<Region> >& result)
{
for (PlaylistList::iterator i = playlists.begin(); i != playlists.end(); ++i)
(*i)->get_region_list_equivalent_regions (region, result);
}
int
-Session::destroy_region (Region* region)
+Session::destroy_region (boost::shared_ptr<Region> region)
{
- AudioRegion* aregion;
+ boost::shared_ptr<AudioRegion> aregion;
- if ((aregion = dynamic_cast<AudioRegion*> (region)) == 0) {
+ if ((aregion = boost::dynamic_pointer_cast<AudioRegion> (region)) == 0) {
return 0;
}
@@ -2672,9 +2675,9 @@ Session::destroy_region (Region* region)
}
int
-Session::destroy_regions (list<Region*> regions)
+Session::destroy_regions (list<boost::shared_ptr<Region> > regions)
{
- for (list<Region*>::iterator i = regions.begin(); i != regions.end(); ++i) {
+ for (list<boost::shared_ptr<Region> >::iterator i = regions.begin(); i != regions.end(); ++i) {
destroy_region (*i);
}
return 0;
@@ -2683,12 +2686,12 @@ Session::destroy_regions (list<Region*> regions)
int
Session::remove_last_capture ()
{
- list<Region*> r;
+ list<boost::shared_ptr<Region> > r;
boost::shared_ptr<DiskstreamList> dsl = diskstreams.reader();
for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) {
- list<Region*>& l = (*i)->last_capture_regions();
+ list<boost::shared_ptr<Region> >& l = (*i)->last_capture_regions();
if (!l.empty()) {
r.insert (r.end(), l.begin(), l.end());
@@ -2701,9 +2704,9 @@ Session::remove_last_capture ()
}
int
-Session::remove_region_from_region_list (Region& r)
+Session::remove_region_from_region_list (boost::shared_ptr<Region> r)
{
- remove_region (&r);
+ remove_region (r);
return 0;
}
@@ -2721,7 +2724,7 @@ Session::add_audio_source (AudioSource* source)
audio_sources.insert (entry);
}
- source->GoingAway.connect (mem_fun (this, &Session::remove_source));
+ source->GoingAway.connect (sigc::bind (mem_fun (this, &Session::remove_source), source));
set_dirty();
SourceAdded (source); /* EMIT SIGNAL */
@@ -3055,7 +3058,7 @@ Session::add_playlist (Playlist* playlist)
playlists.insert (playlists.begin(), playlist);
// playlist->ref();
playlist->InUse.connect (mem_fun (*this, &Session::track_playlist));
- playlist->GoingAway.connect (mem_fun (*this, &Session::remove_playlist));
+ playlist->GoingAway.connect (sigc::bind (mem_fun (*this, &Session::remove_playlist), playlist));
}
}
@@ -3126,7 +3129,7 @@ Session::remove_playlist (Playlist* playlist)
}
void
-Session::set_audition (AudioRegion* r)
+Session::set_audition (boost::shared_ptr<AudioRegion> r)
{
pending_audition_region = r;
post_transport_work = PostTransportWork (post_transport_work | PostTransportAudition);
@@ -3136,12 +3139,12 @@ Session::set_audition (AudioRegion* r)
void
Session::non_realtime_set_audition ()
{
- if (pending_audition_region == (AudioRegion*) 0xfeedface) {
+ if (pending_audition_region.get() == (AudioRegion*) 0xfeedface) {
auditioner->audition_current_playlist ();
} else if (pending_audition_region) {
- auditioner->audition_region (*pending_audition_region);
+ auditioner->audition_region (pending_audition_region);
}
- pending_audition_region = 0;
+ pending_audition_region.reset ((AudioRegion*) 0);
AuditionActive (true); /* EMIT SIGNAL */
}
@@ -3154,12 +3157,12 @@ Session::audition_playlist ()
}
void
-Session::audition_region (Region& r)
+Session::audition_region (boost::shared_ptr<Region> r)
{
- AudioRegion* ar = dynamic_cast<AudioRegion*>(&r);
+ boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion>(r);
if (ar) {
Event* ev = new Event (Event::Audition, Event::Add, Event::Immediate, 0, 0.0);
- ev->set_ptr (ar);
+ // ev->set_ptr (ar); // AUDFIX
queue_event (ev);
}
}
@@ -3336,7 +3339,7 @@ Session::add_redirect (Redirect* redirect)
/*NOTREACHED*/
}
- redirect->GoingAway.connect (mem_fun (*this, &Session::remove_redirect));
+ redirect->GoingAway.connect (sigc::bind (mem_fun (*this, &Session::remove_redirect), redirect));
set_dirty();
}
diff --git a/libs/ardour/session_command.cc b/libs/ardour/session_command.cc
index dbe0ffccdd..b54e5c8398 100644
--- a/libs/ardour/session_command.cc
+++ b/libs/ardour/session_command.cc
@@ -13,9 +13,7 @@ using namespace PBD;
namespace ARDOUR {
-static map<PBD::ID, Stateful*> registry;
-
-void Session::register_with_memento_command_factory(PBD::ID id, Stateful *ptr)
+void Session::register_with_memento_command_factory(PBD::ID id, StatefulDestructible *ptr)
{
registry[id] = ptr;
}
@@ -90,7 +88,8 @@ Command *Session::memento_command_factory(XMLNode *n)
}
// For Editor and AutomationLine which are off-limits here
else if (registry.count(id))
- return new MementoCommand<Stateful>(*registry[id], before, after);
+ return new MementoCommand<StatefulDestructible>(*registry[id], before, after);
+
/* we failed */
error << _("could not reconstitute MementoCommand from XMLNode. id=") << id.to_s() << endmsg;
diff --git a/libs/ardour/session_events.cc b/libs/ardour/session_events.cc
index e918e0383f..1e7a2a41ba 100644
--- a/libs/ardour/session_events.cc
+++ b/libs/ardour/session_events.cc
@@ -401,7 +401,7 @@ Session::process_event (Event* ev)
break;
case Event::Audition:
- set_audition (static_cast<AudioRegion*> (ev->ptr));
+ // set_audition (static_cast<AudioRegion*> (ev->ptr)); AUDFIX
break;
case Event::InputConfigurationChange:
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index 6f2ad965b4..3df43157ea 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -81,6 +81,7 @@
#include <ardour/audioregion.h>
#include <ardour/crossfade.h>
#include <ardour/control_protocol_manager.h>
+#include <ardour/region_factory.h>
#include "i18n.h"
#include <locale.h>
@@ -175,7 +176,6 @@ Session::first_stage_init (string fullpath, string snapshot_name)
g_atomic_int_set (&_capture_load, 100);
g_atomic_int_set (&_playback_load_min, 100);
g_atomic_int_set (&_capture_load_min, 100);
- pending_audition_region = 0;
_edit_mode = Slide;
pending_edit_mode = _edit_mode;
_play_range = false;
@@ -190,6 +190,7 @@ Session::first_stage_init (string fullpath, string snapshot_name)
layer_model = MoveAddHigher;
xfade_model = ShortCrossfade;
destructive_index = 0;
+ current_trans = 0;
AudioDiskstream::allocate_working_buffers();
@@ -260,7 +261,7 @@ Session::first_stage_init (string fullpath, string snapshot_name)
/* These are all static "per-class" signals */
- Region::CheckNewRegion.connect (mem_fun (*this, &Session::add_region));
+ RegionFactory::CheckNewRegion.connect (mem_fun (*this, &Session::add_region));
AudioSource::AudioSourceCreated.connect (mem_fun (*this, &Session::add_audio_source));
Playlist::PlaylistCreated.connect (mem_fun (*this, &Session::add_playlist));
Redirect::RedirectCreated.connect (mem_fun (*this, &Session::add_redirect));
@@ -1751,7 +1752,7 @@ Session::load_regions (const XMLNode& node)
{
XMLNodeList nlist;
XMLNodeConstIterator niter;
- AudioRegion* region;
+ boost::shared_ptr<AudioRegion> region;
nlist = node.children();
@@ -1762,21 +1763,22 @@ Session::load_regions (const XMLNode& node)
error << _("Session: cannot create Region from XML description.") << endmsg;
}
}
+
return 0;
}
-AudioRegion *
+boost::shared_ptr<AudioRegion>
Session::XMLRegionFactory (const XMLNode& node, bool full)
{
const XMLProperty* prop;
Source* source;
AudioSource* as;
- AudioRegion::SourceList sources;
+ SourceList sources;
uint32_t nchans = 1;
char buf[128];
if (node.name() != X_("Region")) {
- return 0;
+ return boost::shared_ptr<AudioRegion>();
}
if ((prop = node.property (X_("channels"))) != 0) {
@@ -1787,7 +1789,7 @@ Session::XMLRegionFactory (const XMLNode& node, bool full)
if ((prop = node.property (X_("source-0"))) == 0) {
if ((prop = node.property ("source")) == 0) {
error << _("Session: XMLNode describing a AudioRegion is incomplete (no source)") << endmsg;
- return 0;
+ return boost::shared_ptr<AudioRegion>();
}
}
@@ -1795,13 +1797,13 @@ Session::XMLRegionFactory (const XMLNode& node, bool full)
if ((source = source_by_id (s_id)) == 0) {
error << string_compose(_("Session: XMLNode describing a AudioRegion references an unknown source id =%1"), s_id) << endmsg;
- return 0;
+ return boost::shared_ptr<AudioRegion>();
}
as = dynamic_cast<AudioSource*>(source);
if (!as) {
error << string_compose(_("Session: XMLNode describing a AudioRegion references a non-audio source id =%1"), s_id) << endmsg;
- return 0;
+ return boost::shared_ptr<AudioRegion>();
}
sources.push_back (as);
@@ -1816,24 +1818,26 @@ Session::XMLRegionFactory (const XMLNode& node, bool full)
if ((source = source_by_id (id2)) == 0) {
error << string_compose(_("Session: XMLNode describing a AudioRegion references an unknown source id =%1"), id2) << endmsg;
- return 0;
+ return boost::shared_ptr<AudioRegion>();
}
as = dynamic_cast<AudioSource*>(source);
if (!as) {
error << string_compose(_("Session: XMLNode describing a AudioRegion references a non-audio source id =%1"), id2) << endmsg;
- return 0;
+ return boost::shared_ptr<AudioRegion>();
}
sources.push_back (as);
}
}
try {
- return new AudioRegion (sources, node);
+ boost::shared_ptr<AudioRegion> region (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (sources, node)));
+ return region;
+
}
catch (failed_constructor& err) {
- return 0;
+ return boost::shared_ptr<AudioRegion>();
}
}
@@ -2574,8 +2578,8 @@ Session::set_meter_falloff (float val)
void
Session::begin_reversible_command (string name)
{
- current_trans.clear ();
- current_trans.set_name (name);
+ current_trans = new UndoTransaction;
+ current_trans->set_name (name);
}
void
@@ -2584,11 +2588,11 @@ Session::commit_reversible_command (Command *cmd)
struct timeval now;
if (cmd) {
- current_trans.add_command (cmd);
+ current_trans->add_command (cmd);
}
gettimeofday (&now, 0);
- current_trans.set_timestamp (now);
+ current_trans->set_timestamp (now);
history.add (current_trans);
}
@@ -2976,7 +2980,7 @@ Session::cleanup_sources (Session::cleanup_report& rep)
for (AudioRegionList::iterator r = audio_regions.begin(); r != audio_regions.end(); ) {
AudioRegionList::iterator tmp;
- AudioRegion* ar;
+ boost::shared_ptr<AudioRegion> ar;
tmp = r;
++tmp;
@@ -3360,15 +3364,15 @@ Session::restore_history (string snapshot_name)
it++)
{
XMLNode *t = *it;
- UndoTransaction ut;
+ UndoTransaction* ut = new UndoTransaction ();
struct timeval tv;
- ut.set_name(t->property("name")->value());
+ ut->set_name(t->property("name")->value());
stringstream ss(t->property("tv_sec")->value());
ss >> tv.tv_sec;
ss.str(t->property("tv_usec")->value());
ss >> tv.tv_usec;
- ut.set_timestamp(tv);
+ ut->set_timestamp(tv);
for (XMLNodeConstIterator child_it = t->children().begin();
child_it != t->children().end();
@@ -3382,7 +3386,7 @@ Session::restore_history (string snapshot_name)
{
c = memento_command_factory(n);
if (c)
- ut.add_command(c);
+ ut->add_command(c);
}
else
{
diff --git a/libs/ardour/session_timefx.cc b/libs/ardour/session_timefx.cc
index 45733c75ae..2b6b45dad0 100644
--- a/libs/ardour/session_timefx.cc
+++ b/libs/ardour/session_timefx.cc
@@ -28,6 +28,7 @@
#include <ardour/session.h>
#include <ardour/audioregion.h>
#include <ardour/sndfilesource.h>
+#include <ardour/region_factory.h>
#include "i18n.h"
@@ -36,12 +37,12 @@ using namespace ARDOUR;
using namespace PBD;
using namespace soundtouch;
-AudioRegion*
+boost::shared_ptr<AudioRegion>
Session::tempoize_region (TimeStretchRequest& tsr)
{
- AudioRegion::SourceList sources;
- AudioRegion::SourceList::iterator it;
- AudioRegion* r = 0;
+ SourceList sources;
+ SourceList::iterator it;
+ boost::shared_ptr<AudioRegion> r;
SoundTouch st;
string region_name;
string ident = X_("-TIMEFX-");
@@ -160,10 +161,9 @@ Session::tempoize_region (TimeStretchRequest& tsr)
region_name = tsr.region->name() + X_(".t");
- r = new AudioRegion (sources, 0, sources.front()->length(), region_name,
- 0, AudioRegion::Flag (AudioRegion::DefaultFlags | AudioRegion::WholeFile));
-
-
+ r = (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (sources, 0, sources.front()->length(), region_name,
+ 0, AudioRegion::Flag (AudioRegion::DefaultFlags | AudioRegion::WholeFile))));
+
out:
if (sources.size()) {
@@ -172,7 +172,7 @@ Session::tempoize_region (TimeStretchRequest& tsr)
for deletion.
*/
- if ((r == 0 || !tsr.running)) {
+ if ((!r || !tsr.running)) {
for (it = sources.begin(); it != sources.end(); ++it) {
(*it)->mark_for_remove ();
delete *it;
@@ -183,10 +183,7 @@ Session::tempoize_region (TimeStretchRequest& tsr)
/* if the process was cancelled, delete the region */
if (!tsr.running) {
- if (r) {
- delete r;
- r = 0;
- }
+ r.reset ();
}
return r;
diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc
index b487d4e3a3..f67d61472f 100644
--- a/libs/ardour/sndfilesource.cc
+++ b/libs/ardour/sndfilesource.cc
@@ -235,7 +235,8 @@ SndFileSource::open ()
_length = _info.frames;
- _broadcast_info = (SF_BROADCAST_INFO*) calloc (1, sizeof (SF_BROADCAST_INFO));
+ _broadcast_info = new SF_BROADCAST_INFO;
+ memset (_broadcast_info, 0, sizeof (*_broadcast_info));
/* lookup broadcast info */
@@ -244,7 +245,7 @@ SndFileSource::open ()
/* if the file has data but no broadcast info, then clearly, there is no broadcast info */
if (_length) {
- free (_broadcast_info);
+ delete _broadcast_info;
_broadcast_info = 0;
_flags = Flag (_flags & ~Broadcast);
}
@@ -269,7 +270,7 @@ SndFileSource::open ()
SndFileSource::~SndFileSource ()
{
- GoingAway (this); /* EMIT SIGNAL */
+ GoingAway (); /* EMIT SIGNAL */
if (sf) {
sf_close (sf);
@@ -485,7 +486,7 @@ SndFileSource::setup_broadcast_info (jack_nframes_t when, struct tm& now, time_t
if (sf_command (sf, SFC_SET_BROADCAST_INFO, _broadcast_info, sizeof (*_broadcast_info)) != SF_TRUE) {
error << string_compose (_("cannot set broadcast info for audio file %1; Dropping broadcast info for this file"), _path) << endmsg;
_flags = Flag (_flags & ~Broadcast);
- free (_broadcast_info);
+ delete _broadcast_info;
_broadcast_info = 0;
return -1;
}
@@ -506,7 +507,7 @@ SndFileSource::set_header_timeline_position ()
if (sf_command (sf, SFC_SET_BROADCAST_INFO, _broadcast_info, sizeof (*_broadcast_info)) != SF_TRUE) {
error << string_compose (_("cannot set broadcast info for audio file %1; Dropping broadcast info for this file"), _path) << endmsg;
_flags = Flag (_flags & ~Broadcast);
- free (_broadcast_info);
+ delete _broadcast_info;
_broadcast_info = 0;
}
}
diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc
index 4c09ba3440..dbb7547052 100644
--- a/libs/ardour/vst_plugin.cc
+++ b/libs/ardour/vst_plugin.cc
@@ -98,7 +98,7 @@ VSTPlugin::VSTPlugin (const VSTPlugin &other)
VSTPlugin::~VSTPlugin ()
{
deactivate ();
- GoingAway (this); /* EMIT SIGNAL */
+ GoingAway (); /* EMIT SIGNAL */
fst_close (_fst);
}
diff --git a/libs/pbd/pbd/command.h b/libs/pbd/pbd/command.h
index cd9bf0e08a..7c367e7462 100644
--- a/libs/pbd/pbd/command.h
+++ b/libs/pbd/pbd/command.h
@@ -22,8 +22,9 @@
#define __lib_pbd_command_h__
#include <pbd/stateful.h>
+#include <pbd/destructible.h>
-class Command : public Stateful
+class Command : public Stateful, public PBD::Destructible
{
public:
virtual ~Command() {}
diff --git a/libs/pbd/pbd/memento_command.h b/libs/pbd/pbd/memento_command.h
index 3a72fc9841..f257e63233 100644
--- a/libs/pbd/pbd/memento_command.h
+++ b/libs/pbd/pbd/memento_command.h
@@ -21,6 +21,10 @@
#ifndef __lib_pbd_memento_command_h__
#define __lib_pbd_memento_command_h__
+#include <iostream>
+using std::cerr;
+using std::endl;
+
#include <pbd/command.h>
#include <pbd/xml++.h>
#include <sigc++/slot.h>
@@ -34,12 +38,22 @@ template <class obj_T>
class MementoCommand : public Command
{
public:
- MementoCommand(XMLNode &state);
- MementoCommand(obj_T &obj,
+ MementoCommand(obj_T &object,
XMLNode *before,
XMLNode *after
)
- : obj(obj), before(before), after(after) {}
+ : obj(object), before(before), after(after) {
+ obj.GoingAway.connect (sigc::mem_fun (*this, &MementoCommand<obj_T>::object_death));
+ }
+ ~MementoCommand () {
+ GoingAway();
+ if (before) {
+ delete before;
+ }
+ if (after) {
+ delete after;
+ }
+ }
void operator() ()
{
if (after)
@@ -60,20 +74,27 @@ class MementoCommand : public Command
else
name = "MementoRedoCommand";
+
XMLNode *node = new XMLNode(name);
- node->add_property("obj_id", obj.id().to_s());
- node->add_property("type_name", typeid(obj).name());
- if (before)
- node->add_child_copy(*before);
- if (after)
- node->add_child_copy(*after);
+ node->add_property("obj_id", obj.id().to_s());
+ node->add_property("type_name", typeid(obj).name());
+
+ if (before)
+ node->add_child_copy(*before);
+ if (after)
+ node->add_child_copy(*after);
return *node;
}
+
protected:
obj_T &obj;
XMLNode *before, *after;
+
+ void object_death () {
+ delete this;
+ }
};
#endif // __lib_pbd_memento_h__
diff --git a/libs/pbd/pbd/statefuldestructible.h b/libs/pbd/pbd/statefuldestructible.h
new file mode 100644
index 0000000000..e78cc4bdaa
--- /dev/null
+++ b/libs/pbd/pbd/statefuldestructible.h
@@ -0,0 +1,13 @@
+#ifndef __pbd_stateful_destructible_h__
+#define __pbd_stateful_destructible_h__
+
+#include <pbd/stateful.h>
+#include <pbd/destructible.h>
+
+namespace PBD {
+class StatefulDestructible : public Stateful, public Destructible
+{
+};
+}
+
+#endif /* __pbd_stateful_destructible_h__ */
diff --git a/libs/pbd/pbd/undo.h b/libs/pbd/pbd/undo.h
index 724e86aaa0..eecd8ae49d 100644
--- a/libs/pbd/pbd/undo.h
+++ b/libs/pbd/pbd/undo.h
@@ -29,9 +29,6 @@
#include <sys/time.h>
#include <pbd/command.h>
-using std::string;
-using std::list;
-
typedef sigc::slot<void> UndoAction;
class UndoTransaction : public Command
@@ -40,10 +37,11 @@ class UndoTransaction : public Command
UndoTransaction ();
UndoTransaction (const UndoTransaction&);
UndoTransaction& operator= (const UndoTransaction&);
+ ~UndoTransaction ();
void clear ();
- void add_command (Command *const);
+ void add_command (Command* const);
void operator() ();
void undo();
@@ -51,10 +49,10 @@ class UndoTransaction : public Command
XMLNode &get_state();
- void set_name (const string& str) {
+ void set_name (const std::string& str) {
_name = str;
}
- const string& name() const { return _name; }
+ const std::string& name() const { return _name; }
void set_timestamp (struct timeval &t) {
_timestamp = t;
@@ -65,26 +63,28 @@ class UndoTransaction : public Command
}
private:
- list<Command*> actions;
- struct timeval _timestamp;
- string _name;
+ std::list<Command*> actions;
+ struct timeval _timestamp;
+ std::string _name;
+ bool clearing;
+ void remove_command (Command* const);
};
class UndoHistory
{
public:
- UndoHistory() {}
+ UndoHistory();
~UndoHistory() {}
- void add (UndoTransaction ut);
+ void add (UndoTransaction* ut);
void undo (unsigned int n);
void redo (unsigned int n);
unsigned long undo_depth() const { return UndoList.size(); }
unsigned long redo_depth() const { return RedoList.size(); }
- string next_undo() const { return (UndoList.empty() ? string("") : UndoList.back().name()); }
- string next_redo() const { return (RedoList.empty() ? string("") : RedoList.back().name()); }
+ std::string next_undo() const { return (UndoList.empty() ? std::string("") : UndoList.back()->name()); }
+ std::string next_redo() const { return (RedoList.empty() ? std::string("") : RedoList.back()->name()); }
void clear ();
void clear_undo ();
@@ -92,9 +92,13 @@ class UndoHistory
XMLNode &get_state();
void save_state();
+
private:
- list<UndoTransaction> UndoList;
- list<UndoTransaction> RedoList;
+ bool clearing;
+ std::list<UndoTransaction*> UndoList;
+ std::list<UndoTransaction*> RedoList;
+
+ void remove (UndoTransaction*);
};
diff --git a/libs/pbd/undo.cc b/libs/pbd/undo.cc
index 6f421de84e..717c355bae 100644
--- a/libs/pbd/undo.cc
+++ b/libs/pbd/undo.cc
@@ -19,26 +19,36 @@
*/
#include <iostream>
+#include <string>
+#include <sstream>
#include <pbd/undo.h>
#include <pbd/xml++.h>
-#include <string>
-#include <sstream>
+
+#include <sigc++/bind.h>
using namespace std;
using namespace sigc;
UndoTransaction::UndoTransaction ()
{
+ clearing = false;
}
UndoTransaction::UndoTransaction (const UndoTransaction& rhs)
{
_name = rhs._name;
+ clearing = false;
clear ();
actions.insert(actions.end(),rhs.actions.begin(),rhs.actions.end());
}
+UndoTransaction::~UndoTransaction ()
+{
+ GoingAway ();
+ clear ();
+}
+
UndoTransaction&
UndoTransaction::operator= (const UndoTransaction& rhs)
{
@@ -52,13 +62,31 @@ UndoTransaction::operator= (const UndoTransaction& rhs)
void
UndoTransaction::add_command (Command *const action)
{
+ action->GoingAway.connect (bind (mem_fun (*this, &UndoTransaction::remove_command), action));
actions.push_back (action);
}
void
+UndoTransaction::remove_command (Command* const action)
+{
+ if (clearing) {
+ return;
+ }
+ actions.remove (action);
+ if (actions.empty()) {
+ delete this;
+ }
+}
+
+void
UndoTransaction::clear ()
{
+ clearing = true;
+ for (list<Command*>::iterator i = actions.begin(); i != actions.end(); ++i) {
+ delete *i;
+ }
actions.clear ();
+ clearing = false;
}
void
@@ -72,7 +100,6 @@ UndoTransaction::operator() ()
void
UndoTransaction::undo ()
{
- cerr << "Undo " << _name << endl;
for (list<Command*>::reverse_iterator i = actions.rbegin(); i != actions.rend(); ++i) {
(*i)->undo();
}
@@ -81,7 +108,6 @@ UndoTransaction::undo ()
void
UndoTransaction::redo ()
{
- cerr << "Redo " << _name << endl;
(*this)();
}
@@ -103,10 +129,29 @@ XMLNode &UndoTransaction::get_state()
return *node;
}
+UndoHistory::UndoHistory ()
+{
+ clearing = false;
+}
+
void
-UndoHistory::add (UndoTransaction ut)
+UndoHistory::add (UndoTransaction* const ut)
{
+ ut->GoingAway.connect (bind (mem_fun (*this, &UndoHistory::remove), ut));
UndoList.push_back (ut);
+
+ /* we are now owners of the transaction */
+}
+
+void
+UndoHistory::remove (UndoTransaction* const ut)
+{
+ if (clearing) {
+ return;
+ }
+
+ UndoList.remove (ut);
+ RedoList.remove (ut);
}
void
@@ -116,9 +161,9 @@ UndoHistory::undo (unsigned int n)
if (UndoList.size() == 0) {
return;
}
- UndoTransaction ut = UndoList.back ();
+ UndoTransaction* ut = UndoList.back ();
UndoList.pop_back ();
- ut.undo ();
+ ut->undo ();
RedoList.push_back (ut);
}
}
@@ -130,9 +175,9 @@ UndoHistory::redo (unsigned int n)
if (RedoList.size() == 0) {
return;
}
- UndoTransaction ut = RedoList.back ();
+ UndoTransaction* ut = RedoList.back ();
RedoList.pop_back ();
- ut.redo ();
+ ut->redo ();
UndoList.push_back (ut);
}
}
@@ -140,29 +185,34 @@ UndoHistory::redo (unsigned int n)
void
UndoHistory::clear_redo ()
{
+ clearing = true;
RedoList.clear ();
+ clearing = false;
}
void
UndoHistory::clear_undo ()
{
+ clearing = true;
UndoList.clear ();
+ clearing = false;
}
void
UndoHistory::clear ()
{
- RedoList.clear ();
- UndoList.clear ();
+ clear_undo ();
+ clear_redo ();
}
XMLNode & UndoHistory::get_state()
{
XMLNode *node = new XMLNode ("UndoHistory");
- list<UndoTransaction>::iterator it;
- for (it=UndoList.begin(); it != UndoList.end(); it++)
- node->add_child_nocopy(it->get_state());
+ list<UndoTransaction*>::iterator it;
+ for (it = UndoList.begin(); it != UndoList.end(); it++) {
+ node->add_child_nocopy((*it)->get_state());
+ }
return *node;
}