- int ret = 0;
-
- if (!sends_output()) {
- return ret;
- }
-
- if (!is_process_thread()) {
-
- Glib::Mutex::Lock lm (output_fifo_lock);
- RingBuffer< Evoral::Event<double> >::rw_vector vec = { { 0, 0 }, { 0, 0} };
-
- output_fifo.get_write_vector (&vec);
-
- if (vec.len[0] + vec.len[1] < 1) {
- error << "no space in FIFO for non-process thread MIDI write" << endmsg;
- return 0;
- }
-
- if (vec.len[0]) {
- if (!vec.buf[0]->owns_buffer()) {
- vec.buf[0]->set_buffer (0, 0, true);
- }
- vec.buf[0]->set (msg, msglen, timestamp);
- } else {
- if (!vec.buf[1]->owns_buffer()) {
- vec.buf[1]->set_buffer (0, 0, true);
- }
- vec.buf[1]->set (msg, msglen, timestamp);
- }
-
- output_fifo.increment_write_idx (1);
-
- ret = msglen;
-
- } else {
-
- // XXX This had to be temporarily commented out to make export work again
- if (!(timestamp < _nframes_this_cycle)) {
- std::cerr << "attempting to write MIDI event of " << msglen << " bytes at time "
- << timestamp << " of " << _nframes_this_cycle
- << " (this will not work - needs a code fix)"
- << std::endl;
- }