From 95bb346926e237b903059c83a70e58ed9253eaca Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 22 Dec 2010 23:43:04 +0000 Subject: [PATCH] Refactor so that all the locate-related stuff in CursorDrag is in one method. Also, wait for timecode transmission to be suspended before sending MMC/MTC locates, rather than hoping it will be suspended in time. git-svn-id: svn://localhost/ardour2/branches/3.0@8329 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor_drag.cc | 53 +++++++++++++++++++------------------- gtk2_ardour/editor_drag.h | 2 ++ 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index d069e2e984..7f87ae0273 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -1983,17 +1983,33 @@ CursorDrag::CursorDrag (Editor* e, ArdourCanvas::Item* i, bool s) DEBUG_TRACE (DEBUG::Drags, "New CursorDrag\n"); } +/** Do all the things we do when dragging the playhead to make it look as though + * we have located, without actually doing the locate (because that would cause + * the diskstream buffers to be refilled, which is too slow). + */ +void +CursorDrag::fake_locate (framepos_t t) +{ + _editor->playhead_cursor->set_position (t); + + Session* s = _editor->session (); + if (s->timecode_transmission_suspended ()) { + framepos_t const f = _editor->playhead_cursor->current_frame; + s->send_mmc_locate (f); + s->send_full_time_code (f); + } + + _editor->show_verbose_time_cursor (t, 10); + _editor->UpdateAllTransportClocks (t); +} + void CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c) { Drag::start_grab (event, c); - if (!_stop) { - framepos_t where = _editor->event_frame (event, 0, 0); - - _editor->snap_to_with_modifier (where, event); - _editor->playhead_cursor->set_position (where); - } + framepos_t where = _editor->event_frame (event, 0, 0); + _editor->snap_to_with_modifier (where, event); _editor->_dragging_playhead = true; @@ -2009,16 +2025,12 @@ CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c) } s->request_suspend_timecode_transmission (); - - if (s->timecode_transmission_suspended ()) { - framepos_t const f = _editor->playhead_cursor->current_frame; - s->send_mmc_locate (f); - s->send_full_time_code (f); + while (!s->timecode_transmission_suspended ()) { + /* twiddle our thumbs */ } } - - _editor->show_verbose_time_cursor (_editor->playhead_cursor->current_frame, 10); - _editor->UpdateAllTransportClocks (_editor->playhead_cursor->current_frame); + + fake_locate (where); } void @@ -2030,22 +2042,11 @@ CursorDrag::motion (GdkEvent* event, bool) return; } - _editor->playhead_cursor->set_position (adjusted_frame); - - _editor->show_verbose_time_cursor (_editor->playhead_cursor->current_frame, 10); - - Session* s = _editor->session (); - if (s && s->timecode_transmission_suspended ()) { - framepos_t const f = _editor->playhead_cursor->current_frame; - s->send_mmc_locate (f); - s->send_full_time_code (f); - } + fake_locate (adjusted_frame); - #ifdef GTKOSX _editor->update_canvas_now (); #endif - _editor->UpdateAllTransportClocks (_editor->playhead_cursor->current_frame); } void diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index c294744004..3323a8b741 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -594,6 +594,8 @@ public: } private: + void fake_locate (framepos_t); + bool _stop; ///< true to stop the transport on starting the drag, otherwise false };