diff options
author | David Robillard <d@drobilla.net> | 2010-02-23 20:25:53 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-02-23 20:25:53 +0000 |
commit | 650c6d5824222a8879df5c5ba9645c264ed3b84f (patch) | |
tree | 7cd5aace00cb23622f07727ae4f7963c03dd05c9 /libs | |
parent | 0c20d48e7d436725396baf362368f7ce61717151 (diff) |
Fix various code quality issues found by cppcheck (e.g. uninitialized members, larger than necessary variable scope, memory leaks, etc).
git-svn-id: svn://localhost/ardour2/branches/3.0@6710 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
44 files changed, 218 insertions, 162 deletions
diff --git a/libs/ardour/ardour/audio_library.h b/libs/ardour/ardour/audio_library.h index aada317dbd..2009ec39a7 100644 --- a/libs/ardour/ardour/audio_library.h +++ b/libs/ardour/ardour/audio_library.h @@ -35,7 +35,7 @@ class AudioLibrary void set_tags (std::string member, std::vector<std::string> tags); std::vector<std::string> get_tags (std::string member); - void search_members_and (std::vector<std::string>& results, const std::vector<std::string> tags); + void search_members_and (std::vector<std::string>& results, const std::vector<std::string>& tags); void save_changes(); diff --git a/libs/ardour/ardour/audio_unit.h b/libs/ardour/ardour/audio_unit.h index 9fbc188562..6d2b2410fd 100644 --- a/libs/ardour/ardour/audio_unit.h +++ b/libs/ardour/ardour/audio_unit.h @@ -96,7 +96,7 @@ class AUPlugin : public ARDOUR::Plugin int set_state(const XMLNode& node); bool save_preset (std::string name); - bool load_preset (const std::string preset_label); + bool load_preset (const std::string& preset_label); std::vector<std::string> get_presets (); std::string current_preset() const; diff --git a/libs/ardour/ardour/control_protocol_manager.h b/libs/ardour/ardour/control_protocol_manager.h index 6fedc95c6c..ad5bb3166e 100644 --- a/libs/ardour/ardour/control_protocol_manager.h +++ b/libs/ardour/ardour/control_protocol_manager.h @@ -45,8 +45,10 @@ struct ControlProtocolInfo { bool supports_feedback; XMLNode* state; - ControlProtocolInfo() : descriptor (0), protocol (0), state (0) {} - ~ControlProtocolInfo() { if (state) { delete state; } } + ControlProtocolInfo() : descriptor (0), protocol (0), requested(false), + mandatory(false), supports_feedback(false), state (0) + {} + ~ControlProtocolInfo() { delete state; } }; class ControlProtocolManager : public PBD::Stateful, public ARDOUR::SessionHandlePtr diff --git a/libs/ardour/ardour/delivery.h b/libs/ardour/ardour/delivery.h index a7ccd96a2d..b2bd283ef8 100644 --- a/libs/ardour/ardour/delivery.h +++ b/libs/ardour/ardour/delivery.h @@ -59,6 +59,7 @@ public: Delivery (Session& s, boost::shared_ptr<MuteMaster> mm, const std::string& name, Role); Delivery (Session&, boost::shared_ptr<MuteMaster> mm, const XMLNode&); + ~Delivery (); bool set_name (const std::string& name); std::string display_name() const; diff --git a/libs/ardour/ardour/export_graph_builder.h b/libs/ardour/ardour/export_graph_builder.h index 2f57aaf583..f98ffeb8eb 100644 --- a/libs/ardour/ardour/export_graph_builder.h +++ b/libs/ardour/ardour/export_graph_builder.h @@ -98,7 +98,7 @@ class ExportGraphBuilder class SFC { public: // This constructor so that this can be constructed like a Normalizer - SFC (ExportGraphBuilder &) {} + SFC (ExportGraphBuilder &) : data_width(0) {} FloatSinkPtr init (FileSpec const & new_config, nframes_t max_frames); void add_child (FileSpec const & new_config); bool operator== (FileSpec const & other_config) const; diff --git a/libs/ardour/ardour/export_handler.h b/libs/ardour/ardour/export_handler.h index 971c0c4940..05fbddecf5 100644 --- a/libs/ardour/ardour/export_handler.h +++ b/libs/ardour/ardour/export_handler.h @@ -140,7 +140,7 @@ class ExportHandler : public ExportElementFactory struct CDMarkerStatus { CDMarkerStatus (std::string out_file, TimespanPtr timespan, FormatPtr format, std::string filename) : - out (out_file.c_str()), timespan (timespan), format (format), filename (filename), + out (out_file.c_str()), timespan (timespan), format (format), filename (filename), marker(0), track_number (1), track_position (0), track_duration (0), track_start_frame (0), index_number (1), index_position (0) {} diff --git a/libs/ardour/ardour/lv2_plugin.h b/libs/ardour/ardour/lv2_plugin.h index 157d9144b8..d42c34a546 100644 --- a/libs/ardour/ardour/lv2_plugin.h +++ b/libs/ardour/ardour/lv2_plugin.h @@ -116,7 +116,7 @@ class LV2Plugin : public ARDOUR::Plugin XMLNode& get_state(); int set_state(const XMLNode& node, int version); bool save_preset(std::string uri); - bool load_preset(const std::string uri); + bool load_preset(const std::string& uri); virtual std::vector<Plugin::PresetRecord> get_presets(); bool has_editor() const; diff --git a/libs/ardour/ardour/plugin.h b/libs/ardour/ardour/plugin.h index 4770c43511..8731697906 100644 --- a/libs/ardour/ardour/plugin.h +++ b/libs/ardour/ardour/plugin.h @@ -127,7 +127,7 @@ class Plugin : public PBD::StatefulDestructible, public Latent virtual bool parameter_is_output(uint32_t) const = 0; virtual bool save_preset (std::string) = 0; - virtual bool load_preset (const std::string uri); + virtual bool load_preset (const std::string& uri); struct PresetRecord { PresetRecord(const std::string& u, const std::string& l) : uri(u), label(l) {} diff --git a/libs/ardour/ardour/rc_configuration.h b/libs/ardour/ardour/rc_configuration.h index ad31aac44e..35b22106dd 100644 --- a/libs/ardour/ardour/rc_configuration.h +++ b/libs/ardour/ardour/rc_configuration.h @@ -35,6 +35,7 @@ class RCConfiguration : public Configuration { public: RCConfiguration(); + ~RCConfiguration(); void map_parameters (boost::function<void (std::string)>&); int set_state (XMLNode const &, int version); diff --git a/libs/ardour/ardour/route_group.h b/libs/ardour/ardour/route_group.h index f3109a707d..7f3d25454a 100644 --- a/libs/ardour/ardour/route_group.h +++ b/libs/ardour/ardour/route_group.h @@ -93,19 +93,19 @@ class RouteGroup : public SessionObject int remove (boost::shared_ptr<Route>); void apply (void (Route::*func)(void *), void *src) { - for (RouteList::iterator i = routes->begin(); i != routes->end(); i++) { + for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) { ((*i).get()->*func)(src); } } template<class T> void apply (void (Route::*func)(T, void *), T val, void *src) { - for (RouteList::iterator i = routes->begin(); i != routes->end(); i++) { + for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) { ((*i).get()->*func)(val, src); } } template<class T> void foreach_route (T *obj, void (T::*func)(Route&)) { - for (RouteList::iterator i = routes->begin(); i != routes->end(); i++) { + for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) { (obj->*func)(**i); } } diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 9294d56fcc..02c5cc2391 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -411,7 +411,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi PBD::Signal0<void> route_group_removed; void foreach_route_group (boost::function<void(RouteGroup*)> f) { - for (std::list<RouteGroup *>::iterator i = _route_groups.begin(); i != _route_groups.end(); i++) { + for (std::list<RouteGroup *>::iterator i = _route_groups.begin(); i != _route_groups.end(); ++i) { f (*i); } } diff --git a/libs/ardour/ardour/session_event.h b/libs/ardour/ardour/session_event.h index 2ce2d5225a..882142c68d 100644 --- a/libs/ardour/ardour/session_event.h +++ b/libs/ardour/ardour/session_event.h @@ -120,15 +120,16 @@ private: }; class SessionEventManager { - public: - SessionEventManager () : pending_events (2048){} - virtual ~SessionEventManager() {} +public: + SessionEventManager () : pending_events (2048), + auto_loop_event(0), punch_out_event(0), punch_in_event(0) {} + virtual ~SessionEventManager() {} - virtual void queue_event (SessionEvent *ev) = 0; + virtual void queue_event (SessionEvent *ev) = 0; void clear_events (SessionEvent::Type type); - - protected: - RingBuffer<SessionEvent*> pending_events; + +protected: + RingBuffer<SessionEvent*> pending_events; typedef std::list<SessionEvent *> Events; Events events; Events immediate_events; @@ -138,8 +139,8 @@ class SessionEventManager { SessionEvent *auto_loop_event; SessionEvent *punch_out_event; - SessionEvent *punch_in_event; - + SessionEvent *punch_in_event; + void dump_events () const; void merge_event (SessionEvent*); void replace_event (SessionEvent::Type, nframes64_t action_frame, nframes64_t target = 0); @@ -150,8 +151,8 @@ class SessionEventManager { void add_event (nframes64_t action_frame, SessionEvent::Type type, nframes64_t target_frame = 0); void remove_event (nframes64_t frame, SessionEvent::Type type); - virtual void process_event(SessionEvent*) = 0; - virtual void set_next_event () = 0; + virtual void process_event(SessionEvent*) = 0; + virtual void set_next_event () = 0; }; } /* namespace */ diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index 4380662540..54c965ce67 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -438,19 +438,14 @@ namespace ARDOUR { MeterPointChange = 0x1 }; - RouteProcessorChange () { - type = GeneralChange; - } + RouteProcessorChange () : type (GeneralChange), meter_visibly_changed (true) + {} - RouteProcessorChange (Type t) { - type = t; - meter_visibly_changed = true; - } + RouteProcessorChange (Type t) : type (t), meter_visibly_changed (true) + {} - RouteProcessorChange (Type t, bool m) { - type = t; - meter_visibly_changed = m; - } + RouteProcessorChange (Type t, bool m) : type (t), meter_visibly_changed (m) + {} /** type of change; "GeneralChange" means anything could have changed */ Type type; diff --git a/libs/ardour/ardour/vst_plugin.h b/libs/ardour/ardour/vst_plugin.h index 753d94294f..513f24d493 100644 --- a/libs/ardour/ardour/vst_plugin.h +++ b/libs/ardour/ardour/vst_plugin.h @@ -79,7 +79,7 @@ class VSTPlugin : public ARDOUR::Plugin bool parameter_is_input(uint32_t i) const { return true; } bool parameter_is_output(uint32_t i) const { return false; } - bool load_preset (const std::string preset_label ); + bool load_preset (const std::string& preset_label); bool save_preset (std::string name); bool has_editor () const; diff --git a/libs/ardour/audio_buffer.cc b/libs/ardour/audio_buffer.cc index a57891a27d..8b2d5c744f 100644 --- a/libs/ardour/audio_buffer.cc +++ b/libs/ardour/audio_buffer.cc @@ -58,9 +58,7 @@ AudioBuffer::resize (size_t size) return; } - if (_data) { - free (_data); - } + free (_data); _capacity = size; _size = size; diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index 0ec6533aa4..f7a1240bdd 100644 --- a/libs/ardour/audio_diskstream.cc +++ b/libs/ardour/audio_diskstream.cc @@ -139,6 +139,8 @@ AudioDiskstream::~AudioDiskstream () } channels.flush (); + + delete deprecated_io_node; } void @@ -905,7 +907,6 @@ AudioDiskstream::read (Sample* buf, Sample* mixdown_buffer, float* gain_buffer, bool reloop = false; nframes_t loop_end = 0; nframes_t loop_start = 0; - nframes_t loop_length = 0; nframes_t offset = 0; Location *loc = 0; @@ -913,6 +914,8 @@ AudioDiskstream::read (Sample* buf, Sample* mixdown_buffer, float* gain_buffer, if (!reversed) { + nframes_t loop_length = 0; + /* Make the use of a Location atomic for this read operation. Note: Locations don't get deleted, so all we care about @@ -2258,11 +2261,10 @@ AudioDiskstream::set_non_layered (bool yn) int AudioDiskstream::set_destructive (bool yn) { - bool bounce_ignored; - if (yn != destructive()) { if (yn) { + bool bounce_ignored; /* requestor should already have checked this and bounced if necessary and desired */ diff --git a/libs/ardour/audio_library.cc b/libs/ardour/audio_library.cc index 26f225273f..662b8cb33e 100644 --- a/libs/ardour/audio_library.cc +++ b/libs/ardour/audio_library.cc @@ -116,7 +116,7 @@ AudioLibrary::get_tags (string member) } void -AudioLibrary::search_members_and (vector<string>& members, const vector<string> tags) +AudioLibrary::search_members_and (vector<string>& members, const vector<string>& tags) { lrdf_statement **head; lrdf_statement* pattern = 0; diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc index 6e8b35a072..65b05b7c92 100644 --- a/libs/ardour/audio_playlist.cc +++ b/libs/ardour/audio_playlist.cc @@ -365,9 +365,6 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh) } for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) { - - nframes_t xfade_length; - other = boost::dynamic_pointer_cast<AudioRegion> (*i); if (other == region) { @@ -397,6 +394,7 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh) touched_regions = 0; try { + nframes_t xfade_length; switch (c) { case OverlapNone: break; diff --git a/libs/ardour/audio_region_importer.cc b/libs/ardour/audio_region_importer.cc index 289af0b4d8..ebe4ae5270 100644 --- a/libs/ardour/audio_region_importer.cc +++ b/libs/ardour/audio_region_importer.cc @@ -266,7 +266,7 @@ AudioRegionImporter::parse_source_xml () string source_id = prop->value(); // Get source - for (XMLNodeList::const_iterator it = sources.begin(); it != sources.end(); it++) { + for (XMLNodeList::const_iterator it = sources.begin(); it != sources.end(); ++it) { prop = (*it)->property ("id"); if (prop && !source_id.compare (prop->value())) { source_path = source_dir; diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc index a2cf0e07e9..ca5362004c 100644 --- a/libs/ardour/audio_unit.cc +++ b/libs/ardour/audio_unit.cc @@ -322,9 +322,7 @@ AUPlugin::~AUPlugin () unit->Uninitialize (); } - if (buffers) { - free (buffers); - } + free (buffers); } @@ -1090,7 +1088,7 @@ AUPlugin::set_state(const XMLNode& node) } bool -AUPlugin::load_preset (const string preset_label) +AUPlugin::load_preset (const string& preset_label) { #ifdef AU_STATE_SUPPORT bool ret = false; @@ -1837,15 +1835,13 @@ AUPluginInfo::load_cached_info () if (gchild->name() == X_("io")) { - int in; - int out; const XMLProperty* iprop; const XMLProperty* oprop; if (((iprop = gchild->property (X_("in"))) != 0) && ((oprop = gchild->property (X_("out"))) != 0)) { - in = atoi (iprop->value()); - out = atoi (iprop->value()); + const int in = atoi (iprop->value()); + const int out = atoi (iprop->value()); cinfo.io_configs.push_back (pair<int,int> (in, out)); } diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index 2035265c46..3766f60b63 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -153,7 +153,7 @@ ardour_jack_error (const char* msg) int AudioEngine::start () { - GET_PRIVATE_JACK_POINTER_RET (_jack, -1); + GET_PRIVATE_JACK_POINTER_RET (_jack, -1); if (!_running) { @@ -216,7 +216,7 @@ AudioEngine::start () int AudioEngine::stop (bool forever) { - GET_PRIVATE_JACK_POINTER_RET (_jack, -1); + GET_PRIVATE_JACK_POINTER_RET (_jack, -1); if (_priv_jack) { if (forever) { @@ -238,7 +238,7 @@ AudioEngine::get_sync_offset (nframes_t& offset) const #ifdef HAVE_JACK_VIDEO_SUPPORT - GET_PRIVATE_JACK_POINTER_RET (_jack, false); + GET_PRIVATE_JACK_POINTER_RET (_jack, false); jack_position_t pos; @@ -619,7 +619,7 @@ AudioEngine::remove_session () void AudioEngine::port_registration_failure (const std::string& portname) { - GET_PRIVATE_JACK_POINTER (_jack); + GET_PRIVATE_JACK_POINTER (_jack); string full_portname = jack_client_name; full_portname += ':'; full_portname += portname; @@ -797,7 +797,7 @@ AudioEngine::disconnect (const string& source, const string& destination) int AudioEngine::disconnect (Port& port) { - GET_PRIVATE_JACK_POINTER_RET (_jack,-1); + GET_PRIVATE_JACK_POINTER_RET (_jack,-1); if (!_running) { if (!_has_run) { @@ -814,7 +814,7 @@ AudioEngine::disconnect (Port& port) ARDOUR::nframes_t AudioEngine::frame_rate () const { - GET_PRIVATE_JACK_POINTER_RET (_jack,0); + GET_PRIVATE_JACK_POINTER_RET (_jack,0); if (_frame_rate == 0) { return (_frame_rate = jack_get_sample_rate (_priv_jack)); } else { @@ -832,7 +832,7 @@ AudioEngine::raw_buffer_size (DataType t) ARDOUR::nframes_t AudioEngine::frames_per_cycle () const { - GET_PRIVATE_JACK_POINTER_RET (_jack,0); + GET_PRIVATE_JACK_POINTER_RET (_jack,0); if (_buffer_size == 0) { return (_buffer_size = jack_get_buffer_size (_jack)); } else { @@ -893,7 +893,7 @@ AudioEngine::get_port_by_name_locked (const string& portname) const char ** AudioEngine::get_ports (const string& port_name_pattern, const string& type_name_pattern, uint32_t flags) { - GET_PRIVATE_JACK_POINTER_RET (_jack,0); + GET_PRIVATE_JACK_POINTER_RET (_jack,0); if (!_running) { if (!_has_run) { fatal << _("get_ports called before engine was started") << endmsg; @@ -941,7 +941,7 @@ AudioEngine::died () bool AudioEngine::can_request_hardware_monitoring () { - GET_PRIVATE_JACK_POINTER_RET (_jack,false); + GET_PRIVATE_JACK_POINTER_RET (_jack,false); const char ** ports; if ((ports = jack_get_ports (_priv_jack, NULL, JACK_DEFAULT_AUDIO_TYPE, JackPortCanMonitor)) == 0) { @@ -957,7 +957,7 @@ AudioEngine::can_request_hardware_monitoring () uint32_t AudioEngine::n_physical_outputs (DataType type) const { - GET_PRIVATE_JACK_POINTER_RET (_jack,0); + GET_PRIVATE_JACK_POINTER_RET (_jack,0); const char ** ports; uint32_t i = 0; @@ -974,7 +974,7 @@ AudioEngine::n_physical_outputs (DataType type) const uint32_t AudioEngine::n_physical_inputs (DataType type) const { - GET_PRIVATE_JACK_POINTER_RET (_jack,0); + GET_PRIVATE_JACK_POINTER_RET (_jack,0); const char ** ports; uint32_t i = 0; @@ -991,17 +991,15 @@ AudioEngine::n_physical_inputs (DataType type) const void AudioEngine::get_physical_inputs (DataType type, vector<string>& ins) { - GET_PRIVATE_JACK_POINTER (_jack); + GET_PRIVATE_JACK_POINTER (_jack); const char ** ports; - uint32_t i = 0; - if ((ports = jack_get_ports (_priv_jack, NULL, type.to_jack_type(), JackPortIsPhysical|JackPortIsOutput)) == 0) { return; } if (ports) { - for (i = 0; ports[i]; ++i) { + for (uint32_t i = 0; ports[i]; ++i) { ins.push_back (ports[i]); } free (ports); @@ -1011,7 +1009,7 @@ AudioEngine::get_physical_inputs (DataType type, vector<string>& ins) void AudioEngine::get_physical_outputs (DataType type, vector<string>& outs) { - GET_PRIVATE_JACK_POINTER (_jack); + GET_PRIVATE_JACK_POINTER (_jack); const char ** ports; uint32_t i = 0; @@ -1028,7 +1026,7 @@ AudioEngine::get_physical_outputs (DataType type, vector<string>& outs) string AudioEngine::get_nth_physical (DataType type, uint32_t n, int flag) { - GET_PRIVATE_JACK_POINTER_RET (_jack,""); + GET_PRIVATE_JACK_POINTER_RET (_jack,""); const char ** ports; uint32_t i; string ret; @@ -1045,7 +1043,7 @@ AudioEngine::get_nth_physical (DataType type, uint32_t n, int flag) ret = ports[i]; } - free ((char *) ports); + free ((const char **) ports); return ret; } @@ -1059,21 +1057,21 @@ AudioEngine::update_total_latency (const Port& port) void AudioEngine::transport_stop () { - GET_PRIVATE_JACK_POINTER (_jack); + GET_PRIVATE_JACK_POINTER (_jack); jack_transport_stop (_priv_jack); } void AudioEngine::transport_start () { - GET_PRIVATE_JACK_POINTER (_jack); + GET_PRIVATE_JACK_POINTER (_jack); jack_transport_start (_priv_jack); } void AudioEngine::transport_locate (nframes_t where) { - GET_PRIVATE_JACK_POINTER (_jack); + GET_PRIVATE_JACK_POINTER (_jack); // cerr << "tell JACK to locate to " << where << endl; jack_transport_locate (_priv_jack, where); } @@ -1081,7 +1079,7 @@ AudioEngine::transport_locate (nframes_t where) AudioEngine::TransportState AudioEngine::transport_state () { - GET_PRIVATE_JACK_POINTER_RET (_jack, ((TransportState) JackTransportStopped)); + GET_PRIVATE_JACK_POINTER_RET (_jack, ((TransportState) JackTransportStopped)); jack_position_t pos; return (TransportState) jack_transport_query (_priv_jack, &pos); } @@ -1089,7 +1087,7 @@ AudioEngine::transport_state () int AudioEngine::reset_timebase () { - GET_PRIVATE_JACK_POINTER_RET (_jack, -1); + GET_PRIVATE_JACK_POINTER_RET (_jack, -1); if (_session) { if (_session->config.get_jack_time_master()) { return jack_set_timebase_callback (_priv_jack, 0, _jack_timebase_callback, this); @@ -1103,7 +1101,7 @@ AudioEngine::reset_timebase () int AudioEngine::freewheel (bool onoff) { - GET_PRIVATE_JACK_POINTER_RET (_jack, -1); + GET_PRIVATE_JACK_POINTER_RET (_jack, -1); if (onoff != _freewheeling) { @@ -1155,7 +1153,7 @@ AudioEngine::connect_to_jack (string client_name) return -1; } - GET_PRIVATE_JACK_POINTER_RET (_jack, -1); + GET_PRIVATE_JACK_POINTER_RET (_jack, -1); if (status & JackNameNotUnique) { jack_client_name = jack_get_client_name (_priv_jack); @@ -1167,7 +1165,7 @@ AudioEngine::connect_to_jack (string client_name) int AudioEngine::disconnect_from_jack () { - GET_PRIVATE_JACK_POINTER_RET (_jack, 0); + GET_PRIVATE_JACK_POINTER_RET (_jack, 0); if (_running) { stop_metering_thread (); @@ -1222,7 +1220,7 @@ AudioEngine::reconnect_to_jack () return -1; } - GET_PRIVATE_JACK_POINTER_RET (_jack,-1); + GET_PRIVATE_JACK_POINTER_RET (_jack,-1); if (_session) { _session->reset_jack_connection (_priv_jack); @@ -1274,7 +1272,7 @@ AudioEngine::reconnect_to_jack () int AudioEngine::request_buffer_size (nframes_t nframes) { - GET_PRIVATE_JACK_POINTER_RET (_jack, -1); + GET_PRIVATE_JACK_POINTER_RET (_jack, -1); if (nframes == jack_get_buffer_size (_priv_jack)) { return 0; @@ -1287,7 +1285,7 @@ void AudioEngine::update_total_latencies () { #ifdef HAVE_JACK_RECOMPUTE_LATENCIES - GET_PRIVATE_JACK_POINTER (_jack); + GET_PRIVATE_JACK_POINTER (_jack); jack_recompute_total_latencies (_priv_jack); #endif } @@ -1332,6 +1330,6 @@ AudioEngine::make_port_name_non_relative (string portname) bool AudioEngine::is_realtime () const { - GET_PRIVATE_JACK_POINTER_RET (_jack,false); + GET_PRIVATE_JACK_POINTER_RET (_jack,false); return jack_is_realtime (_priv_jack); } diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index 841dec1887..2657ba94ad 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -612,11 +612,8 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t int AudioSource::build_peaks_from_scratch () { - framepos_t current_frame; - framecnt_t cnt; Sample* buf = 0; - framecnt_t frames_read; - framecnt_t frames_to_read; + const framecnt_t bufsize = 65536; // 256kB per disk read for mono data is about ideal int ret = -1; @@ -630,14 +627,16 @@ AudioSource::build_peaks_from_scratch () goto out; } - current_frame = 0; - cnt = _length; + framepos_t current_frame = 0; + framecnt_t cnt = _length; + _peaks_built = false; buf = new Sample[bufsize]; while (cnt) { - frames_to_read = min (bufsize, cnt); + framecnt_t frames_to_read = min (bufsize, cnt); + framecnt_t frames_read; if ((frames_read = read_unlocked (buf, current_frame, frames_to_read)) != frames_to_read) { error << string_compose(_("%1: could not write read raw data for peak computation (%2)"), _name, strerror (errno)) << endmsg; diff --git a/libs/ardour/auditioner.cc b/libs/ardour/auditioner.cc index 82ec91cafd..c88eeedf1a 100644 --- a/libs/ardour/auditioner.cc +++ b/libs/ardour/auditioner.cc @@ -202,9 +202,8 @@ Auditioner::play_audition (nframes_t nframes) void Auditioner::output_changed (IOChange change, void* /*src*/) { - string phys; - if (change & ConnectionsChanged) { + string phys; vector<string> connections; if (_output->nth (0)->get_connections (connections)) { phys = _session.engine().get_nth_physical_output (DataType::AUDIO, 0); diff --git a/libs/ardour/delivery.cc b/libs/ardour/delivery.cc index 902dbc9705..5777269416 100644 --- a/libs/ardour/delivery.cc +++ b/libs/ardour/delivery.cc @@ -150,6 +150,11 @@ Delivery::Delivery (Session& s, boost::shared_ptr<IO> out, boost::shared_ptr<Mut CycleStart.connect_same_thread (*this, boost::bind (&Delivery::cycle_start, this, _1)); } +Delivery::~Delivery() +{ + delete _output_buffers; +} + std::string Delivery::display_name () const { diff --git a/libs/ardour/export_handler.cc b/libs/ardour/export_handler.cc index a9335add37..cf6fced74c 100644 --- a/libs/ardour/export_handler.cc +++ b/libs/ardour/export_handler.cc @@ -104,7 +104,9 @@ ExportHandler::ExportHandler (Session & session) , graph_builder (new ExportGraphBuilder (session)) , export_status (session.get_export_status ()) , realtime (false) - + , normalizing (false) + , cue_tracknum (0) + , cue_indexnum (0) { } diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc index c980c49c02..d621afe297 100644 --- a/libs/ardour/import.cc +++ b/libs/ardour/import.cc @@ -125,7 +125,7 @@ open_importable_source (const string& path, nframes_t samplerate, ARDOUR::SrcQua } static std::string -get_non_existent_filename (DataType type, const bool allow_replacing, const std::string destdir, const std::string& basename, uint channel, uint channels) +get_non_existent_filename (DataType type, const bool allow_replacing, const std::string& destdir, const std::string& basename, uint channel, uint channels) { char buf[PATH_MAX+1]; bool goodfile = false; diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index 48bab25546..b34614e1dd 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -674,12 +674,12 @@ IO::find_possible_bundle (const string &desired_name) // see if it's a stereo connection e.g. "in 3+4" if (last_non_digit_pos > 1 && desired_name[last_non_digit_pos] == '+') { - int left_bundle_number = 0; string::size_type left_last_non_digit_pos; left_last_non_digit_pos = desired_name.find_last_not_of(digits, last_non_digit_pos-1); if (left_last_non_digit_pos != string::npos) { + int left_bundle_number = 0; stringstream s; s << desired_name.substr(left_last_non_digit_pos, last_non_digit_pos-1); s >> left_bundle_number; diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc index 7e3330ecd9..4861718d85 100644 --- a/libs/ardour/location.cc +++ b/libs/ardour/location.cc @@ -676,15 +676,12 @@ Locations::get_state () int Locations::set_state (const XMLNode& node, int /*version*/) { - XMLNodeList nlist; - XMLNodeConstIterator niter; - if (node.name() != "Locations") { error << _("incorrect XML mode passed to Locations::set_state") << endmsg; return -1; } - nlist = node.children(); + XMLNodeList nlist = node.children(); locations.clear (); current_location = 0; @@ -692,6 +689,7 @@ Locations::set_state (const XMLNode& node, int /*version*/) { Glib::Mutex::Lock lm (lock); + XMLNodeConstIterator niter; for (niter = nlist.begin(); niter != nlist.end(); ++niter) { try { @@ -910,7 +908,7 @@ Location * Locations::get_location_by_id(PBD::ID id) { LocationList::iterator it; - for (it = locations.begin(); it != locations.end(); it++) + for (it = locations.begin(); it != locations.end(); ++it) if (id == (*it)->id()) return *it; diff --git a/libs/ardour/location_importer.cc b/libs/ardour/location_importer.cc index 655a8f1a84..8d6af300ca 100644 --- a/libs/ardour/location_importer.cc +++ b/libs/ardour/location_importer.cc @@ -46,7 +46,7 @@ LocationImportHandler::LocationImportHandler (XMLTree const & source, Session & // Construct importable locations XMLNodeList const & locations = location_node->children(); - for (XMLNodeList::const_iterator it = locations.begin(); it != locations.end(); it++) { + for (XMLNodeList::const_iterator it = locations.begin(); it != locations.end(); ++it) { try { elements.push_back (ElementPtr ( new LocationImporter (source, session, *this, **it))); } catch (failed_constructor err) { diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index 13cc78c5c0..b48395b40f 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -319,7 +319,7 @@ LV2Plugin::get_presets() } bool -LV2Plugin::load_preset(const string uri) +LV2Plugin::load_preset(const string& uri) { const string query = string( "PREFIX lv2p: <http://lv2plug.in/ns/dev/presets#>\n" diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index 4f7d6364b0..ccfaeaa5cd 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -703,10 +703,12 @@ MidiDiskstream::read (nframes_t& start, nframes_t dur, bool reversed) bool reloop = false; nframes_t loop_end = 0; nframes_t loop_start = 0; - nframes_t loop_length = 0; Location *loc = 0; if (!reversed) { + + nframes_t loop_length = 0; + /* Make the use of a Location atomic for this read operation. Note: Locations don't get deleted, so all we care about @@ -914,11 +916,9 @@ out: void MidiDiskstream::transport_stopped (struct tm& /*when*/, time_t /*twhen*/, bool abort_capture) { - uint32_t buffer_position; bool more_work = true; int err = 0; boost::shared_ptr<MidiRegion> region; - nframes_t total_capture; MidiRegion::SourceList srcs; MidiRegion::SourceList::iterator src; vector<CaptureInfo*>::iterator ci; @@ -965,7 +965,8 @@ MidiDiskstream::transport_stopped (struct tm& /*when*/, time_t /*twhen*/, bool a assert(_write_source); - for (total_capture = 0, ci = capture_info.begin(); ci != capture_info.end(); ++ci) { + nframes_t total_capture = 0; + for (ci = capture_info.begin(); ci != capture_info.end(); ++ci) { total_capture += (*ci)->frames; } @@ -993,7 +994,7 @@ MidiDiskstream::transport_stopped (struct tm& /*when*/, time_t /*twhen*/, bool a plist.add (Properties::start, 0); plist.add (Properties::length, total_capture); plist.add (Properties::layer, 0); - + boost::shared_ptr<Region> rx (RegionFactory::create (srcs, plist)); region = boost::dynamic_pointer_cast<MidiRegion> (rx); @@ -1013,6 +1014,7 @@ MidiDiskstream::transport_stopped (struct tm& /*when*/, time_t /*twhen*/, bool a XMLNode &before = _playlist->get_state(); _playlist->freeze (); + uint32_t buffer_position = 0; for (buffer_position = 0, ci = capture_info.begin(); ci != capture_info.end(); ++ci) { string region_name; @@ -1248,7 +1250,6 @@ MidiDiskstream::set_state (const XMLNode& node, int /*version*/) const XMLProperty* prop; XMLNodeList nlist = node.children(); XMLNodeIterator niter; - uint32_t nchans = 1; XMLNode* capture_pending_node = 0; LocaleGuard lg (X_("POSIX")); @@ -1296,10 +1297,6 @@ MidiDiskstream::set_state (const XMLNode& node, int /*version*/) set_channel_mode(channel_mode, channel_mask); - if ((prop = node.property ("channels")) != 0) { - nchans = atoi (prop->value().c_str()); - } - if ((prop = node.property ("playlist")) == 0) { return -1; } diff --git a/libs/ardour/midi_playlist.cc b/libs/ardour/midi_playlist.cc index 8c94bb1a7f..048a54da93 100644 --- a/libs/ardour/midi_playlist.cc +++ b/libs/ardour/midi_playlist.cc @@ -55,16 +55,19 @@ MidiPlaylist::MidiPlaylist (Session& session, const XMLNode& node, bool hidden) MidiPlaylist::MidiPlaylist (Session& session, string name, bool hidden) : Playlist (session, name, DataType::MIDI, hidden) + , _note_mode(Sustained) { } MidiPlaylist::MidiPlaylist (boost::shared_ptr<const MidiPlaylist> other, string name, bool hidden) : Playlist (other, name, hidden) + , _note_mode(other->_note_mode) { } MidiPlaylist::MidiPlaylist (boost::shared_ptr<const MidiPlaylist> other, nframes_t start, nframes_t dur, string name, bool hidden) - : Playlist (other, start, dur, name, hidden) + : Playlist (other, start, dur, name, hidden) + , _note_mode(other->_note_mode) { /* this constructor does NOT notify others (session) */ } diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc index aab7431cc1..af66f2f40c 100644 --- a/libs/ardour/midi_track.cc +++ b/libs/ardour/midi_track.cc @@ -621,9 +621,8 @@ MidiTrack::MidiControl::set_value(float val) } assert(val <= _list->parameter().max()); - size_t size = 3; - if ( ! automation_playback()) { + size_t size = 3; uint8_t ev[3] = { _list->parameter().channel(), int(val), 0 }; switch(_list->parameter().type()) { case MidiCCAutomation: diff --git a/libs/ardour/onset_detector.cc b/libs/ardour/onset_detector.cc index 85917041b6..59fd8d10df 100644 --- a/libs/ardour/onset_detector.cc +++ b/libs/ardour/onset_detector.cc @@ -12,6 +12,7 @@ string OnsetDetector::_op_id = X_("libardourvampplugins:aubioonset:2"); OnsetDetector::OnsetDetector (float sr) : AudioAnalyser (sr, X_("libardourvampplugins:aubioonset")) + , current_results (0) { /* update the op_id */ diff --git a/libs/ardour/panner.cc b/libs/ardour/panner.cc index d3ce72679a..3f4aee0cf7 100644 --- a/libs/ardour/panner.cc +++ b/libs/ardour/panner.cc @@ -228,6 +228,10 @@ StreamPanner::distribute_automated (AudioBuffer& src, BufferSet& obufs, BaseStereoPanner::BaseStereoPanner (Panner& p, Evoral::Parameter param) : StreamPanner (p, param) + , left (0.5) + , right (0.5) + , left_interp (left) + , right_interp (right) { } @@ -546,11 +550,10 @@ int EqualPowerStereoPanner::set_state (const XMLNode& node, int version) { const XMLProperty* prop; - float pos; LocaleGuard lg (X_("POSIX")); if ((prop = node.property (X_("x")))) { - pos = atof (prop->value().c_str()); + const float pos = atof (prop->value().c_str()); set_position (pos, true); } diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 815970a276..e128489820 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -161,7 +161,7 @@ Playlist::Playlist (boost::shared_ptr<const Playlist> other, framepos_t start, f in_set_state++; - for (RegionList::const_iterator i = other->regions.begin(); i != other->regions.end(); i++) { + for (RegionList::const_iterator i = other->regions.begin(); i != other->regions.end(); ++i) { boost::shared_ptr<Region> region; boost::shared_ptr<Region> new_region; @@ -1112,13 +1112,12 @@ int Playlist::paste (boost::shared_ptr<Playlist> other, framepos_t position, float times) { times = fabs (times); - framecnt_t old_length; { RegionLock rl1 (this); RegionLock rl2 (other.get()); - old_length = _get_maximum_extent(); + framecnt_t old_length = _get_maximum_extent(); int itimes = (int) floor (times); framepos_t pos = position; @@ -1611,7 +1610,6 @@ Playlist::regions_to_read (framepos_t start, framepos_t end) RegionList covering; set<framepos_t> to_check; set<boost::shared_ptr<Region> > unique; - RegionList here; to_check.insert (start); to_check.insert (end); @@ -1662,6 +1660,7 @@ Playlist::regions_to_read (framepos_t start, framepos_t end) } else { + RegionList here; for (set<framepos_t>::iterator t = to_check.begin(); t != to_check.end(); ++t) { here.clear (); @@ -2316,7 +2315,6 @@ Playlist::move_region_to_layer (layer_t target_layer, boost::shared_ptr<Region> RegionList::iterator i; typedef pair<boost::shared_ptr<Region>,layer_t> LayerInfo; list<LayerInfo> layerinfo; - layer_t dest; { RegionLock rlock (const_cast<Playlist *> (this)); @@ -2327,6 +2325,8 @@ Playlist::move_region_to_layer (layer_t target_layer, boost::shared_ptr<Region> continue; } + layer_t dest; + if (dir > 0) { /* region is moving up, move all regions on intermediate layers @@ -2387,7 +2387,6 @@ void Playlist::nudge_after (framepos_t start, framecnt_t distance, bool forwards) { RegionList::iterator i; - framepos_t new_pos; bool moved = false; _nudging = true; @@ -2399,6 +2398,8 @@ Playlist::nudge_after (framepos_t start, framecnt_t distance, bool forwards) if ((*i)->position() >= start) { + framepos_t new_pos; + if (forwards) { if ((*i)->last_frame() > max_frames - distance) { @@ -2498,7 +2499,6 @@ void Playlist::shuffle (boost::shared_ptr<Region> region, int dir) { bool moved = false; - framepos_t new_pos; if (region->locked()) { return; @@ -2525,6 +2525,8 @@ Playlist::shuffle (boost::shared_ptr<Region> region, int dir) break; } + framepos_t new_pos; + if ((*next)->position() != region->last_frame() + 1) { /* they didn't used to touch, so after shuffle, just have them swap positions. @@ -2566,6 +2568,7 @@ Playlist::shuffle (boost::shared_ptr<Region> region, int dir) break; } + framepos_t new_pos; if (region->position() != (*prev)->last_frame() + 1) { /* they didn't used to touch, so after shuffle, just have them swap positions. diff --git a/libs/ardour/plugin.cc b/libs/ardour/plugin.cc index 4971c57deb..9bbe21aabf 100644 --- a/libs/ardour/plugin.cc +++ b/libs/ardour/plugin.cc @@ -142,7 +142,7 @@ Plugin::get_presets() } bool -Plugin::load_preset(const string preset_uri) +Plugin::load_preset(const string& preset_uri) { lrdf_defaults* defs = lrdf_get_setting_values(preset_uri.c_str()); diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc index b0d40f6124..f4d638e3bc 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -142,6 +142,13 @@ PluginManager::PluginManager () BootMessage (_("Discovering Plugins")); } + +PluginManager::~PluginManager() +{ + delete _lv2_world; +} + + void PluginManager::refresh () { @@ -302,13 +309,12 @@ PluginManager::add_lrdf_data (const string &path) PathScanner scanner; vector<string *>* rdf_files; vector<string *>::iterator x; - string uri; rdf_files = scanner (path, rdf_filter, 0, true, true); if (rdf_files) { for (x = rdf_files->begin(); x != rdf_files->end (); ++x) { - uri = "file://" + **x; + const string uri(string("file://") + **x); if (lrdf_read_file(uri.c_str())) { warning << "Could not parse rdf file: " << uri << endmsg; diff --git a/libs/ardour/processor.cc b/libs/ardour/processor.cc index 65517be4b1..712ca927e5 100644 --- a/libs/ardour/processor.cc +++ b/libs/ardour/processor.cc @@ -111,7 +111,6 @@ XMLNode& Processor::state (bool full_state) { XMLNode* node = new XMLNode (state_node_name); - stringstream sstr; char buf[64]; id().print (buf, sizeof (buf)); @@ -129,6 +128,7 @@ Processor::state (bool full_state) || !automation.properties().empty() || !_visible_controls.empty()) { + stringstream sstr; for (set<Evoral::Parameter>::iterator x = _visible_controls.begin(); x != _visible_controls.end(); ++x) { if (x != _visible_controls.begin()) { diff --git a/libs/ardour/rc_configuration.cc b/libs/ardour/rc_configuration.cc index a68d0d3b94..f1b7748f73 100644 --- a/libs/ardour/rc_configuration.cc +++ b/libs/ardour/rc_configuration.cc @@ -65,6 +65,12 @@ RCConfiguration::RCConfiguration () { } + +RCConfiguration::~RCConfiguration () +{ + delete _control_protocol_state; +} + int RCConfiguration::load_state () { @@ -78,7 +84,6 @@ RCConfiguration::load_state () if (find_file_in_search_path (ardour_search_path() + system_config_search_path(), "ardour_system.rc", system_rc_file) ) { - XMLTree tree; found = true; string rcfile = system_rc_file.to_string(); @@ -92,6 +97,7 @@ RCConfiguration::load_state () if (statbuf.st_size != 0) { info << string_compose (_("Loading system configuration file %1"), rcfile) << endl; + XMLTree tree; if (!tree.read (rcfile.c_str())) { error << string_compose(_("Ardour: cannot read system configuration file \"%1\""), rcfile) << endmsg; return -1; @@ -113,7 +119,6 @@ RCConfiguration::load_state () if (find_file_in_search_path (ardour_search_path() + user_config_directory(), "ardour.rc", user_rc_file)) { - XMLTree tree; found = true; string rcfile = user_rc_file.to_string(); @@ -127,6 +132,7 @@ RCConfiguration::load_state () if (statbuf.st_size != 0) { info << string_compose (_("Loading user configuration file %1"), rcfile) << endl; + XMLTree tree; if (!tree.read (rcfile)) { error << string_compose(_("Ardour: cannot read configuration file \"%1\""), rcfile) << endmsg; return -1; @@ -150,8 +156,6 @@ RCConfiguration::load_state () int RCConfiguration::save_state() { - XMLTree tree; - try { sys::create_directories (user_config_directory ()); @@ -169,6 +173,7 @@ RCConfiguration::save_state() // this test seems bogus? if (rcfile.length()) { + XMLTree tree; tree.set_root (&get_state()); if (!tree.write (rcfile.c_str())){ error << string_compose (_("Config file %1 not saved"), rcfile) << endmsg; diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 34274832c1..5ccde8b317 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -1368,7 +1368,6 @@ int Route::remove_processors (const ProcessorList& to_be_deleted, ProcessorStreams* err) { ProcessorList deleted; - ProcessorList as_we_were; if (!_session.engine().connected()) { return 1; @@ -1381,7 +1380,7 @@ Route::remove_processors (const ProcessorList& to_be_deleted, ProcessorStreams* ProcessorList::iterator i; boost::shared_ptr<Processor> processor; - as_we_were = _processors; + ProcessorList as_we_were = _processors; for (i = _processors.begin(); i != _processors.end(); ) { @@ -2435,7 +2434,7 @@ Route::feeds (boost::shared_ptr<Route> other, bool* only_send) } - for (ProcessorList::iterator r = _processors.begin(); r != _processors.end(); r++) { + for (ProcessorList::iterator r = _processors.begin(); r != _processors.end(); ++r) { boost::shared_ptr<IOProcessor> iop; diff --git a/libs/ardour/route_group.cc b/libs/ardour/route_group.cc index 5e50c15457..f31820e924 100644 --- a/libs/ardour/route_group.cc +++ b/libs/ardour/route_group.cc @@ -161,7 +161,7 @@ RouteGroup::get_min_factor(gain_t factor) { gain_t g; - for (RouteList::iterator i = routes->begin(); i != routes->end(); i++) { + for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) { g = (*i)->amp()->gain(); if ( (g+g*factor) >= 0.0f) diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index decb2603fe..c1fe4bb8c0 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -725,24 +725,27 @@ Session::when_engine_running () } else { - /* XXX this logic is wrong for mixed port types */ - - uint32_t shift = _master_out->n_outputs().n_audio(); - uint32_t mod = _engine.n_physical_outputs (DataType::AUDIO); - limit = _control_out->n_outputs().n_audio(); - - cerr << "Connecting " << limit << " control out ports, shift is " << shift << " mod is " << mod << endl; - - for (uint32_t n = 0; n < limit; ++n) { - - Port* p = _control_out->output()->nth (n); - string connect_to = _engine.get_nth_physical_output (DataType (p->type()), (n+shift) % mod); - - if (!connect_to.empty()) { - if (_control_out->output()->connect (p, connect_to, this)) { - error << string_compose (_("cannot connect control output %1 to %2"), n, connect_to) - << endmsg; - break; + for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { + uint32_t shift = _master_out->n_outputs().get(*t); + uint32_t mod = _engine.n_physical_outputs (*t); + limit = _control_out->n_outputs().get(*t); + + cerr << "Connecting " << limit << " control out ports, shift is " << shift + << " mod is " << mod << endl; + + for (uint32_t n = 0; n < limit; ++n) { + + Port* p = _control_out->output()->ports().port(*t, n); + string connect_to = _engine.get_nth_physical_output (*t, (n+shift) % mod); + + if (!connect_to.empty()) { + if (_control_out->output()->connect (p, connect_to, this)) { + error << string_compose ( + _("cannot connect control output %1 to %2"), + n, connect_to) + << endmsg; + break; + } } } } @@ -1527,12 +1530,11 @@ Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_m char track_name[32]; uint32_t track_id = 0; uint32_t n = 0; + uint32_t channels_used = 0; string port; RouteList new_routes; list<boost::shared_ptr<MidiTrack> > ret; - //uint32_t control_id; - - // FIXME: need physical I/O and autoconnect stuff for MIDI + uint32_t control_id; /* count existing midi tracks */ @@ -1543,7 +1545,7 @@ Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_m if (boost::dynamic_pointer_cast<MidiTrack>(*i) != 0) { if (!(*i)->is_hidden()) { n++; - //channels_used += (*i)->n_inputs().n_midi(); + channels_used += (*i)->n_inputs().n_midi(); } } } @@ -1555,7 +1557,7 @@ Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_m _engine.get_physical_outputs (DataType::MIDI, physoutputs); _engine.get_physical_inputs (DataType::MIDI, physinputs); - // control_id = ntracks() + nbusses(); + control_id = ntracks() + nbusses(); while (how_many) { @@ -1580,7 +1582,9 @@ Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_m shared_ptr<MidiTrack> track; try { - track = boost::shared_ptr<MidiTrack>((new MidiTrack (*this, track_name, Route::Flag (0), mode))); + MidiTrack* mt = new MidiTrack (*this, track_name, Route::Flag (0), mode); + boost_debug_shared_ptr_mark_interesting (mt, "Track"); + track = boost::shared_ptr<MidiTrack>(mt); if (track->input()->ensure_io (ChanCount(DataType::MIDI, 1), false, this)) { error << "cannot configure 1 in/1 out configuration for new midi track" << endmsg; @@ -1593,6 +1597,47 @@ Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_m goto failed; } + if (!physinputs.empty()) { + uint32_t nphysical_in = physinputs.size(); + + for (uint32_t x = 0; x < track->n_inputs().n_midi() && x < nphysical_in; ++x) { + + port = ""; + + if (Config->get_input_auto_connect() & AutoConnectPhysical) { + port = physinputs[(channels_used+x)%nphysical_in]; + } + + if (port.length() && track->input()->connect (track->input()->nth(x), port, this)) { + break; + } + } + } + + if (!physoutputs.empty()) { + uint32_t nphysical_out = physoutputs.size(); + + for (uint32_t x = 0; x < track->n_outputs().n_midi(); ++x) { + port = ""; + + if (Config->get_output_auto_connect() & AutoConnectPhysical) { + port = physoutputs[(channels_used+x)%nphysical_out]; + } else if (Config->get_output_auto_connect() & AutoConnectMaster) { + if (_master_out && _master_out->n_inputs().n_midi() > 0) { + port = _master_out->input()->nth (x % _master_out->input()->n_ports().n_midi())->name(); + } + } + + if (port.length() && track->output()->connect (track->output()->nth(x), port, this)) { + break; + } + } + } + + channels_used += track->n_inputs ().n_audio(); + + + /* if (nphysical_in) { for (uint32_t x = 0; x < track->n_inputs().n_midi() && x < nphysical_in; ++x) { diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc index 80631ac840..6367a668dd 100644 --- a/libs/ardour/vst_plugin.cc +++ b/libs/ardour/vst_plugin.cc @@ -326,7 +326,7 @@ VSTPlugin::get_parameter_descriptor (uint32_t which, ParameterDescriptor& desc) } bool -VSTPlugin::load_preset (string name) +VSTPlugin::load_preset (const string& name) { if (_plugin->flags & 32 /* effFlagsProgramsChunks */) { error << _("no support for presets using chunks at this time") |