Fix various code quality issues found by cppcheck (e.g. uninitialized members, larger...
authorDavid Robillard <d@drobilla.net>
Tue, 23 Feb 2010 20:25:53 +0000 (20:25 +0000)
committerDavid Robillard <d@drobilla.net>
Tue, 23 Feb 2010 20:25:53 +0000 (20:25 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@6710 d708f5d6-7413-0410-9779-e7cbd77b26cf

44 files changed:
libs/ardour/ardour/audio_library.h
libs/ardour/ardour/audio_unit.h
libs/ardour/ardour/control_protocol_manager.h
libs/ardour/ardour/delivery.h
libs/ardour/ardour/export_graph_builder.h
libs/ardour/ardour/export_handler.h
libs/ardour/ardour/lv2_plugin.h
libs/ardour/ardour/plugin.h
libs/ardour/ardour/rc_configuration.h
libs/ardour/ardour/route_group.h
libs/ardour/ardour/session.h
libs/ardour/ardour/session_event.h
libs/ardour/ardour/types.h
libs/ardour/ardour/vst_plugin.h
libs/ardour/audio_buffer.cc
libs/ardour/audio_diskstream.cc
libs/ardour/audio_library.cc
libs/ardour/audio_playlist.cc
libs/ardour/audio_region_importer.cc
libs/ardour/audio_unit.cc
libs/ardour/audioengine.cc
libs/ardour/audiosource.cc
libs/ardour/auditioner.cc
libs/ardour/delivery.cc
libs/ardour/export_handler.cc
libs/ardour/import.cc
libs/ardour/io.cc
libs/ardour/location.cc
libs/ardour/location_importer.cc
libs/ardour/lv2_plugin.cc
libs/ardour/midi_diskstream.cc
libs/ardour/midi_playlist.cc
libs/ardour/midi_track.cc
libs/ardour/onset_detector.cc
libs/ardour/panner.cc
libs/ardour/playlist.cc
libs/ardour/plugin.cc
libs/ardour/plugin_manager.cc
libs/ardour/processor.cc
libs/ardour/rc_configuration.cc
libs/ardour/route.cc
libs/ardour/route_group.cc
libs/ardour/session.cc
libs/ardour/vst_plugin.cc

index aada317dbdae3010974b169356957647cf7a48db..2009ec39a7a5d104987c6b958b157c6231ef911a 100644 (file)
@@ -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();
 
index 9fbc188562ce7bc648e29fb98eca3da1e3086d6d..6d2b2410fdae097a8022c4bb74bccb51524185cf 100644 (file)
@@ -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;
 
index 6fedc95c6c679bb309d69d8a79bc9c67a9d39d88..ad5bb3166eb339d7fd1cf9b61d0221ed0396dc7c 100644 (file)
@@ -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
index a7ccd96a2db96e39efcfa65ddb070c81e475ab5c..b2bd283ef8cb132e17136af0fd8c53220c313271 100644 (file)
@@ -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;
index 2f57aaf5834d6130fdcdb6e6c2199667087429d1..f98ffeb8eb67e7dfa9a4c69e70542e4745c7ea61 100644 (file)
@@ -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;
index 971c0c494052eb0f35d1e15e222e3691dce5e2c9..05fbddecf57a08fb28f8a6729e47eb54c6097b04 100644 (file)
@@ -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)
                  {}
index 157d9144b85db4b7e191b163941d81e48001b627..d42c34a5461e631c6c6148521c695f9a2e7360fa 100644 (file)
@@ -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;
index 4770c43511ec3d6f6249c3e1bc566df6d20c31f9..8731697906f9ebbf7d9170987f514d7f6284e6b4 100644 (file)
@@ -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) {}
index ad31aac44ea102747707f46aa527147fe1bbef26..35b22106dd060fa35ebbc2a58aae2a8ce3366ea0 100644 (file)
@@ -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);
index f3109a707df23599392f9dcf95518f30af190f45..7f3d25454acba1a08ad05bc00f6f8a13266cff40 100644 (file)
@@ -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);
                }
        }
index 9294d56fcc74b5dbae1cd50953d4e025f2e4a726..02c5cc2391573751cc69c18c7ab13000c11df49b 100644 (file)
@@ -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);
                }
        }
index 2ce2d5225ad4fde75fba90fef8bda7212fe36999..882142c68d1916d9dfd0ad60e1f1a991d7c2b049 100644 (file)
@@ -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 */
index 43806625405d5e6140a6915201f727bf67f63890..54c965ce67e4e954b44702dfa69845d0c1119405 100644 (file)
@@ -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;
index 753d94294f4ba55a968a6760c2bf4641dd18cf82..513f24d493d5c26c833ae912ef5e5daa87374c6a 100644 (file)
@@ -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;
index a57891a27d7c0a04c699adf7cb849ab89a688cd4..8b2d5c744f116310f24d9453ae9da02b2a3f2547 100644 (file)
@@ -58,9 +58,7 @@ AudioBuffer::resize (size_t size)
                return;
        }
 
-       if (_data) {
-               free (_data);
-       }
+       free (_data);
 
        _capacity = size;
        _size = size;
index 0ec6533aa4525b71a784e171788c0941b398c26a..f7a1240bddf7a69990ecb37db6eb668e1f703b96 100644 (file)
@@ -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
                        */
index 26f225273f626a15c5878af1c082f23bfeff0e47..662b8cb33e66f844dac4fa63231f76c3d89dc789 100644 (file)
@@ -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;
index 6e8b35a07238e8661058cef8f5453f42ab9fa85d..65b05b7c92962ac0c624042d8c2054327a28cae9 100644 (file)
@@ -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;
index 289af0b4d8f6e91dd2baacea1e96cb43a7b2ea18..ebe4ae527046df4bf860002e125312ab34196988 100644 (file)
@@ -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;
index a2cf0e07e98cb8efd82dd4abd7c78873cbab41bc..ca5362004c81f012b58e365359cc1dc96729ba51 100644 (file)
@@ -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));
                                        }
index 2035265c466fe1487f272e8c160fc00027819ac4..3766f60b63d34ab4dae3e5e6e35ce93f0081f992 100644 (file)
@@ -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);
 }
index 841dec18878bed5202ecdd9fedcea8a188ef8b0f..2657ba94ad22695dfacaab30a7dc6992fafe9fcf 100644 (file)
@@ -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;
index 82ec91cafd160f63a78fc533663f7b4cf26c59bc..c88eeedf1a32dde77b655693c690385f2f140a6f 100644 (file)
@@ -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);
index 902dbc97057e2ecb4196f5ae5ad7699ac9340cd4..5777269416bec8066c11f3ddd7f56dd935653775 100644 (file)
@@ -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
 {
index a9335add37c362e7c5e5bbea4cad457a84e8570e..cf6fced74cb22eb73d4506cfcca4bddd06b2a04c 100644 (file)
@@ -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)
 {
 }
 
index c980c49c02eb752334c25cdc31a64d39e08c4a02..d621afe2971ff9067d0336c77b5fcf33af67dc88 100644 (file)
@@ -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;
index 48bab25546dcf0d01785c27d4e26dbfe7bd829ad..b34614e1dd1242b01d94ca581436f0b20916c9fb 100644 (file)
@@ -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;
index 7e3330ecd9476128d9f54158b57dbe997c05391b..4861718d8516fd00868e840fe150d8df8345980f 100644 (file)
@@ -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;
 
index 655a8f1a848c0b641582b881a6110f084f3ae5a1..8d6af300ca597d746dc2a7f0a4a9067323f988a7 100644 (file)
@@ -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) {
index 13cc78c5c0e7091adcf516a2d914153f8773bf8e..b48395b40f5c5b95c0dfe9da4696ae88128ba402 100644 (file)
@@ -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"
index 4f7d6364b079a9b70b29c96510778e69a1d7bd12..ccfaeaa5cd305ad98af39cae1d11de47a5f8200d 100644 (file)
@@ -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;
        }
index 8c94bb1a7fe0fd0958816e4f89327c999a94514a..048a54da93a006036c63fc0add6eeaa7c221d7fe 100644 (file)
@@ -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) */
 }
index aab7431cc1962ad5517ebc79d7aae1d8e5c47a0a..af66f2f40c3d69ce24245acbdf03e08b9c04bd10 100644 (file)
@@ -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:
index 85917041b6c15c00f687ee2a52c7658323cbfd0d..59fd8d10dfaf720b9abb0355f03edc82b7cc3ef3 100644 (file)
@@ -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 */
 
index d3ce72679a6513d6898d0776e84d265c859e7291..3f4aee0cf75b489dd40cb7ad93c2bf5c8a605a7d 100644 (file)
@@ -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);
        }
 
index 815970a27698c8344363f9836a78cd8d64eda645..e128489820b3f150b9fdff8fbd58fedbb14a9a9b 100644 (file)
@@ -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.
index 4971c57deb6171bb93f9cb2f8372fb37102afd9d..9bbe21aabf652ebe6d300979636c85cdaba7f92f 100644 (file)
@@ -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());
 
index b0d40f6124a14aa61a69da4702f4c0334fbc64bf..f4d638e3bc87ed77e4b8c0aea5a855e2307eda50 100644 (file)
@@ -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;
index 65517be4b145ecedb74f53134d9d6ba760aa7f10..712ca927e5edd640cb6eca0598a1ae12189a72c9 100644 (file)
@@ -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()) {
index a68d0d3b9410d50ea005a219ba002cdd07b17fe0..f1b7748f7306b07206a6eb4aa2b81586ee977de6 100644 (file)
@@ -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;
index 34274832c135e41e56a8d900e865a46081492c82..5ccde8b317d12a31e4aa118bf21c6f9ad2759db2 100644 (file)
@@ -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;
 
index 5e50c15457b403e756b89c072d85d4eb59b6c21a..f31820e9244cb75c7ded816221acc9641347b0ba 100644 (file)
@@ -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)
index decb2603fe98a73fd7268a7eea62c16a646d269f..c1fe4bb8c09d0be1e6670ebb23cf3303b20afc05 100644 (file)
@@ -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) {
index 80631ac840d35200c1f2e2a8abdff418304db332..6367a668dd319640f03c8cd8fda4fc534f8cc95f 100644 (file)
@@ -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")