+ _write_data_count = 0;
+
+ if (_last_flush_frame > _session.transport_frame()) {
+ _last_flush_frame = _session.transport_frame();
+ }
+
+ total = _session.transport_frame() - _last_flush_frame;
+
+
+ // FIXME: put this condition back in! (removed for testing)
+ if (total == 0 || (total < disk_io_chunk_frames && !force_flush && was_recording)) {
+ //cerr << "MDS - no flush 1\n";
+ goto out;
+ }
+
+ /* if there are 2+ chunks of disk i/o possible for
+ this track, let the caller know so that it can arrange
+ for us to be called again, ASAP.
+
+ if we are forcing a flush, then if there is* any* extra
+ work, let the caller know.
+
+ if we are no longer recording and there is any extra work,
+ let the caller know too.
+ */
+
+ if (total >= 2 * disk_io_chunk_frames || ((force_flush || !was_recording) && total > disk_io_chunk_frames)) {
+ ret = 1;
+ }
+
+ //to_write = min (disk_io_chunk_frames, (nframes_t) vector.len[0]);
+ to_write = disk_io_chunk_frames;
+
+ assert(!destructive());
+
+ if ((!_write_source) || _write_source->write (*_capture_buf, to_write) != to_write) {
+ //cerr << "MDS - no flush 2\n";
+ error << string_compose(_("MidiDiskstream %1: cannot write to disk"), _id) << endmsg;
+ return -1;
+ } else {
+ _last_flush_frame = _session.transport_frame();
+ //cerr << "MDS - flushed\n";
+ }
+
+ //(*chan).curr_capture_cnt += to_write;
+
+out:
+ //return ret;