Commit of the century, right here.
authorDavid Robillard <d@drobilla.net>
Sun, 15 Feb 2009 03:51:49 +0000 (03:51 +0000)
committerDavid Robillard <d@drobilla.net>
Sun, 15 Feb 2009 03:51:49 +0000 (03:51 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@4580 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/smf_source.cc

index 378d3ab91f9d3be743bfdd8435991eae89bb213e..efa99c2c00eb09ea58a24051f8cb91f4802e595e 100644 (file)
@@ -197,8 +197,7 @@ SMFSource::read_unlocked (MidiRingBuffer<nframes_t>& dst, nframes_t start, nfram
                if (ev_size > scratch_size) {
                        scratch_size = ev_size;
                }
-               
-               ev_size = scratch_size; // minimize realloc in read_event
+               ev_size = scratch_size; // ensure read_event only allocates if necessary
        }
        
        return dur;
@@ -642,7 +641,9 @@ SMFSource::load_model(bool lock, bool force_reload)
        size_t scratch_size = 0; // keep track of scratch and minimize reallocs
        
        // FIXME: assumes tempo never changes after start
-       const double frames_per_beat = _session.tempo_map().tempo_at(_timeline_position).frames_per_beat(
+       const Tempo& tempo = _session.tempo_map().tempo_at(_timeline_position);
+       
+       const double frames_per_beat = tempo.frames_per_beat(
                        _session.engine().frame_rate(),
                        _session.tempo_map().meter_at(_timeline_position));
        
@@ -651,7 +652,6 @@ SMFSource::load_model(bool lock, bool force_reload)
        uint8_t* buf     = NULL;
        int ret;
        while ((ret = read_event(&delta_t, &size, &buf)) >= 0) {
-               
                ev.set(buf, size, 0.0);
                time += delta_t;
                
@@ -664,9 +664,8 @@ SMFSource::load_model(bool lock, bool force_reload)
 
                if (ev.size() > scratch_size) {
                        scratch_size = ev.size();
-               } else {
-                       ev.size() = scratch_size;
                }
+               ev.size() = scratch_size; // ensure read_event only allocates if necessary
        }
 
        set_default_controls_interpolation();