Clean up State API:

* Processor implement get_state(), classes derived from Processor
  implement protected ::state() -- as documented in processor.h
* likewise for Route, Track: make ::state() a protected interface
* removal of "full_state", use explicit "template_save"
* use RAII/Unwind to skip saving automation-state
This commit is contained in:
Robin Gareus 2017-10-04 00:35:29 +02:00
parent 5dd9acf9ab
commit e31f5d9998
58 changed files with 197 additions and 218 deletions

View file

@ -365,9 +365,9 @@ Amp::apply_simple_gain (AudioBuffer& buf, samplecnt_t nframes, gain_t target)
}
XMLNode&
Amp::state (bool full_state)
Amp::state ()
{
XMLNode& node (Processor::state (full_state));
XMLNode& node (Processor::state ());
node.set_property("type", _gain_control->parameter().type() == GainAutomation ? "amp" : "trim");
node.add_child_nocopy (_gain_control->get_state());

View file

@ -53,7 +53,7 @@ public:
void setup_gain_automation (samplepos_t start_sample, samplepos_t end_sample, samplecnt_t nframes);
XMLNode& state (bool full);
XMLNode& state ();
int set_state (const XMLNode&, int version);
static gain_t apply_gain (BufferSet& bufs, samplecnt_t sample_rate, samplecnt_t nframes, gain_t initial, gain_t target, bool midi_amp = true);

View file

@ -51,7 +51,7 @@ class LIBARDOUR_API AudioTrack : public Track
boost::shared_ptr<AudioFileSource> write_source (uint32_t n = 0);
protected:
XMLNode& state (bool full);
XMLNode& state (bool save_template);
private:
int deprecated_use_diskstream_connections ();

View file

@ -52,6 +52,8 @@ public:
virtual ~Automatable();
static bool skip_saving_automation; // to be used only by session-state
boost::shared_ptr<Evoral::Control> control_factory(const Evoral::Parameter& id);
boost::shared_ptr<AutomationControl> automation_control (PBD::ID const & id) const;

View file

@ -125,7 +125,7 @@ private:
void create_curve_if_necessary ();
int deserialize_events (const XMLNode&);
XMLNode& state (bool full, bool need_lock);
XMLNode& state (bool save_auto_state, bool need_lock);
XMLNode& serialize_events (bool need_lock);
void maybe_signal_changed ();

View file

@ -28,23 +28,24 @@ namespace ARDOUR {
class LIBARDOUR_API CapturingProcessor : public Processor
{
public:
public:
CapturingProcessor (Session & session, samplecnt_t latency);
~CapturingProcessor();
public: // main interface
public: // main interface
BufferSet const & get_capture_buffers() const { return capture_buffers; }
public: // Processor overrides
public: // Processor overrides
bool display_to_user() const { return false; }
int set_block_size (pframes_t nframes);
void run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool result_required);
bool configure_io (ChanCount in, ChanCount out);
bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
virtual XMLNode& state (bool);
private:
protected:
XMLNode& state ();
private:
void realloc_buffers();
samplecnt_t block_size;

View file

@ -56,7 +56,8 @@ public:
bool set_name (const std::string& str);
XMLNode& state (bool full);
protected:
XMLNode& state ();
private:
void allocate_pending_buffers (samplecnt_t);

View file

@ -84,7 +84,6 @@ public:
PBD::Signal0<void> MuteChange;
XMLNode& state (bool full);
int set_state (const XMLNode&, int version);
/* Panning */
@ -103,7 +102,9 @@ public:
uint32_t pans_required() const { return _configured_input.n_audio(); }
virtual uint32_t pan_outs() const;
protected:
protected:
XMLNode& state ();
Role _role;
BufferSet* _output_buffers;
gain_t _current_gain;
@ -111,7 +112,7 @@ public:
gain_t target_gain ();
private:
private:
bool _no_outs_cuz_we_no_monitor;
boost::shared_ptr<MuteMaster> _mute_master;

View file

@ -35,7 +35,7 @@ template<typename T> class MidiRingBuffer;
class LIBARDOUR_API DiskReader : public DiskIOProcessor
{
public:
public:
DiskReader (Session&, std::string const & name, DiskIOProcessor::Flag f = DiskIOProcessor::Flag (0));
~DiskReader ();
@ -52,7 +52,6 @@ class LIBARDOUR_API DiskReader : public DiskIOProcessor
int overwrite_existing_buffers ();
void set_pending_overwrite (bool yn);
virtual XMLNode& state (bool full);
int set_state (const XMLNode&, int version);
PBD::Signal0<void> AlignmentStyleChanged;
@ -99,17 +98,19 @@ class LIBARDOUR_API DiskReader : public DiskIOProcessor
static void set_no_disk_output (bool yn);
static bool no_disk_output() { return _no_disk_output; }
protected:
protected:
friend class Track;
friend class MidiTrack;
XMLNode& state ();
void resolve_tracker (Evoral::EventSink<samplepos_t>& buffer, samplepos_t time);
void playlist_changed (const PBD::PropertyChange&);
int use_playlist (DataType, boost::shared_ptr<Playlist>);
void playlist_ranges_moved (std::list< Evoral::RangeMove<samplepos_t> > const &, bool);
private:
private:
/** The number of samples by which this diskstream's output should be delayed
with respect to the transport sample. This is used for latency compensation.
*/

View file

@ -55,7 +55,6 @@ public:
void non_realtime_locate (samplepos_t);
void realtime_handle_transport_stopped ();
virtual XMLNode& state (bool full);
int set_state (const XMLNode&, int version);
virtual bool set_write_source_name (const std::string& str);
@ -133,6 +132,9 @@ public:
protected:
friend class Track;
virtual XMLNode& state ();
int do_flush (RunContext context, bool force = false);
void get_input_sources ();

View file

@ -31,12 +31,9 @@ class InternalSend;
class LIBARDOUR_API InternalReturn : public Return
{
public:
public:
InternalReturn (Session&);
XMLNode& state (bool full);
XMLNode& get_state ();
void run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool);
bool configure_io (ChanCount, ChanCount);
bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
@ -46,7 +43,10 @@ class LIBARDOUR_API InternalReturn : public Return
void set_playback_offset (samplecnt_t cnt);
private:
protected:
XMLNode& state ();
private:
/** sends that we are receiving data from */
std::list<InternalSend*> _sends;
/** mutex to protect _sends */

View file

@ -27,7 +27,7 @@ namespace ARDOUR {
class LIBARDOUR_API InternalSend : public Send
{
public:
public:
InternalSend (Session&, boost::shared_ptr<Pannable>, boost::shared_ptr<MuteMaster>, boost::shared_ptr<Route> send_from, boost::shared_ptr<Route> send_to, Delivery::Role role = Delivery::Aux, bool ignore_bitslot = false);
virtual ~InternalSend ();
@ -35,8 +35,6 @@ class LIBARDOUR_API InternalSend : public Send
bool set_name (const std::string&);
bool visible() const;
XMLNode& state(bool full);
XMLNode& get_state(void);
int set_state(const XMLNode& node, int version);
void cycle_start (pframes_t);
@ -62,7 +60,10 @@ class LIBARDOUR_API InternalSend : public Send
static PBD::Signal1<void, pframes_t> CycleStart;
private:
protected:
XMLNode& state();
private:
BufferSet mixbufs;
boost::shared_ptr<Route> _send_from;
boost::shared_ptr<Route> _send_to;

View file

@ -67,7 +67,7 @@ class UserBundle;
*/
class LIBARDOUR_API IO : public SessionObject, public Latent
{
public:
public:
static const std::string state_node_name;
enum Direction {
@ -147,8 +147,8 @@ class LIBARDOUR_API IO : public SessionObject, public Latent
*/
PBD::Signal2<void, IOChange, void *> changed;
virtual XMLNode& state (bool full);
XMLNode& get_state (void);
int set_state (const XMLNode&, int version);
int set_state_2X (const XMLNode&, int, bool);
static void prepare_for_reset (XMLNode&, const std::string&);
@ -205,17 +205,17 @@ class LIBARDOUR_API IO : public SessionObject, public Latent
int set_ports (const std::string& str);
private:
mutable Glib::Threads::Mutex io_lock;
protected:
virtual XMLNode& state ();
protected:
PortSet _ports;
Direction _direction;
DataType _default_type;
bool _active;
bool _sendish;
private:
private:
mutable Glib::Threads::Mutex io_lock;
int connecting_became_legal ();
PBD::ScopedConnection connection_legal_c;

View file

@ -74,7 +74,7 @@ class LIBARDOUR_API IOProcessor : public Processor
PBD::Signal2<void,IOProcessor*,bool> AutomationPlaybackChanged;
PBD::Signal2<void,IOProcessor*,uint32_t> AutomationChanged;
XMLNode& state (bool full_state);
XMLNode& state ();
int set_state (const XMLNode&, int version);
static void prepare_for_reset (XMLNode& state, const std::string& name);

View file

@ -63,7 +63,7 @@ class LIBARDOUR_API LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
LV2Plugin (const LV2Plugin &);
~LV2Plugin ();
static bool force_state_save;
static bool force_state_save; // to be used only by session-state
std::string unique_id () const;
const char* uri () const;

View file

@ -77,10 +77,12 @@ public:
void set_type(MeterType t);
MeterType get_type() { return _meter_type; }
XMLNode& state (bool full);
PBD::Signal1<void, MeterType> TypeChanged;
protected:
XMLNode& state ();
private:
friend class IO;

View file

@ -133,7 +133,8 @@ public:
PBD::Signal0<void> InputActiveChanged;
protected:
XMLNode& state (bool full);
XMLNode& state (bool save_template);
void act_on_mute ();
void monitoring_changed (bool, PBD::Controllable::GroupControlDisposition);

View file

@ -126,7 +126,7 @@ public:
void run (BufferSet& /*bufs*/, samplepos_t /*start_sample*/, samplepos_t /*end_sample*/, double /*speed*/, pframes_t /*nframes*/, bool /*result_required*/);
XMLNode& state (bool full);
XMLNode& state ();
int set_state (const XMLNode&, int /* version */);
bool configure_io (ChanCount in, ChanCount out);

View file

@ -38,7 +38,7 @@ class Panner;
class LIBARDOUR_API Pannable : public PBD::Stateful, public Automatable, public SessionHandleRef
{
public:
public:
Pannable (Session& s);
~Pannable ();
@ -73,12 +73,13 @@ class LIBARDOUR_API Pannable : public PBD::Stateful, public Automatable, public
bool touch_enabled() const { return _auto_state & (Touch | Latch); }
XMLNode& get_state ();
XMLNode& state (bool full_state);
int set_state (const XMLNode&, int version);
bool has_state() const { return _has_state; }
protected:
protected:
virtual XMLNode& state ();
boost::weak_ptr<Panner> _panner;
AutoState _auto_state;
gint _touching;
@ -87,7 +88,7 @@ class LIBARDOUR_API Pannable : public PBD::Stateful, public Automatable, public
void control_auto_state_changed (AutoState);
private:
private:
void value_changed ();
};

View file

@ -50,14 +50,12 @@ class Plugin;
*/
class LIBARDOUR_API PluginInsert : public Processor
{
public:
public:
PluginInsert (Session&, boost::shared_ptr<Plugin> = boost::shared_ptr<Plugin>());
~PluginInsert ();
static const std::string port_automation_node_name;
XMLNode& state(bool);
XMLNode& get_state(void);
int set_state(const XMLNode&, int version);
void update_id (PBD::ID);
void set_owner (SessionObject*);
@ -215,7 +213,7 @@ class LIBARDOUR_API PluginInsert : public Processor
double get_value (void) const;
XMLNode& get_state();
protected:
protected:
void actually_set_value (double value, PBD::Controllable::GroupControlDisposition);
private:
@ -301,7 +299,10 @@ class LIBARDOUR_API PluginInsert : public Processor
bool custom_cfg; ///< custom config (if not strict)
};
private:
protected:
XMLNode& state ();
private:
/* disallow copy construction */
PluginInsert (const PluginInsert&);

View file

@ -45,12 +45,10 @@ class Pannable;
*/
class LIBARDOUR_API PortInsert : public IOProcessor
{
public:
public:
PortInsert (Session&, boost::shared_ptr<Pannable>, boost::shared_ptr<MuteMaster> mm);
~PortInsert ();
XMLNode& state(bool full);
XMLNode& get_state(void);
int set_state (const XMLNode&, int version);
void run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool);
@ -82,7 +80,9 @@ class LIBARDOUR_API PortInsert : public IOProcessor
static std::string name_and_id_new_insert (Session&, uint32_t&);
private:
protected:
XMLNode& state ();
private:
/* disallow copy construction */
PortInsert (const PortInsert&);

View file

@ -120,8 +120,7 @@ class LIBARDOUR_API Processor : public SessionObject, public Automatable, public
smoothly.
*/
virtual XMLNode& state (bool full);
XMLNode& get_state (void);
XMLNode& get_state ();
int set_state (const XMLNode&, int version);
virtual void set_pre_fader (bool);
@ -147,6 +146,7 @@ class LIBARDOUR_API Processor : public SessionObject, public Automatable, public
SessionObject* owner() const;
protected:
virtual XMLNode& state ();
virtual int set_state_2X (const XMLNode&, int version);
int _pending_active;

View file

@ -88,7 +88,7 @@ class LIBARDOUR_API Region
, public Trimmable
, public Movable
{
public:
public:
typedef std::vector<boost::shared_ptr<Source> > SourceList;
static void make_property_quarks ();
@ -281,7 +281,6 @@ class LIBARDOUR_API Region
/* serialization */
XMLNode& get_state ();
virtual XMLNode& state ();
virtual int set_state (const XMLNode&, int version);
virtual boost::shared_ptr<Region> get_parent() const;
@ -344,7 +343,9 @@ class LIBARDOUR_API Region
void drop_sources ();
protected:
protected:
virtual XMLNode& state ();
friend class RegionFactory;
/** Construct a region from multiple sources*/
@ -366,7 +367,7 @@ class LIBARDOUR_API Region
return false;
}
protected:
protected:
void send_change (const PBD::PropertyChange&);
virtual int _set_state (const XMLNode&, int version, PBD::PropertyChange& what_changed, bool send_signal);
@ -412,7 +413,7 @@ class LIBARDOUR_API Region
samplepos_t _transient_analysis_start;
samplepos_t _transient_analysis_end;
private:
private:
void mid_thaw (const PBD::PropertyChange&);
virtual void trim_to_internal (samplepos_t position, samplecnt_t length, const int32_t sub_num);

View file

@ -51,8 +51,6 @@ public:
bool metering() const { return _metering; }
void set_metering (bool yn) { _metering = yn; }
XMLNode& state(bool full);
XMLNode& get_state(void);
int set_state(const XMLNode&, int version);
uint32_t pans_required() const { return _configured_input.n_audio(); }
@ -63,7 +61,9 @@ public:
static uint32_t how_many_returns();
static std::string name_and_id_new_return (Session&, uint32_t&);
protected:
protected:
XMLNode& state();
bool _metering;
boost::shared_ptr<GainControl> _gain_control;
boost::shared_ptr<Amp> _amp;

View file

@ -390,10 +390,9 @@ public:
PBD::Signal0<void> io_changed;
/* stateful */
XMLNode& get_state();
XMLNode& get_template();
virtual int set_state (const XMLNode&, int version);
virtual XMLNode& get_template();
XMLNode& get_processor_state ();
void set_processor_state (const XMLNode&);
@ -674,7 +673,7 @@ protected:
virtual ChanCount input_streams () const;
virtual XMLNode& state(bool);
virtual XMLNode& state (bool save_template);
int configure_processors (ProcessorStreams*);

View file

@ -36,7 +36,7 @@ class DelayLine;
class LIBARDOUR_API Send : public Delivery
{
public:
public:
Send (Session&, boost::shared_ptr<Pannable> pannable, boost::shared_ptr<MuteMaster>, Delivery::Role r = Delivery::Send, bool ignore_bitslot = false);
virtual ~Send ();
@ -51,8 +51,6 @@ class LIBARDOUR_API Send : public Delivery
bool metering() const { return _metering; }
void set_metering (bool yn) { _metering = yn; }
XMLNode& state (bool full);
XMLNode& get_state ();
int set_state(const XMLNode&, int version);
PBD::Signal0<void> SelfDestruct;
@ -83,7 +81,9 @@ class LIBARDOUR_API Send : public Delivery
static uint32_t how_many_sends();
static std::string name_and_id_new_send (Session&, Delivery::Role r, uint32_t&, bool);
protected:
protected:
XMLNode& state ();
bool _metering;
boost::shared_ptr<GainControl> _gain_control;
boost::shared_ptr<Amp> _amp;
@ -91,7 +91,7 @@ class LIBARDOUR_API Send : public Delivery
boost::shared_ptr<DelayLine> _send_delay;
boost::shared_ptr<DelayLine> _thru_delay;
private:
private:
/* disallow copy construction */
Send (const Send&);

View file

@ -563,10 +563,7 @@ public:
std::vector<std::string> possible_states() const;
static std::vector<std::string> possible_states (std::string path);
XMLNode& get_state();
int set_state(const XMLNode& node, int version); // not idempotent
XMLNode& get_template();
bool export_track_state (boost::shared_ptr<RouteList> rl, const std::string& path);
bool export_track_state (boost::shared_ptr<RouteList> rl, const std::string& path);
/// The instant xml file is written to the session directory
void add_instant_xml (XMLNode&, bool write_to_config = true);
@ -1903,7 +1900,11 @@ private:
SwitchToSnapshot
};
XMLNode& state(bool, snapshot_t snapshot_type = NormalSave);
XMLNode& state (bool save_template, snapshot_t snapshot_type = NormalSave);
XMLNode& get_state ();
int set_state (const XMLNode& node, int version); // not idempotent
XMLNode& get_template ();
/* click track */
typedef std::list<Click*> Clicks;

View file

@ -73,7 +73,7 @@ private:
void find_equivalent_playlist_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >& result);
void update_after_tempo_map_change ();
void add_state (XMLNode *, bool);
void add_state (XMLNode*, bool save_template, bool include_unused);
bool maybe_delete_unused (boost::function<int(boost::shared_ptr<Playlist>)>);
int load (Session &, const XMLNode&);
int load_unused (Session &, const XMLNode&);

View file

@ -39,8 +39,10 @@ public:
bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
bool configure_io (ChanCount in, ChanCount out);
XMLNode& state(bool full);
int set_state(const XMLNode&, int version);
int set_state(const XMLNode&, int version);
protected:
XMLNode& state ();
private:
/* disallow copy construction */

View file

@ -50,7 +50,7 @@ class RecordSafeControl;
*/
class LIBARDOUR_API Track : public Route, public Recordable
{
public:
public:
Track (Session&, std::string name, PresentationInfo::Flag f = PresentationInfo::Flag (0), TrackMode m = Normal, DataType default_type = DataType::AUDIO);
virtual ~Track ();
@ -110,8 +110,6 @@ class LIBARDOUR_API Track : public Route, public Recordable
virtual int export_stuff (BufferSet& bufs, samplepos_t start_sample, samplecnt_t nframes,
boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export, bool for_freeze) = 0;
XMLNode& get_state();
XMLNode& get_template();
virtual int set_state (const XMLNode&, int version);
static void zero_diskstream_id_in_xml (XMLNode&);
@ -175,8 +173,8 @@ class LIBARDOUR_API Track : public Route, public Recordable
PBD::Signal0<void> SpeedChanged;
PBD::Signal0<void> AlignmentStyleChanged;
protected:
XMLNode& state (bool full);
protected:
XMLNode& state (bool save_template);
boost::shared_ptr<Playlist> _playlists[DataType::num_types];

View file

@ -48,7 +48,8 @@ public:
bool can_support_io_configuration (const ChanCount &, ChanCount &);
void run (BufferSet& /*bufs*/, samplepos_t /*start_sample*/, samplepos_t /*end_sample*/, double /*speed*/, pframes_t /*nframes*/, bool /*result_required*/);
XMLNode & state (bool);
protected:
XMLNode& state ();
private:
XMLNode _state;

View file

@ -95,9 +95,9 @@ AudioTrack::set_state (const XMLNode& node, int version)
}
XMLNode&
AudioTrack::state (bool full_state)
AudioTrack::state (bool save_template)
{
XMLNode& root (Track::state(full_state));
XMLNode& root (Track::state (save_template));
XMLNode* freeze_node;
if (_freeze_record.playlist) {

View file

@ -48,6 +48,9 @@ using namespace std;
using namespace ARDOUR;
using namespace PBD;
/* used for templates (previously: !full_state) */
bool Automatable::skip_saving_automation = false;
const string Automatable::xml_node_name = X_("Automation");
Automatable::Automatable(Session& session)

View file

@ -344,7 +344,7 @@ AutomationList::get_state ()
}
XMLNode&
AutomationList::state (bool full, bool need_lock)
AutomationList::state (bool save_auto_state, bool need_lock)
{
XMLNode* root = new XMLNode (X_("AutomationList"));
@ -352,7 +352,7 @@ AutomationList::state (bool full, bool need_lock)
root->set_property ("id", id());
root->set_property ("interpolation-style", _interpolation);
if (full) {
if (save_auto_state) {
/* never serialize state with Write enabled - too dangerous
for the user's data
*/

View file

@ -84,9 +84,9 @@ CapturingProcessor::realloc_buffers()
}
XMLNode &
CapturingProcessor::state (bool full)
CapturingProcessor::state ()
{
XMLNode& node = Processor::state (full);
XMLNode& node = Processor::state ();
node.set_property (X_("type"), X_("capture"));
return node;

View file

@ -385,9 +385,9 @@ DelayLine::flush()
}
XMLNode&
DelayLine::state (bool full_state)
DelayLine::state ()
{
XMLNode& node (Processor::state (full_state));
XMLNode& node (Processor::state ());
node.set_property("type", "delay");
return node;
}

View file

@ -355,9 +355,9 @@ out:
}
XMLNode&
Delivery::state (bool full_state)
Delivery::state ()
{
XMLNode& node (IOProcessor::state (full_state));
XMLNode& node (IOProcessor::state ());
if (_role & Main) {
node.set_property("type", "main-outs");

View file

@ -126,9 +126,9 @@ DiskReader::set_name (string const & str)
}
XMLNode&
DiskReader::state (bool full)
DiskReader::state ()
{
XMLNode& node (DiskIOProcessor::state (full));
XMLNode& node (DiskIOProcessor::state ());
node.set_property(X_("type"), X_("diskreader"));
return node;
}

View file

@ -272,9 +272,9 @@ DiskWriter::set_align_style (AlignStyle a, bool force)
}
XMLNode&
DiskWriter::state (bool full)
DiskWriter::state ()
{
XMLNode& node (DiskIOProcessor::state (full));
XMLNode& node (DiskIOProcessor::state ());
node.set_property (X_("type"), X_("diskwriter"));
node.set_property (X_("record-safe"), (_record_safe ? X_("yes" : "no")));
return node;

View file

@ -77,20 +77,14 @@ InternalReturn::set_playback_offset (samplecnt_t cnt)
}
XMLNode&
InternalReturn::state (bool full)
InternalReturn::state ()
{
XMLNode& node (Return::state (full));
XMLNode& node (Return::state ());
/* override type */
node.set_property("type", "intreturn");
return node;
}
XMLNode&
InternalReturn::get_state()
{
return state (true);
}
bool
InternalReturn::can_support_io_configuration (const ChanCount& in, ChanCount& out)
{

View file

@ -297,9 +297,9 @@ InternalSend::feeds (boost::shared_ptr<Route> other) const
}
XMLNode&
InternalSend::state (bool full)
InternalSend::state ()
{
XMLNode& node (Send::state (full));
XMLNode& node (Send::state ());
/* this replaces any existing "type" property */
@ -313,12 +313,6 @@ InternalSend::state (bool full)
return node;
}
XMLNode&
InternalSend::get_state()
{
return state (true);
}
int
InternalSend::set_state (const XMLNode& node, int version)
{

View file

@ -498,11 +498,11 @@ IO::ensure_io (ChanCount count, bool clear, void* src)
XMLNode&
IO::get_state ()
{
return state (true);
return state ();
}
XMLNode&
IO::state (bool /*full_state*/)
IO::state ()
{
XMLNode* node = new XMLNode (state_node_name);
int n;

View file

@ -106,15 +106,15 @@ IOProcessor::set_output (boost::shared_ptr<IO> io)
}
XMLNode&
IOProcessor::state (bool full_state)
IOProcessor::state ()
{
XMLNode& node (Processor::state (full_state));
XMLNode& node (Processor::state ());
node.set_property ("own-input", _own_input);
if (_input) {
if (_own_input) {
XMLNode& i (_input->state (full_state));
XMLNode& i (_input->get_state ());
// i.name() = X_("output");
node.add_child_nocopy (i);
} else {
@ -126,7 +126,7 @@ IOProcessor::state (bool full_state)
if (_output) {
if (_own_output) {
XMLNode& o (_output->state (full_state));
XMLNode& o (_output->get_state ());
node.add_child_nocopy (o);
} else {
node.set_property ("output", _output->name ());

View file

@ -427,9 +427,9 @@ PeakMeter::set_type(MeterType t)
}
XMLNode&
PeakMeter::state (bool full_state)
PeakMeter::state ()
{
XMLNode& node (Processor::state (full_state));
XMLNode& node (Processor::state ());
node.set_property("type", "meter");
return node;
}

View file

@ -195,9 +195,9 @@ MidiTrack::set_state (const XMLNode& node, int version)
}
XMLNode&
MidiTrack::state(bool full_state)
MidiTrack::state(bool save_template)
{
XMLNode& root (Track::state(full_state));
XMLNode& root (Track::state (save_template));
XMLNode* freeze_node;
char buf[64];

View file

@ -218,9 +218,9 @@ MonitorProcessor::set_state (const XMLNode& node, int version)
}
XMLNode&
MonitorProcessor::state (bool full)
MonitorProcessor::state ()
{
XMLNode& node(Processor::state(full));
XMLNode& node(Processor::state ());
/* this replaces any existing "type" property */

View file

@ -166,11 +166,11 @@ Pannable::stop_touch (double when)
XMLNode&
Pannable::get_state ()
{
return state (true);
return state ();
}
XMLNode&
Pannable::state (bool /*full*/)
Pannable::state ()
{
XMLNode* node = new XMLNode (X_("Pannable"));

View file

@ -2358,15 +2358,9 @@ PluginInsert::automatic_can_support_io_configuration (ChanCount const & inx, Cha
XMLNode&
PluginInsert::get_state ()
PluginInsert::state ()
{
return state (true);
}
XMLNode&
PluginInsert::state (bool full)
{
XMLNode& node = Processor::state (full);
XMLNode& node = Processor::state ();
node.set_property("type", _plugins[0]->state_node_name());
node.set_property("unique-id", _plugins[0]->unique_id());
@ -2391,7 +2385,7 @@ PluginInsert::state (bool full)
node.add_child_nocopy (* _thru_map.state ("ThruMap"));
if (_sidechain) {
node.add_child_nocopy (_sidechain->state (full));
node.add_child_nocopy (_sidechain->get_state ());
}
_plugins[0]->set_insert_id(this->id());

View file

@ -159,15 +159,9 @@ PortInsert::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
}
XMLNode&
PortInsert::get_state(void)
PortInsert::state ()
{
return state (true);
}
XMLNode&
PortInsert::state (bool full)
{
XMLNode& node = IOProcessor::state(full);
XMLNode& node = IOProcessor::state ();
node.set_property ("type", "port");
node.set_property ("bitslot", _bitslot);
node.set_property ("latency", _measured_latency);

View file

@ -102,7 +102,7 @@ Processor::~Processor ()
XMLNode&
Processor::get_state (void)
{
return state (true);
return state ();
}
/* NODE STRUCTURE
@ -120,7 +120,7 @@ Processor::get_state (void)
*/
XMLNode&
Processor::state (bool full_state)
Processor::state ()
{
XMLNode* node = new XMLNode (state_node_name);
@ -132,7 +132,7 @@ Processor::state (bool full_state)
node->add_child_copy (*_extra_xml);
}
if (full_state) {
if (!skip_saving_automation) {
XMLNode& automation = Automatable::get_automation_xml_state();
if (!automation.children().empty() || !automation.properties().empty()) {
node->add_child_nocopy (automation);

View file

@ -64,15 +64,9 @@ Return::~Return ()
}
XMLNode&
Return::get_state(void)
Return::state()
{
return state (true);
}
XMLNode&
Return::state(bool full)
{
XMLNode& node = IOProcessor::state(full);
XMLNode& node = IOProcessor::state ();
node.set_property ("type", "return");
node.set_property ("bitslot", _bitslot);

View file

@ -2428,17 +2428,17 @@ Route::set_strict_io (const bool enable)
XMLNode&
Route::get_state()
{
return state(true);
return state (false);
}
XMLNode&
Route::get_template()
{
return state(false);
return state (true);
}
XMLNode&
Route::state(bool full_state)
Route::state (bool save_template)
{
if (!_session._template_state_dir.empty()) {
foreach_processor (sigc::bind (sigc::mem_fun (*this, &Route::set_plugin_state_dir), _session._template_state_dir));
@ -2469,14 +2469,14 @@ Route::state(bool full_state)
node->add_child_nocopy (_solo_isolate_control->get_state ());
node->add_child_nocopy (_solo_safe_control->get_state ());
node->add_child_nocopy (_input->state (full_state));
node->add_child_nocopy (_output->state (full_state));
node->add_child_nocopy (_input->get_state ());
node->add_child_nocopy (_output->get_state ());
node->add_child_nocopy (_mute_master->get_state ());
node->add_child_nocopy (_mute_control->get_state ());
node->add_child_nocopy (_phase_control->get_state ());
if (full_state) {
if (!skip_saving_automation) {
node->add_child_nocopy (Automatable::get_automation_xml_state ());
}
@ -2486,7 +2486,7 @@ Route::state(bool full_state)
}
if (_pannable) {
node->add_child_nocopy (_pannable->state (full_state));
node->add_child_nocopy (_pannable->get_state ());
}
{
@ -2495,7 +2495,7 @@ Route::state(bool full_state)
if (*i == _delayline) {
continue;
}
if (!full_state) {
if (save_template) {
/* template save: do not include internal sends functioning as
aux sends because the chance of the target ID
in the session where this template is used
@ -2513,7 +2513,7 @@ Route::state(bool full_state)
}
}
}
node->add_child_nocopy((*i)->state (full_state));
node->add_child_nocopy((*i)->get_state ());
}
}
@ -2908,7 +2908,7 @@ Route::get_processor_state ()
{
XMLNode* root = new XMLNode (X_("redirects"));
for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
root->add_child_nocopy ((*i)->state (true));
root->add_child_nocopy ((*i)->get_state ());
}
return *root;

View file

@ -260,15 +260,9 @@ Send::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, do
}
XMLNode&
Send::get_state(void)
Send::state ()
{
return state (true);
}
XMLNode&
Send::state (bool full)
{
XMLNode& node = Delivery::state(full);
XMLNode& node = Delivery::state ();
node.set_property ("type", "send");
@ -278,7 +272,7 @@ Send::state (bool full)
node.set_property ("selfdestruct", _remove_on_disconnect);
node.add_child_nocopy (_amp->state (full));
node.add_child_nocopy (_amp->get_state ());
return node;
}

View file

@ -325,7 +325,7 @@ get_id_sorted_playlists (const List& playlists, IDSortedList& id_sorted_playlist
} // anonymous namespace
void
SessionPlaylists::add_state (XMLNode* node, bool full_state)
SessionPlaylists::add_state (XMLNode* node, bool save_template, bool include_unused)
{
XMLNode* child = node->add_child ("Playlists");
@ -334,14 +334,18 @@ SessionPlaylists::add_state (XMLNode* node, bool full_state)
for (IDSortedList::iterator i = id_sorted_playlists.begin (); i != id_sorted_playlists.end (); ++i) {
if (!(*i)->hidden ()) {
if (full_state) {
child->add_child_nocopy ((*i)->get_state ());
} else {
if (save_template) {
child->add_child_nocopy ((*i)->get_template ());
} else {
child->add_child_nocopy ((*i)->get_state ());
}
}
}
if (!include_unused) {
return;
}
child = node->add_child ("UnusedPlaylists");
IDSortedList id_sorted_unused_playlists;
@ -351,10 +355,10 @@ SessionPlaylists::add_state (XMLNode* node, bool full_state)
i != id_sorted_unused_playlists.end (); ++i) {
if (!(*i)->hidden()) {
if (!(*i)->empty()) {
if (full_state) {
child->add_child_nocopy ((*i)->get_state());
} else {
if (save_template) {
child->add_child_nocopy ((*i)->get_template());
} else {
child->add_child_nocopy ((*i)->get_state());
}
}
}

View file

@ -808,7 +808,7 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot
mark_as_clean = false;
tree.set_root (&get_template());
} else {
tree.set_root (&state (true, fork_state));
tree.set_root (&state (false, fork_state));
}
if (snapshot_name.empty()) {
@ -1013,13 +1013,15 @@ Session::save_default_options ()
}
XMLNode&
Session::get_state()
Session::get_state ()
{
return state(true);
/* this is not directly called, but required by PBD::Stateful */
assert (0);
return state (false, NormalSave);
}
XMLNode&
Session::get_template()
Session::get_template ()
{
/* if we don't disable rec-enable, diskstreams
will believe they need to store their capture
@ -1028,7 +1030,7 @@ Session::get_template()
disable_record (false);
return state(false);
return state (true, NormalSave);
}
typedef std::set<boost::shared_ptr<Playlist> > PlaylistSet;
@ -1117,12 +1119,14 @@ struct route_id_compare {
} // anon namespace
XMLNode&
Session::state (bool full_state, snapshot_t snapshot_type)
Session::state (bool save_template, snapshot_t snapshot_type)
{
LocaleGuard lg;
XMLNode* node = new XMLNode("Session");
XMLNode* child;
PBD::Unwinder<bool> uw (Automatable::skip_saving_automation, save_template);
node->set_property("version", CURRENT_SESSION_FILE_VERSION);
child = node->add_child ("ProgramVersion");
@ -1133,7 +1137,7 @@ Session::state (bool full_state, snapshot_t snapshot_type)
/* store configuration settings */
if (full_state) {
if (!save_template) {
node->set_property ("name", _name);
node->set_property ("sample-rate", _base_sample_rate);
@ -1195,7 +1199,7 @@ Session::state (bool full_state, snapshot_t snapshot_type)
}
XMLNode& cfgxml (config.get_variables ());
if (!full_state) {
if (save_template) {
/* exclude search-paths from template */
cfgxml.remove_nodes_and_delete ("name", "audio-search-path");
cfgxml.remove_nodes_and_delete ("name", "midi-search-path");
@ -1207,7 +1211,7 @@ Session::state (bool full_state, snapshot_t snapshot_type)
child = node->add_child ("Sources");
if (full_state) {
if (!save_template) {
Glib::Threads::Mutex::Lock sl (source_lock);
for (SourceMap::iterator siter = sources.begin(); siter != sources.end(); ++siter) {
@ -1295,7 +1299,7 @@ Session::state (bool full_state, snapshot_t snapshot_type)
child = node->add_child ("Regions");
if (full_state) {
if (!save_template) {
Glib::Threads::Mutex::Lock rl (region_lock);
const RegionFactory::RegionMap& region_map (RegionFactory::all_regions());
for (RegionFactory::RegionMap::const_iterator i = region_map.begin(); i != region_map.end(); ++i) {
@ -1324,7 +1328,7 @@ Session::state (bool full_state, snapshot_t snapshot_type)
}
}
if (full_state) {
if (!save_template) {
node->add_child_nocopy (_selection->get_state());
@ -1384,16 +1388,16 @@ Session::state (bool full_state, snapshot_t snapshot_type)
for (RouteList::const_iterator i = xml_node_order.begin(); i != xml_node_order.end(); ++i) {
if (!(*i)->is_auditioner()) {
if (full_state) {
child->add_child_nocopy ((*i)->get_state());
} else {
if (save_template) {
child->add_child_nocopy ((*i)->get_template());
} else {
child->add_child_nocopy ((*i)->get_state());
}
}
}
}
playlists->add_state (node, full_state);
playlists->add_state (node, save_template, /* include unused*/ true);
child = node->add_child ("RouteGroups");
for (list<RouteGroup *>::iterator i = _route_groups.begin(); i != _route_groups.end(); ++i) {
@ -1402,18 +1406,18 @@ Session::state (bool full_state, snapshot_t snapshot_type)
if (_click_io) {
XMLNode* gain_child = node->add_child ("Click");
gain_child->add_child_nocopy (_click_io->state (full_state));
gain_child->add_child_nocopy (_click_gain->state (full_state));
gain_child->add_child_nocopy (_click_io->get_state ());
gain_child->add_child_nocopy (_click_gain->get_state ());
}
if (_ltc_input) {
XMLNode* ltc_input_child = node->add_child ("LTC-In");
ltc_input_child->add_child_nocopy (_ltc_input->state (full_state));
ltc_input_child->add_child_nocopy (_ltc_input->get_state ());
}
if (_ltc_input) {
XMLNode* ltc_output_child = node->add_child ("LTC-Out");
ltc_output_child->add_child_nocopy (_ltc_output->state (full_state));
ltc_output_child->add_child_nocopy (_ltc_output->get_state ());
}
node->add_child_nocopy (_speakers->get_state());

View file

@ -45,9 +45,9 @@ SideChain::~SideChain ()
}
XMLNode&
SideChain::state (bool full)
SideChain::state ()
{
XMLNode& node = IOProcessor::state (full);
XMLNode& node = IOProcessor::state ();
node.set_property ("type", "sidechain");
return node;
}

View file

@ -139,15 +139,9 @@ Track::input_changed ()
}
XMLNode&
Track::get_state ()
Track::state (bool save_template)
{
return state (true);
}
XMLNode&
Track::state (bool full)
{
XMLNode& root (Route::state (full));
XMLNode& root (Route::state (save_template));
if (_playlists[DataType::AUDIO]) {
root.set_property (X_("audio-playlist"), _playlists[DataType::AUDIO]->id().to_s());
@ -245,12 +239,6 @@ Track::set_state (const XMLNode& node, int version)
return 0;
}
XMLNode&
Track::get_template ()
{
return state (false);
}
Track::FreezeRecord::~FreezeRecord ()
{
for (vector<FreezeRecordProcessorInfo*>::iterator i = processor_info.begin(); i != processor_info.end(); ++i) {

View file

@ -59,7 +59,7 @@ UnknownProcessor::~UnknownProcessor () {
}
XMLNode &
UnknownProcessor::state (bool)
UnknownProcessor::state ()
{
return *(new XMLNode (_state));
}