summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-10-25 19:46:23 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-10-25 19:46:23 +0000
commit7b818e9a7f3d999eb6bcc90c961d2b42531c3917 (patch)
tree603bf528cea93051837bedb514b3ed74ee61a4fa /libs
parentedc8a593556df099622539763b3189b2f9ab1322 (diff)
move ownership of LTC I/O ports to Session, and manage as IO objects
git-svn-id: svn://localhost/ardour2/branches/3.0@13341 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/audioengine.h7
-rw-r--r--libs/ardour/ardour/session.h9
-rw-r--r--libs/ardour/audioengine.cc56
-rw-r--r--libs/ardour/session.cc68
-rw-r--r--libs/ardour/session_state.cc14
5 files changed, 90 insertions, 64 deletions
diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h
index a908cf0bc1..165ad6744f 100644
--- a/libs/ardour/ardour/audioengine.h
+++ b/libs/ardour/ardour/audioengine.h
@@ -260,9 +260,6 @@ _ the regular process() call to session->process() is not made.
int create_process_thread (boost::function<void()>, pthread_t*, size_t stacksize);
- boost::shared_ptr<Port> ltc_input_port() const { return _ltc_input; }
- boost::shared_ptr<Port> ltc_output_port() const { return _ltc_output; }
-
private:
static AudioEngine* _instance;
@@ -292,10 +289,6 @@ private:
Glib::Threads::Thread* m_meter_thread;
ProcessThread* _main_thread;
- boost::shared_ptr<Port> _ltc_input;
- boost::shared_ptr<Port> _ltc_output;
- void reconnect_ltc ();
-
SerializedRCUManager<Ports> ports;
boost::shared_ptr<Port> register_port (DataType type, const std::string& portname, bool input);
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 2f9c114c0c..e3376ae45f 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -847,6 +847,9 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
/** Emitted when the session wants Ardour to quit */
static PBD::Signal0<void> Quit;
+ boost::shared_ptr<Port> ltc_input_port() const;
+ boost::shared_ptr<Port> ltc_output_port() const;
+
protected:
friend class AudioEngine;
void set_block_size (pframes_t nframes);
@@ -1554,6 +1557,12 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
bool ignore_route_processor_changes;
MidiClockTicker* midi_clock;
+
+ boost::shared_ptr<IO> _ltc_input;
+ boost::shared_ptr<IO> _ltc_output;
+
+ void reconnect_ltc_input ();
+ void reconnect_ltc_output ();
};
} // namespace ARDOUR
diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc
index ef3899bf2f..2c57949074 100644
--- a/libs/ardour/audioengine.cc
+++ b/libs/ardour/audioengine.cc
@@ -78,8 +78,6 @@ AudioEngine::AudioEngine (string client_name, string session_uuid)
, port_remove_in_progress (false)
, m_meter_thread (0)
, _main_thread (0)
- , _ltc_input ()
- , _ltc_output ()
, ports (new Ports)
{
_instance = this; /* singleton */
@@ -91,34 +89,11 @@ AudioEngine::AudioEngine (string client_name, string session_uuid)
}
Port::set_engine (this);
-
-#ifdef HAVE_LTC
- _ltc_input = register_port (DataType::AUDIO, _("LTC in"), true);
-
- /* register_port() would allocate buffers and pass a shadow copy
- * which is subject to ardour's route buffering behavioud and
- * not suitable for generating LTC independent of transport state.
- */
- _ltc_output.reset(new AudioPort ("LTC out", Port::IsOutput));
-
- /* 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 ();
-#ifdef HAVE_LTC
- if (_ltc_output && _ltc_output->jack_port()) {
- jack_port_disconnect (_jack, _ltc_output->jack_port());
- }
-#endif
{
Glib::Threads::Mutex::Lock tm (_process_lock);
@@ -234,9 +209,6 @@ AudioEngine::start ()
_running = true;
_has_run = true;
Running(); /* EMIT SIGNAL */
-
- reconnect_ltc ();
-
} else {
// error << _("cannot activate JACK client") << endmsg;
}
@@ -1513,8 +1485,6 @@ AudioEngine::reconnect_to_jack ()
MIDI::Manager::instance()->reconnect ();
- reconnect_ltc ();
-
Running (); /* EMIT SIGNAL*/
start_metering_thread ();
@@ -1659,29 +1629,3 @@ AudioEngine::destroy ()
_instance = 0;
}
-void
-AudioEngine::parameter_changed (const std::string& s)
-{
- if (s == "ltc-source-port") {
- reconnect_ltc ();
- }
- else if (s == "ltc-sink-port") {
- // TODO
- }
-
-}
-
-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);
- }
- }
-}
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 8c36f95726..c335e021aa 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -145,7 +145,6 @@ Session::Session (AudioEngine &eng,
, _bundles (new BundleList)
, _bundle_xml_node (0)
, _current_trans (0)
- , _click_io ((IO*) 0)
, click_data (0)
, click_emphasis_data (0)
, main_outs (0)
@@ -371,7 +370,30 @@ Session::when_engine_running ()
try {
XMLNode* child = 0;
+
+ _ltc_input.reset (new IO (*this, _("LTC In"), IO::Input));
+ _ltc_output.reset (new IO (*this, _("LTC Out"), IO::Output));
+
+ if (state_tree && (child = find_named_node (*state_tree->root(), "LTC-In")) != 0) {
+ _ltc_input->set_state (*(child->children().front()), Stateful::loading_state_version);
+ } else {
+ {
+ Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
+ _ltc_input->ensure_io (ChanCount (DataType::AUDIO, 1), true, this);
+ }
+ reconnect_ltc_input ();
+ }
+ if (state_tree && (child = find_named_node (*state_tree->root(), "LTC-Out")) != 0) {
+ _ltc_output->set_state (*(child->children().front()), Stateful::loading_state_version);
+ } else {
+ {
+ Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
+ _ltc_output->ensure_io (ChanCount (DataType::AUDIO, 1), true, this);
+ }
+ reconnect_ltc_output ();
+ }
+
_click_io.reset (new ClickIO (*this, "click"));
_click_gain.reset (new Amp (*this));
_click_gain->activate ();
@@ -4740,3 +4762,47 @@ Session::operation_in_progress (GQuark op) const
{
return (find (_current_trans_quarks.begin(), _current_trans_quarks.end(), op) != _current_trans_quarks.end());
}
+
+boost::shared_ptr<Port>
+Session::ltc_input_port () const
+{
+ return _ltc_input->nth (0);
+}
+
+boost::shared_ptr<Port>
+Session::ltc_output_port () const
+{
+ return _ltc_output->nth (0);
+}
+
+void
+Session::reconnect_ltc_input ()
+{
+ if (_ltc_input) {
+
+ string src = Config->get_ltc_source_port();
+
+ _ltc_input->disconnect (this);
+
+ if (src != _("None") && !src.empty()) {
+ _ltc_input->nth (0)->connect (src);
+ }
+ }
+}
+
+void
+Session::reconnect_ltc_output ()
+{
+ if (_ltc_output) {
+
+#if 0
+ string src = Config->get_ltc_sink_port();
+
+ _ltc_output->disconnect (this);
+
+ if (src != _("None") && !src.empty()) {
+ _ltc_output->nth (0)->connect (src);
+ }
+#endif
+ }
+}
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index 8cf58a7793..1a566ec20e 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -1161,6 +1161,16 @@ Session::state (bool full_state)
gain_child->add_child_nocopy (_click_gain->state (full_state));
}
+ if (_ltc_input) {
+ XMLNode* ltc_input_child = node->add_child ("LTC-In");
+ ltc_input_child->add_child_nocopy (_ltc_input->state (full_state));
+ }
+
+ if (_ltc_input) {
+ XMLNode* ltc_output_child = node->add_child ("LTC-Out");
+ ltc_output_child->add_child_nocopy (_ltc_output->state (full_state));
+ }
+
node->add_child_nocopy (_speakers->get_state());
node->add_child_nocopy (_tempo_map->get_state());
node->add_child_nocopy (get_control_protocol_state());
@@ -3551,6 +3561,10 @@ Session::config_changed (std::string p, bool ours)
AudioSource::allocate_working_buffers (frame_rate());
} else if (p == "automation-thinning-factor") {
Evoral::ControlList::set_thinning_factor (Config->get_automation_thinning_factor());
+ } else if (p == "ltc-source-port") {
+ reconnect_ltc_input ();
+ } else if (p == "ltc-sink-port") {
+ reconnect_ltc_output ();
}
set_dirty ();