version 1.65, 2012/10/27 11:54:27 |
version 1.66, 2012/11/02 10:24:58 |
|
|
f->xrun = XRUN_IGNORE; |
f->xrun = XRUN_IGNORE; |
f->delta = 0; |
f->delta = 0; |
f->tickpending = 0; |
f->tickpending = 0; |
f->startpos = 0; |
f->fillpending = 0; |
f->startpending = 0; |
|
f->vol = f->lastvol = MIDI_MAXCTL; |
f->vol = f->lastvol = MIDI_MAXCTL; |
f->slot = -1; |
f->slot = -1; |
|
|
|
|
if (wbuf) |
if (wbuf) |
abuf_hup(wbuf); |
abuf_hup(wbuf); |
f->tickpending = 0; |
f->tickpending = 0; |
f->startpending = 0; |
f->fillpending = 0; |
} |
} |
|
|
/* |
/* |
|
|
f->wmax = 0; |
f->wmax = 0; |
} |
} |
f->delta = 0; |
f->delta = 0; |
f->startpos = 0; |
|
f->tickpending = 0; |
f->tickpending = 0; |
f->startpending = 0; |
f->fillpending = 0; |
#ifdef DEBUG |
#ifdef DEBUG |
if (debug_level >= 3) { |
if (debug_level >= 3) { |
sock_dbg(f); |
sock_dbg(f); |
|
|
* get the current position, the origin is when |
* get the current position, the origin is when |
* the first sample is played/recorded |
* the first sample is played/recorded |
*/ |
*/ |
f->startpos = dev_getpos(f->dev) * (int)f->round / (int)f->dev->round; |
f->delta = dev_getpos(f->dev) * |
f->startpending = 1; |
(int)f->round / (int)f->dev->round; |
|
f->fillpending = 0; |
f->pstate = SOCK_RUN; |
f->pstate = SOCK_RUN; |
#ifdef DEBUG |
#ifdef DEBUG |
if (debug_level >= 3) { |
if (debug_level >= 3) { |
sock_dbg(f); |
sock_dbg(f); |
dbg_puts(": attaching at "); |
dbg_puts(": attaching at "); |
dbg_puti(f->startpos); |
dbg_puti(f->delta); |
dbg_puts("\n"); |
dbg_puts("\n"); |
} |
} |
#endif |
#endif |
|
|
aproc_setin(f->pipe.file.wproc, wbuf); |
aproc_setin(f->pipe.file.wproc, wbuf); |
} |
} |
f->pstate = SOCK_MIDI; |
f->pstate = SOCK_MIDI; |
|
f->fillpending = MIDI_BUFSZ; |
dev_midiattach(f->dev, rbuf, wbuf); |
dev_midiattach(f->dev, rbuf, wbuf); |
} |
} |
|
|
|
|
#endif |
#endif |
if (f->pstate != SOCK_MIDI) |
if (f->pstate != SOCK_MIDI) |
f->rmax -= f->rtodo; |
f->rmax -= f->rtodo; |
|
else |
|
f->fillpending += f->rtodo; |
if (f->rtodo == 0) { |
if (f->rtodo == 0) { |
#ifdef DEBUG |
#ifdef DEBUG |
if (debug_level >= 1) { |
if (debug_level >= 1) { |
|
|
unsigned int size, max; |
unsigned int size, max; |
|
|
/* |
/* |
* Send initial position |
* If pos changed, build a MOVE message. |
*/ |
*/ |
if (f->startpending) { |
if (f->tickpending && f->delta >= 0) { |
#ifdef DEBUG |
#ifdef DEBUG |
if (debug_level >= 4) { |
if (debug_level >= 4) { |
sock_dbg(f); |
sock_dbg(f); |
dbg_puts(": building POS message, pos = "); |
dbg_puts(": building MOVE message, delta = "); |
dbg_puti(f->startpos); |
dbg_puti(f->delta); |
dbg_puts("\n"); |
dbg_puts("\n"); |
} |
} |
#endif |
#endif |
AMSG_INIT(&f->wmsg); |
AMSG_INIT(&f->wmsg); |
f->wmsg.cmd = htonl(AMSG_POS); |
f->wmsg.cmd = htonl(AMSG_MOVE); |
f->wmsg.u.ts.delta = htonl(f->startpos); |
f->wmsg.u.ts.delta = htonl(f->delta); |
f->rmax += f->startpos; |
|
f->wtodo = sizeof(struct amsg); |
f->wtodo = sizeof(struct amsg); |
f->wstate = SOCK_WMSG; |
f->wstate = SOCK_WMSG; |
f->startpending = 0; |
f->wmax += f->delta; |
|
f->fillpending += f->delta; |
|
f->delta = 0; |
|
f->tickpending = 0; |
return 1; |
return 1; |
} |
} |
|
|
/* |
if (f->fillpending > 0) { |
* If pos changed, build a MOVE message. |
|
*/ |
|
if (f->tickpending) { |
|
#ifdef DEBUG |
#ifdef DEBUG |
if (debug_level >= 4) { |
if (debug_level >= 4) { |
sock_dbg(f); |
sock_dbg(f); |
dbg_puts(": building MOVE message, delta = "); |
dbg_puts(": building FLOWCTL message, count = "); |
dbg_puti(f->delta); |
dbg_puti(f->fillpending); |
dbg_puts("\n"); |
dbg_puts("\n"); |
} |
} |
#endif |
#endif |
f->wmax += f->delta; |
|
f->rmax += f->delta; |
|
AMSG_INIT(&f->wmsg); |
AMSG_INIT(&f->wmsg); |
f->wmsg.cmd = htonl(AMSG_MOVE); |
f->wmsg.cmd = htonl(AMSG_FLOWCTL); |
f->wmsg.u.ts.delta = htonl(f->delta); |
f->wmsg.u.ts.delta = htonl(f->fillpending); |
f->wtodo = sizeof(struct amsg); |
f->wtodo = sizeof(struct amsg); |
f->wstate = SOCK_WMSG; |
f->wstate = SOCK_WMSG; |
f->delta = 0; |
f->rmax += f->fillpending; |
f->tickpending = 0; |
f->fillpending = 0; |
return 1; |
return 1; |
} |
} |
|
|