Provide dialogs to edit pan values numerically, at least for
[ardour.git] / libs / ardour / midi_diskstream.cc
index 79ef361e1fbadf62ad55467c50db86e77c8d094d..a8757d7575bd2dcf9372db63794032fcbd306c6d 100644 (file)
 #include "pbd/stateful_diff_command.h"
 #include "pbd/stacktrace.h"
 
-#include "ardour/ardour.h"
 #include "ardour/audioengine.h"
 #include "ardour/butler.h"
-#include "ardour/configuration.h"
-#include "ardour/cycle_timer.h"
 #include "ardour/debug.h"
 #include "ardour/io.h"
 #include "ardour/midi_diskstream.h"
 #include "ardour/midi_region.h"
 #include "ardour/playlist_factory.h"
 #include "ardour/region_factory.h"
-#include "ardour/route.h"
-#include "ardour/send.h"
 #include "ardour/session.h"
 #include "ardour/session_playlists.h"
 #include "ardour/smf_source.h"
+#include "ardour/types.h"
 #include "ardour/utils.h"
 
 #include "midi++/types.h"
@@ -339,7 +335,7 @@ MidiDiskstream::process (framepos_t transport_frame, pframes_t nframes, framecnt
        adjust_capture_position = 0;
 
        if (nominally_recording || (re && was_recording && _session.get_record_enabled() && _session.config.get_punch_in())) {
-               OverlapType ot = coverage (first_recordable_frame, last_recordable_frame, transport_frame, transport_frame + nframes);
+               Evoral::OverlapType ot = Evoral::coverage (first_recordable_frame, last_recordable_frame, transport_frame, transport_frame + nframes);
 
                calculate_record_range(ot, transport_frame, nframes, rec_nframes, rec_offset);
 
@@ -455,14 +451,23 @@ MidiDiskstream::commit (framecnt_t playback_distance)
        uint32_t frames_read = g_atomic_int_get(&_frames_read_from_ringbuffer);
        uint32_t frames_written = g_atomic_int_get(&_frames_written_to_ringbuffer);
 
-       cerr << name() << " MDS written: " << frames_written << " - read: " << frames_read <<
-               " = " << frames_written - frames_read
-            << " + " << playback_distance << " < " << midi_readahead << " = " << need_butler << ")" << endl;
-               
-       assert (frames_read <= frames_written);
+       /*
+         cerr << name() << " MDS written: " << frames_written << " - read: " << frames_read <<
+         " = " << frames_written - frames_read
+         << " + " << playback_distance << " < " << midi_readahead << " = " << need_butler << ")" << endl;
+       */
 
-       if ((frames_written - frames_read) + playback_distance < midi_readahead) {
-               need_butler = true;
+       /* frames_read will generally be less than frames_written, but
+        * immediately after an overwrite, we can end up having read some data
+        * before we've written any. we don't need to trip an assert() on this,
+        * but we do need to check so that the decision on whether or not we
+        * need the butler is done correctly.
+        */
+       
+       if (frames_read <= frames_written) {
+               if ((frames_written - frames_read) + playback_distance < midi_readahead) {
+                       need_butler = true;
+               }
        }
 
 
@@ -487,8 +492,6 @@ MidiDiskstream::overwrite_existing_buffers ()
        g_atomic_int_set (&_frames_read_from_ringbuffer, 0);
        g_atomic_int_set (&_frames_written_to_ringbuffer, 0);
 
-       cerr << name() << " FWTRB reset to zero for overwrite\n";
-
        read (overwrite_frame, disk_io_chunk_frames, false);
        file_frame = overwrite_frame; // it was adjusted by ::read()
        overwrite_queued = false;
@@ -508,8 +511,6 @@ MidiDiskstream::seek (framepos_t frame, bool complete_refill)
        g_atomic_int_set(&_frames_read_from_ringbuffer, 0);
        g_atomic_int_set(&_frames_written_to_ringbuffer, 0);
 
-       cerr << name() << " FWTRB reset to zero for seek\n";
-
        playback_sample = frame;
        file_frame = frame;
 
@@ -606,7 +607,6 @@ MidiDiskstream::read (framepos_t& start, framecnt_t dur, bool reversed)
                }
 
                g_atomic_int_add (&_frames_written_to_ringbuffer, this_read);
-               cerr << "FWTRB added " << this_read << " now " << g_atomic_int_get (&_frames_written_to_ringbuffer) << endl;
 
                if (reversed) {
 
@@ -1297,7 +1297,6 @@ MidiDiskstream::get_playback (MidiBuffer& dst, framecnt_t nframes)
 #endif
 
        g_atomic_int_add (&_frames_read_from_ringbuffer, nframes);
-       cerr << name() << " FRFB advanced by " << nframes << " to " << g_atomic_int_get (&_frames_read_from_ringbuffer) << endl;
 }
 
 bool