create and manage a new config parameter that defines where LTC originates (still some tweaks to be done here and there)

git-svn-id: svn://localhost/ardour2/branches/3.0@13280 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis
2012-10-15 15:57:35 +00:00
parent 6ab663342d
commit cb84e71caa
7 changed files with 154 additions and 20 deletions

View File

@@ -260,9 +260,7 @@ _ the regular process() call to session->process() is not made.
int create_process_thread (boost::function<void()>, pthread_t*, size_t stacksize);
#ifdef HAVE_LTC
Port *ltc_input_port() const { return _ltc_input; }
#endif
boost::shared_ptr<Port> ltc_input_port() const { return _ltc_input; }
private:
static AudioEngine* _instance;
@@ -293,9 +291,8 @@ private:
Glib::Threads::Thread* m_meter_thread;
ProcessThread* _main_thread;
#ifdef HAVE_LTC
Port* _ltc_input;
#endif
boost::shared_ptr<Port> _ltc_input;
void reconnect_ltc ();
SerializedRCUManager<Ports> ports;
@@ -329,6 +326,7 @@ private:
int jack_bufsize_callback (pframes_t);
int jack_sample_rate_callback (pframes_t);
void freewheel_callback (int);
void connect_callback (jack_port_id_t, jack_port_id_t, int);
void set_jack_callbacks ();
@@ -356,6 +354,8 @@ private:
};
static void* _start_process_thread (void*);
void parameter_changed (const std::string&);
PBD::ScopedConnection config_connection;
};
} // namespace ARDOUR

View File

@@ -51,6 +51,7 @@ CONFIG_VARIABLE (int, mtc_qf_speed_tolerance, "mtc-qf-speed-tolerance", 5)
CONFIG_VARIABLE (bool, timecode_sync_frame_rate, "timecode-sync-frame-rate", true)
CONFIG_VARIABLE (bool, timecode_source_is_synced, "timecode-source-is-synced", true)
CONFIG_VARIABLE (SyncSource, sync_source, "sync-source", JACK)
CONFIG_VARIABLE (std::string, ltc_source_port, "ltc-source-port", "system:capture_1")
/* control surfaces */

View File

@@ -89,13 +89,24 @@ AudioEngine::AudioEngine (string client_name, string session_uuid)
}
Port::set_engine (this);
#ifdef HAVE_LTC
_ltc_input = new AudioPort ("LTC in", Port::IsInput);
_ltc_input = register_port (DataType::AUDIO, _("LTC in"), Port::IsInput);
/* As of October 2012, the LTC source port is the only thing that needs
* to care about Config parameters, so don't bother to listen if we're
* not doing LTC stuff. This might change if other parameters show up
* in the future that we need to care about with or without LTC.
*/
Config->ParameterChanged.connect_same_thread (config_connection, boost::bind (&AudioEngine::parameter_changed, this, _1));
#endif
}
AudioEngine::~AudioEngine ()
{
config_connection.disconnect ();
{
Glib::Threads::Mutex::Lock tm (_process_lock);
session_removed.signal ();
@@ -210,6 +221,9 @@ AudioEngine::start ()
_running = true;
_has_run = true;
Running(); /* EMIT SIGNAL */
reconnect_ltc ();
} else {
// error << _("cannot activate JACK client") << endmsg;
}
@@ -377,31 +391,38 @@ void
AudioEngine::_connect_callback (jack_port_id_t id_a, jack_port_id_t id_b, int conn, void* arg)
{
AudioEngine* ae = static_cast<AudioEngine*> (arg);
ae->connect_callback (id_a, id_b, conn);
}
if (ae->port_remove_in_progress) {
void
AudioEngine::connect_callback (jack_port_id_t id_a, jack_port_id_t id_b, int conn)
{
if (port_remove_in_progress) {
return;
}
GET_PRIVATE_JACK_POINTER (ae->_jack);
GET_PRIVATE_JACK_POINTER (_jack);
jack_port_t* jack_port_a = jack_port_by_id (_priv_jack, id_a);
jack_port_t* jack_port_b = jack_port_by_id (_priv_jack, id_b);
boost::shared_ptr<Port> port_a;
boost::shared_ptr<Port> port_b;
Ports::iterator x;
boost::shared_ptr<Ports> pr = ports.reader ();
boost::shared_ptr<Ports> pr = ae->ports.reader ();
Ports::iterator i = pr->begin ();
while (i != pr->end() && (port_a == 0 || port_b == 0)) {
if (jack_port_a == i->second->jack_port()) {
port_a = i->second;
} else if (jack_port_b == i->second->jack_port()) {
port_b = i->second;
}
++i;
x = pr->find (make_port_name_relative (jack_port_name (jack_port_a)));
if (x != pr->end()) {
port_a = x->second;
}
ae->PortConnectedOrDisconnected (
x = pr->find (make_port_name_relative (jack_port_name (jack_port_b)));
if (x != pr->end()) {
port_b = x->second;
}
PortConnectedOrDisconnected (
port_a, jack_port_name (jack_port_a),
port_b, jack_port_name (jack_port_b),
conn == 0 ? false : true
@@ -1470,6 +1491,8 @@ AudioEngine::reconnect_to_jack ()
MIDI::Manager::instance()->reconnect ();
reconnect_ltc ();
Running (); /* EMIT SIGNAL*/
start_metering_thread ();
@@ -1613,3 +1636,27 @@ AudioEngine::destroy ()
delete _instance;
_instance = 0;
}
void
AudioEngine::parameter_changed (const std::string& s)
{
if (s == "ltc-source-port") {
reconnect_ltc ();
}
}
void
AudioEngine::reconnect_ltc ()
{
if (_ltc_input) {
string src = Config->get_ltc_source_port();
_ltc_input->disconnect_all ();
if (src != _("None") && !src.empty()) {
_ltc_input->connect (src);
}
}
}

View File

@@ -307,7 +307,7 @@ LTC_Slave::speed_and_position (double& speed, framepos_t& pos)
jack_default_audio_sample_t *in;
jack_latency_range_t ltc_latency;
Port *ltcport = session.engine().ltc_input_port();
boost::shared_ptr<Port> ltcport = session.engine().ltc_input_port();
ltcport->get_connected_latency_range(ltc_latency, false);
in = (jack_default_audio_sample_t*) jack_port_get_buffer (ltcport->jack_port(), nframes);