PBD::canonical_path will no longer throw so change test
[ardour.git] / libs / ardour / port_manager.cc
index 874d36d8828ae19730fa968046d25449aa490f22..10c19a9c67547f4cd07aecbdec4f05185a06e50e 100644 (file)
@@ -28,8 +28,9 @@
 #include "ardour/midiport_manager.h"
 #include "ardour/port_manager.h"
 #include "ardour/profile.h"
+#include "ardour/session.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace ARDOUR;
 using namespace PBD;
@@ -158,6 +159,7 @@ void
 PortManager::get_physical_outputs (DataType type, std::vector<std::string>& s)
 {
        if (!_backend) {
+               s.clear ();
                return;
        }
        _backend->get_physical_outputs (type, s);
@@ -167,6 +169,7 @@ void
 PortManager::get_physical_inputs (DataType type, std::vector<std::string>& s)
 {
        if (!_backend) {
+               s.clear ();
                return;
        }
 
@@ -350,6 +353,12 @@ PortManager::register_output_port (DataType type, const string& portname, bool a
 int
 PortManager::unregister_port (boost::shared_ptr<Port> port)
 {
+       /* This is a little subtle. We do not call the backend's port
+        * unregistration code from here. That is left for the Port
+        * destructor. We are trying to drop references to the Port object
+        * here, so that its destructor will run and it will unregister itself.
+        */
+
        /* caller must hold process lock */
 
        {
@@ -385,6 +394,40 @@ PortManager::connected (const string& port_name)
        return _backend->connected (handle);
 }
 
+bool
+PortManager::physically_connected (const string& port_name)
+{
+       if (!_backend) {
+               return false;
+       }
+
+       PortEngine::PortHandle handle = _backend->get_port_by_name (port_name);
+
+       if (!handle) {
+               return false;
+       }
+
+       return _backend->physically_connected (handle);
+}
+
+int
+PortManager::get_connections (const string& port_name, std::vector<std::string>& s)
+{
+       if (!_backend) {
+               s.clear ();
+               return 0;
+       }
+
+       PortEngine::PortHandle handle = _backend->get_port_by_name (port_name);
+
+       if (!handle) {
+               s.clear ();
+               return 0;
+       }
+
+       return _backend->get_connections (handle, s);
+}
+
 int
 PortManager::connect (const string& source, const string& destination)
 {
@@ -629,9 +672,18 @@ PortManager::cycle_end (pframes_t nframes)
 }
 
 void
-PortManager::silence (pframes_t nframes)
+PortManager::silence (pframes_t nframes, Session *s)
 {
        for (Ports::iterator i = _cycle_ports->begin(); i != _cycle_ports->end(); ++i) {
+               if (s && i->second == s->mtc_output_port ()) {
+                       continue;
+               }
+               if (s && i->second == s->midi_clock_output_port ()) {
+                       continue;
+               }
+               if (s && i->second == s->ltc_output_port ()) {
+                       continue;
+               }
                if (i->second->sends_output()) {
                        i->second->get_buffer(nframes).silence(nframes);
                }