void JVlibForm::connect_port() { if (seq && strlen(SEQ_dev)) { // create_source_port snd_seq_port_info_t *pinfo; snd_seq_port_info_alloca(&pinfo); // the first created port is 0 anyway, but let's make sure ... snd_seq_port_info_set_port(pinfo, 0); snd_seq_port_info_set_port_specified(pinfo, 1); snd_seq_port_info_set_name(pinfo, "midi_player"); snd_seq_port_info_set_capability(pinfo, 0); snd_seq_port_info_set_type(pinfo, SND_SEQ_PORT_TYPE_MIDI_GENERIC | SND_SEQ_PORT_TYPE_APPLICATION); int err = snd_seq_create_port(seq, pinfo); check_snd("create port", err); ports = (snd_seq_addr_t *)realloc(ports, sizeof(snd_seq_addr_t)); err = snd_seq_parse_address(seq, &ports[0], SEQ_dev); if (err < 0) { QMessageBox::critical(this, "MIDI Player", QString("Invalid port%1\n%2") .arg(SEQ_dev) .arg(snd_strerror(err))); return; } err = snd_seq_connect_to(seq, 0, ports[0].client, ports[0].port); if (err < 0 && err!= -16) QMessageBox::critical(this, "MIDI Player", QString("%4 Cannot connect to port %1:%2 - %3") .arg(ports[0].client) .arg(ports[0].port) .arg(strerror(errno)) .arg(err)); } } // end connect_port
/** call-seq: port = portid Set the port id of a port_info container. Parameters: [port] portid, can be nil to unset the port Setting it will set +port_specified+ to true, but setting it to nil will set +port_specified+ to false. To be used for a port being created */ static VALUE wrap_snd_seq_port_info_set_port(VALUE v_port_info, VALUE v_portnr) { snd_seq_port_info_t *port_info; Data_Get_Struct(v_port_info, snd_seq_port_info_t, port_info); if (NIL_P(v_portnr)) { // fprintf(stderr, "snd_seq_port_info_set_port_specified(%d)\n", 0); snd_seq_port_info_set_port_specified(port_info, 0); } else { snd_seq_port_info_set_port(port_info, NUM2INT(v_portnr)); // fprintf(stderr, "snd_seq_port_info_set_port_specified(%d)\n", 1); snd_seq_port_info_set_port_specified(port_info, 1); } return Qnil; }
/** call-seq: port_specified = bool Set the port-specified mode of a port_info container. This method is not required since setting the port will automatically set it. See RRTS::Driver::AlsaPortInfo_i#port= Parameters: [val] true if specifying the port id at creation. This also seems to be the default. */ static VALUE wrap_snd_seq_port_info_set_port_specified(VALUE v_port_info, VALUE v_bool) { snd_seq_port_info_t *port_info; Data_Get_Struct(v_port_info, snd_seq_port_info_t, port_info); const int b = BOOL2INT(v_bool); // fprintf(stderr, "snd_seq_port_info_set_port_specified(%d)\n", b); snd_seq_port_info_set_port_specified(port_info, b); return Qnil; }