Lines Matching refs:port

38 	usbmidi_port_info* port = NULL;
41 port = (usbmidi_port_info*)malloc(sizeof(usbmidi_port_info));
42 if (port == NULL)
45 sprintf(port->name, "%s-%d", devinfo->name, cable);
46 port->device = devinfo;
47 port->cable = cable;
48 port->next = NULL;
49 port->open = 0;
50 port->open_fd = NULL;
51 port->has_in = has_in;
52 port->has_out = has_out;
53 port->rbuf = create_ring_buffer(1024);
55 devinfo->ports[cable] = port;
57 DPRINTF_INFO((MY_ID "Created port %p cable %d: %s\n",
58 port, cable, port->name));
60 return port;
65 remove_port(usbmidi_port_info* port)
67 assert(port != NULL);
68 if (port->rbuf != NULL) {
69 delete_ring_buffer(port->rbuf);
70 port->rbuf = NULL;
72 DPRINTF_INFO((MY_ID "remove_port %p done\n", port));
74 free(port);
158 /* driver cookie (per open -- but only one open per port allowed!) */
164 usbmidi_port_info* port;
210 usbmidi_port_info* port = midiDevice->ports[packet->cn];
212 /* port matching 'cable number' */
213 if (port == NULL) {
214 DPRINTF_ERR((MY_ID "no port matching cable number %d!\n",
216 } else if (port->open_fd == NULL) {
217 DPRINTF_ERR((MY_ID "received data for port %d but it is closed!\n",
220 ring_buffer_write(port->rbuf, packet->midi, pktlen);
221 release_sem_etc(port->open_fd->sem_cb, pktlen,
262 usbmidi_port_info* port = midiDevice->ports[cable];
263 if (port == NULL)
265 if (port->open_fd != NULL)
266 delete_sem(port->open_fd->sem_cb);
421 usbmidi_port_info* port;
423 port = create_usbmidi_port(midiDevice, i,
425 midiDevice->ports[i] = port;
430 add_port_info(port);
462 usbmidi_port_info* port = midiDevice->ports[cable];
463 if (port == NULL)
466 DPRINTF_DEBUG((MY_ID "removing port %d\n", cable));
467 remove_port_info(port);
468 if (port->open_fd != NULL) {
469 port->open_fd->port = NULL;
470 port->open_fd->device = NULL;
471 delete_sem(port->open_fd->sem_cb);
474 remove_port(port);
514 usbmidi_port_info* port;
522 if ((port = search_port_info(name)) == NULL)
525 if (!port->has_in && mode != O_WRONLY)
527 else if (!port->has_out && mode != O_RDONLY)
541 cookie->port = port;
542 cookie->device = port->device;
545 if (port->open_fd != NULL) {
552 port->open_fd = cookie;
553 port->open++;
558 name, port->open));
569 usbmidi_port_info* port = cookie->port;
593 ring_buffer_user_read(port->rbuf, (uint8*)buf, 1);
640 usbmidi_port_info* port = cookie->port;
681 pkt->cn = port->cable;
725 usbmidi_port_info* port = cookie->port;
728 DPRINTF_INFO((MY_ID "usb_midi_close(%p device=%p port=%p)\n",
729 cookie, midiDevice, port));
732 if (port != NULL) {
733 /* detach the cookie from port */
734 port->open_fd = NULL;
735 --port->open;