Logo Search packages:      
Sourcecode: patchage version File versions  Download package

void JackDriver::refresh (  ) 

Refresh all Jack audio ports/connections.

This is to be called from Patchage/PatchBayArea, not from JackDriver.

Definition at line 83 of file JackDriver.cpp.

{
      const char** ports;
      jack_port_t* port;
      
      ports = jack_get_ports(m_client, NULL, NULL, 0); // get all existing ports

      m_patch_bay->destroy();

      string client1_name;
      string port1_name;
      string client2_name;
      string port2_name;
      PatchageModule* m = NULL;
      
      // Add all ports
      if (ports != NULL)
      for (int i=0; ports[i]; ++i) {
            port = jack_port_by_name(m_client, ports[i]);
            client1_name = ports[i];
            client1_name = client1_name.substr(0, client1_name.find(":"));

            ModuleType type = InputOutput;
            if (jack_port_flags(port) & JackPortIsTerminal) {
                  if (jack_port_flags(port) & JackPortIsInput) {
                        type = Input;
                  } else {
                        type = Output;
                  }
            }

            m = (PatchageModule*)m_patch_bay->find_module(client1_name, type);

            if (m == NULL) {
                  m = new PatchageModule(m_app, client1_name, type);
                  m->load_location();
                  m->store_location();
                  m_patch_bay->add_module(m);
            }
            
            m->add_patchage_port(jack_port_short_name(port),
                  (jack_port_flags(port) & JackPortIsInput),
                  JACK);
      }
      
      // Add all connections
      if (ports != NULL) {
            for (int i=0; ports[i]; ++i) {
                  port = jack_port_by_name(m_client, ports[i]);
                  const char** connected_ports = jack_port_get_all_connections(m_client, port);
                  
                  if (connected_ports != NULL)
                  for (int j=0; connected_ports[j]; ++j) {
                        client1_name = ports[i];
                        port1_name = client1_name.substr(client1_name.find(':')+1);
                        client1_name = client1_name.substr(0, client1_name.find(':'));
                        
                        client2_name = connected_ports[j];
                        port2_name = client2_name.substr(client2_name.find(':')+1);
                        client2_name = client2_name.substr(0, client2_name.find(':'));
                        
                        m_patch_bay->add_connection(client1_name, port1_name, client2_name, port2_name);
                  }
                  free(connected_ports);
            }           
            free(ports);
      }
}


Generated by  Doxygen 1.6.0   Back to index