Suspend transport timecode transmission during playhead drag. Should fix #3324.

git-svn-id: svn://localhost/ardour2/branches/3.0@7528 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2010-08-02 01:59:34 +00:00
parent 5d8933893c
commit 8b0354f910
6 changed files with 67 additions and 17 deletions

View File

@ -2110,18 +2110,24 @@ CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c)
if (_cursor == _editor->playhead_cursor) {
_editor->_dragging_playhead = true;
if (_editor->session()) {
Session* s = _editor->session ();
if (s) {
if (_was_rolling && _stop) {
_editor->session()->request_stop ();
s->request_stop ();
}
if (_editor->session()->is_auditioning()) {
_editor->session()->cancel_audition ();
if (s->is_auditioning()) {
s->cancel_audition ();
}
nframes64_t const f = _editor->playhead_cursor->current_frame;
_editor->session()->send_mmc_locate (f);
_editor->session()->send_full_time_code (f);
s->request_suspend_timecode_transmission ();
if (s->timecode_transmission_suspended ()) {
nframes64_t const f = _editor->playhead_cursor->current_frame;
s->send_mmc_locate (f);
s->send_full_time_code (f);
}
}
}
@ -2143,10 +2149,11 @@ CursorDrag::motion (GdkEvent* event, bool)
_editor->show_verbose_time_cursor (_cursor->current_frame, 10);
if (_editor->session() && _item == &_editor->playhead_cursor->canvas_item) {
Session* s = _editor->session ();
if (s && _item == &_editor->playhead_cursor->canvas_item && s->timecode_transmission_suspended ()) {
nframes64_t const f = _editor->playhead_cursor->current_frame;
_editor->session()->send_mmc_locate (f);
_editor->session()->send_full_time_code (f);
s->send_mmc_locate (f);
s->send_full_time_code (f);
}
@ -2168,9 +2175,11 @@ CursorDrag::finished (GdkEvent* event, bool movement_occurred)
motion (event, false);
if (_item == &_editor->playhead_cursor->canvas_item) {
if (_editor->session()) {
_editor->session()->request_locate (_editor->playhead_cursor->current_frame, _was_rolling);
Session* s = _editor->session ();
if (s) {
s->request_locate (_editor->playhead_cursor->current_frame, _was_rolling);
_editor->_pending_locate_request = true;
s->request_resume_timecode_transmission ();
}
}
}
@ -2178,7 +2187,11 @@ CursorDrag::finished (GdkEvent* event, bool movement_occurred)
void
CursorDrag::aborted ()
{
_editor->_dragging_playhead = false;
if (_editor->_dragging_playhead) {
_editor->session()->request_resume_timecode_transmission ();
_editor->_dragging_playhead = false;
}
_cursor->set_position (adjusted_frame (grab_frame (), 0, false));
}

View File

@ -780,6 +780,10 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
bool step_editing() const { return (_step_editors > 0); }
void request_suspend_timecode_transmission ();
void request_resume_timecode_transmission ();
bool timecode_transmission_suspended () const;
protected:
friend class AudioEngine;
void set_block_size (nframes_t nframes);
@ -1421,6 +1425,9 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
void step_edit_status_change (bool);
uint32_t _step_editors;
/** true if timecode transmission by the transport is suspended, otherwise false */
mutable gint _suspend_timecode_transmission;
};
} // namespace ARDOUR

View File

@ -36,6 +36,7 @@ struct SessionEvent {
RealTimeOperation,
AdjustPlaybackBuffering,
AdjustCaptureBuffering,
SetTimecodeTransmission,
/* only one of each of these events can be queued at any one time */

View File

@ -154,8 +154,8 @@ Session::Session (AudioEngine &eng,
click_emphasis_data (0),
main_outs (0),
_metadata (new SessionMetadata()),
_have_rec_enabled_track (false)
_have_rec_enabled_track (false),
_suspend_timecode_transmission (0)
{
playlists.reset (new SessionPlaylists);
@ -4006,3 +4006,4 @@ Session::step_edit_status_change (bool yn)
StepEditStatusChange (val);
}
}

View File

@ -311,7 +311,7 @@ Session::process_with_events (nframes_t nframes)
return;
}
if (!_exporting) {
if (!_exporting && !timecode_transmission_suspended()) {
send_midi_time_code_for_cycle (nframes);
}
@ -762,7 +762,7 @@ Session::process_without_events (nframes_t nframes)
return;
}
if (!_exporting) {
if (!_exporting && !timecode_transmission_suspended()) {
send_midi_time_code_for_cycle (nframes);
}
@ -1099,6 +1099,10 @@ Session::process_event (SessionEvent* ev)
schedule_capture_buffering_adjustment ();
break;
case SessionEvent::SetTimecodeTransmission:
g_atomic_int_set (&_suspend_timecode_transmission, ev->yes_or_no ? 0 : 1);
break;
default:
fatal << string_compose(_("Programming error: illegal event type in process_event (%1)"), ev->type) << endmsg;
/*NOTREACHED*/

View File

@ -1568,3 +1568,27 @@ Session::send_mmc_locate (nframes64_t t)
timecode_time_subframes (t, time);
MIDI::Manager::instance()->mmc()->send (MIDI::MachineControlCommand (time));
}
/** Ask the transport to not send timecode until further notice. The suspension
* will come into effect some finite time after this call, and timecode_transmission_suspended()
* should be checked by the caller to find out when.
*/
void
Session::request_suspend_timecode_transmission ()
{
SessionEvent* ev = new SessionEvent (SessionEvent::SetTimecodeTransmission, SessionEvent::Add, SessionEvent::Immediate, 0, 0, false);
queue_event (ev);
}
void
Session::request_resume_timecode_transmission ()
{
SessionEvent* ev = new SessionEvent (SessionEvent::SetTimecodeTransmission, SessionEvent::Add, SessionEvent::Immediate, 0, 0, true);
queue_event (ev);
}
bool
Session::timecode_transmission_suspended () const
{
return g_atomic_int_get (&_suspend_timecode_transmission) == 1;
}