mirror of https://github.com/ericonr/sndio.git
add port numbers
This commit is contained in:
parent
d4cea96993
commit
c8a50a21ea
|
@ -427,18 +427,16 @@ port_exit(void *arg)
|
||||||
struct port *
|
struct port *
|
||||||
port_new(char *path, unsigned int mode, int hold)
|
port_new(char *path, unsigned int mode, int hold)
|
||||||
{
|
{
|
||||||
struct port *c, **pc;
|
struct port *c;
|
||||||
|
|
||||||
c = xmalloc(sizeof(struct port));
|
c = xmalloc(sizeof(struct port));
|
||||||
c->path = xstrdup(path);
|
c->path = xstrdup(path);
|
||||||
c->state = PORT_CFG;
|
c->state = PORT_CFG;
|
||||||
c->hold = hold;
|
c->hold = hold;
|
||||||
c->midi = midi_new(&port_midiops, c, mode);
|
c->midi = midi_new(&port_midiops, c, mode);
|
||||||
midi_portnum++;
|
c->num = midi_portnum++;
|
||||||
for (pc = &port_list; *pc != NULL; pc = &(*pc)->next)
|
c->next = port_list;
|
||||||
; /* nothing */
|
port_list = c;
|
||||||
c->next = NULL;
|
|
||||||
*pc = c;
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -504,7 +502,7 @@ port_bynum(int num)
|
||||||
struct port *p;
|
struct port *p;
|
||||||
|
|
||||||
for (p = port_list; p != NULL; p = p->next) {
|
for (p = port_list; p != NULL; p = p->next) {
|
||||||
if (num-- == 0)
|
if (p->num == num)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -87,6 +87,7 @@ struct port {
|
||||||
#define PORT_INIT 1
|
#define PORT_INIT 1
|
||||||
#define PORT_DRAIN 2
|
#define PORT_DRAIN 2
|
||||||
unsigned int state;
|
unsigned int state;
|
||||||
|
unsigned int num; /* port serial number */
|
||||||
char *path; /* hold the port open ? */
|
char *path; /* hold the port open ? */
|
||||||
int hold;
|
int hold;
|
||||||
struct midi *midi;
|
struct midi *midi;
|
||||||
|
|
Loading…
Reference in New Issue