attempt to stop sending MMC/MTC while exporting or freewheeling for any reason

git-svn-id: svn://localhost/ardour2/branches/3.0@11457 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis
2012-02-06 17:09:53 +00:00
parent f4f2a9a111
commit 009c7a9e44
9 changed files with 51 additions and 16 deletions

View File

@@ -280,6 +280,7 @@ private:
/// the number of frames processed since start() was called
framecnt_t _processed_frames;
bool _freewheeling;
bool _pre_freewheel_mmc_enabled;
int _usecs_per_cycle;
bool port_remove_in_progress;
@@ -314,6 +315,7 @@ private:
int jack_sync_callback (jack_transport_state_t, jack_position_t*);
int jack_bufsize_callback (pframes_t);
int jack_sample_rate_callback (pframes_t);
void freewheel_callback (int);
void set_jack_callbacks ();

View File

@@ -983,6 +983,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
int pre_export ();
int stop_audio_export ();
void finalize_audio_export ();
bool _pre_export_mmc_enabled;
PBD::ScopedConnection export_freewheel_connection;

View File

@@ -84,6 +84,7 @@ AudioEngine::AudioEngine (string client_name, string session_uuid)
_frame_rate = 0;
_buffer_size = 0;
_freewheeling = false;
_pre_freewheel_mmc_enabled = false;
_main_thread = 0;
port_remove_in_progress = false;
@@ -344,7 +345,20 @@ AudioEngine::_process_thread (void *arg)
void
AudioEngine::_freewheel_callback (int onoff, void *arg)
{
static_cast<AudioEngine*>(arg)->_freewheeling = onoff;
static_cast<AudioEngine*>(arg)->freewheel_callback (onoff);
}
void
AudioEngine::freewheel_callback (int onoff)
{
_freewheeling = onoff;
if (onoff) {
_pre_freewheel_mmc_enabled = MIDI::Manager::instance()->mmc()->send_enabled ();
MIDI::Manager::instance()->mmc()->enable_send (false);
} else {
MIDI::Manager::instance()->mmc()->enable_send (_pre_freewheel_mmc_enabled);
}
}
void

View File

@@ -21,6 +21,9 @@
#include "pbd/error.h"
#include <glibmm/thread.h>
#include <midi++/manager.h>
#include <midi++/mmc.h>
#include "ardour/audioengine.h"
#include "ardour/butler.h"
#include "ardour/export_failed.h"
@@ -89,6 +92,11 @@ Session::pre_export ()
export_status->running = true;
export_status->Aborting.connect_same_thread (*this, boost::bind (&Session::stop_audio_export, this));
export_status->Finished.connect_same_thread (*this, boost::bind (&Session::finalize_audio_export, this));
/* disable MMC output early */
_pre_export_mmc_enabled = MIDI::Manager::instance()->mmc()->send_enabled ();
MIDI::Manager::instance()->mmc()->enable_send (false);
return 0;
}
@@ -223,6 +231,8 @@ Session::finalize_audio_export ()
_engine.freewheel (false);
export_freewheel_connection.disconnect();
MIDI::Manager::instance()->mmc()->enable_send (_pre_export_mmc_enabled);
/* maybe write CUE/TOC */
export_handler.reset();

View File

@@ -361,7 +361,7 @@ Session::send_full_time_code (framepos_t const t)
_send_timecode_update = false;
if (!Config->get_send_mtc() || _slave) {
if (_engine.freewheeling() || !Config->get_send_mtc() || _slave) {
return 0;
}
@@ -415,7 +415,7 @@ Session::send_full_time_code (framepos_t const t)
int
Session::send_midi_time_code_for_cycle (framepos_t start_frame, framepos_t end_frame, pframes_t nframes)
{
if (_slave || !_send_qf_mtc || transmitting_timecode_time.negative || (next_quarter_frame_to_send < 0)) {
if (_engine.freewheeling() || _slave || !_send_qf_mtc || transmitting_timecode_time.negative || (next_quarter_frame_to_send < 0)) {
// cerr << "(MTC) Not sending MTC\n";
return 0;
}

View File

@@ -88,7 +88,7 @@ Session::process (pframes_t nframes)
*/
try {
if (Config->get_send_midi_clock() && transport_speed() == 1.0f && midi_clock->has_midi_port()) {
if (!_engine.freewheeling() && Config->get_send_midi_clock() && transport_speed() == 1.0f && midi_clock->has_midi_port()) {
midi_clock->tick (transport_at_start);
}
} catch (...) {

View File

@@ -226,6 +226,7 @@ Session::first_stage_init (string fullpath, string snapshot_name)
_speakers.reset (new Speakers);
_clicks_cleared = 0;
ignore_route_processor_changes = false;
_pre_export_mmc_enabled = false;
AudioDiskstream::allocate_working_buffers();

View File

@@ -616,11 +616,13 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished)
have_looped = false;
send_full_time_code (_transport_frame);
if (!dynamic_cast<MTC_Slave*>(_slave)) {
MIDI::Manager::instance()->mmc()->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdStop));
send_mmc_locate (_transport_frame);
if (!_engine.freewheeling()) {
send_full_time_code (_transport_frame);
if (!dynamic_cast<MTC_Slave*>(_slave)) {
MIDI::Manager::instance()->mmc()->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdStop));
send_mmc_locate (_transport_frame);
}
}
if ((ptw & PostTransportLocate) && get_record_enabled()) {
@@ -1187,10 +1189,12 @@ Session::start_transport ()
(*i)->automation_snapshot (_transport_frame, true);
}
Timecode::Time time;
timecode_time_subframes (_transport_frame, time);
if (!dynamic_cast<MTC_Slave*>(_slave)) {
MIDI::Manager::instance()->mmc()->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdDeferredPlay));
if (!_engine.freewheeling()) {
Timecode::Time time;
timecode_time_subframes (_transport_frame, time);
if (!dynamic_cast<MTC_Slave*>(_slave)) {
MIDI::Manager::instance()->mmc()->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdDeferredPlay));
}
}
TransportStateChange (); /* EMIT SIGNAL */
@@ -1551,9 +1555,11 @@ Session::maybe_stop (framepos_t limit)
void
Session::send_mmc_locate (framepos_t t)
{
Timecode::Time time;
timecode_time_subframes (t, time);
MIDI::Manager::instance()->mmc()->send (MIDI::MachineControlCommand (time));
if (!_engine.freewheeling()) {
Timecode::Time time;
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

View File

@@ -99,6 +99,7 @@ class MachineControl
byte receive_device_id () const { return _receive_device_id; }
byte send_device_id () const { return _send_device_id; }
void enable_send (bool);
bool send_enabled () const { return _enable_send; }
void send (MachineControlCommand const &);
static bool is_mmc (byte *sysex_buf, size_t len);