Fix uninitialised variable causing garbage output from panners in some cases.
[ardour.git] / libs / ardour / midi_port.cc
index c27332fce12486b968e30664ffd0016c4ee721a5..9a7d3eeb27fdfee4a716671d35fcd7b1583e9780 100644 (file)
@@ -128,20 +128,15 @@ MidiPort::cycle_split ()
 void
 MidiPort::resolve_notes (void* jack_buffer, MidiBuffer::TimeType when)
 {
-       uint8_t ev[3];
-
-       ev[2] = 0;
-
        for (uint8_t channel = 0; channel <= 0xF; channel++) {
-               ev[0] = (MIDI_CMD_CONTROL | channel);
+
+               uint8_t ev[3] = { ((uint8_t) (MIDI_CMD_CONTROL | channel)), MIDI_CTL_SUSTAIN, 0 };
 
                /* we need to send all notes off AND turn the
                 * sustain/damper pedal off to handle synths
                 * that prioritize sustain over AllNotesOff
                 */
 
-               ev[1] = MIDI_CTL_SUSTAIN;
-
                if (jack_midi_event_write (jack_buffer, when, ev, 3) != 0) {
                        cerr << "failed to deliver sustain-zero on channel " << channel << " on port " << name() << endl;
                }
@@ -155,7 +150,7 @@ MidiPort::resolve_notes (void* jack_buffer, MidiBuffer::TimeType when)
 }
 
 void
-MidiPort::flush_buffers (pframes_t nframes, framepos_t time)
+MidiPort::flush_buffers (pframes_t nframes)
 {
        if (sends_output ()) {
 
@@ -164,7 +159,7 @@ MidiPort::flush_buffers (pframes_t nframes, framepos_t time)
                if (_resolve_required) {
                        /* resolve all notes at the start of the buffer */
                        resolve_notes (jack_buffer, 0);
-                       _resolve_required= false;
+                       _resolve_required = false;
                }
 
                for (MidiBuffer::iterator i = _buffer->begin(); i != _buffer->end(); ++i) {
@@ -186,8 +181,8 @@ MidiPort::flush_buffers (pframes_t nframes, framepos_t time)
                                             << ev.time() << " > " << _global_port_buffer_offset + _port_buffer_offset << endl;
                                }
                        } else {
-                               cerr << "drop flushed event on the floor, time " << ev.time()
-                                    << " < " << _global_port_buffer_offset + _port_buffer_offset << endl;
+                               cerr << "drop flushed event on the floor, time " << ev
+                                    << " to early for " << _global_port_buffer_offset + _port_buffer_offset << endl;
                        }
                }
        }