summaryrefslogtreecommitdiff
path: root/libs/midi++2/jack_midiport.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-05-12 02:40:48 +0000
committerDavid Robillard <d@drobilla.net>2008-05-12 02:40:48 +0000
commit8ca72c4eca3a712f5368680ba0fbce5beb831324 (patch)
tree65b29e7fe4bb0d28f8a113bf014e831d98c7d50b /libs/midi++2/jack_midiport.cc
parenta76e2128efea2d48fd873e95fd7c0f0b6f6135b3 (diff)
Fix various MIDI corruption bugs.
Re-enable MIDI CC controller bars and other immediate output (hans commented out, tsk tsk). Write channel mode as textual enumeration instead of magic number. Better atomic (almost) channel mode switching on MIDI ring buffer (was a possible, if unlikely, source of corruption). Handle some cases of broken MIDI, and oversized events, more gracefully. git-svn-id: svn://localhost/ardour2/branches/3.0@3335 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/midi++2/jack_midiport.cc')
-rw-r--r--libs/midi++2/jack_midiport.cc31
1 files changed, 17 insertions, 14 deletions
diff --git a/libs/midi++2/jack_midiport.cc b/libs/midi++2/jack_midiport.cc
index 311bbb98f6..0b49517212 100644
--- a/libs/midi++2/jack_midiport.cc
+++ b/libs/midi++2/jack_midiport.cc
@@ -95,24 +95,27 @@ JACK_MidiPort::write(byte * msg, size_t msglen, timestamp_t timestamp)
} else {
- assert(_currently_in_cycle);
assert(_jack_output_port);
assert(timestamp < _nframes_this_cycle);
- if (timestamp == 0) {
- timestamp = _last_write_timestamp;
- }
-
- if (jack_midi_event_write (jack_port_get_buffer (_jack_output_port, _nframes_this_cycle),
- timestamp, msg, msglen) == 0) {
- ret = msglen;
- _last_write_timestamp = timestamp;
-
+ if (_currently_in_cycle) {
+ if (timestamp == 0) {
+ timestamp = _last_write_timestamp;
+ }
+
+ if (jack_midi_event_write (jack_port_get_buffer (_jack_output_port, _nframes_this_cycle),
+ timestamp, msg, msglen) == 0) {
+ ret = msglen;
+ _last_write_timestamp = timestamp;
+
+ } else {
+ ret = 0;
+ cerr << "write of " << msglen << " failed, port holds "
+ << jack_midi_get_event_count (jack_port_get_buffer (_jack_output_port, _nframes_this_cycle))
+ << endl;
+ }
} else {
- ret = 0;
- cerr << "write of " << msglen << " failed, port holds "
- << jack_midi_get_event_count (jack_port_get_buffer (_jack_output_port, _nframes_this_cycle))
- << endl;
+ cerr << "write to JACK midi port failed: not currently in a process cycle." << endl;
}
}