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

bool AlsaDriver::connect ( const PatchagePort *const   src_port,
const PatchagePort *const   dst_port 
)

Connects two Alsa Midi ports.

Returns:
Whether connection succeeded.

Definition at line 288 of file AlsaDriver.cpp.

References PatchagePort::alsa_addr().

{
      const snd_seq_addr_t* src = src_port->alsa_addr();
      const snd_seq_addr_t* dst = dst_port->alsa_addr();
      
      bool result = false;
      pthread_mutex_lock(m_refresh_mutex);

      snd_seq_port_subscribe_t* subs;
      snd_seq_port_subscribe_malloc(&subs);
      snd_seq_port_subscribe_set_sender(subs, src);
      snd_seq_port_subscribe_set_dest(subs, dst);
      snd_seq_port_subscribe_set_exclusive(subs, 0);
      snd_seq_port_subscribe_set_time_update(subs, 0);
      snd_seq_port_subscribe_set_time_real(subs, 0);

      // Already connected (shouldn't happen)
      if (!snd_seq_get_port_subscription(m_seq, subs)) {
            cerr << "Error: Attempt to subscribe Alsa ports that are already subscribed." << endl;
            result = false;
      }
      
      int ret = snd_seq_subscribe_port(m_seq, subs);
      if (ret < 0) {
            cerr << "Alsa subscription failed: " << snd_strerror(ret) << endl;
            result = false;
      }

      pthread_mutex_unlock(m_refresh_mutex);
      return (!result);
}


Generated by  Doxygen 1.6.0   Back to index