mirror of https://github.com/ericonr/sndio.git
set attach-time delta
This commit is contained in:
parent
28ee95c844
commit
0d773f998a
37
sndiod/dev.c
37
sndiod/dev.c
|
@ -782,10 +782,12 @@ dev_full_cycle(struct dev *d)
|
||||||
unsigned char *base;
|
unsigned char *base;
|
||||||
int nsamp;
|
int nsamp;
|
||||||
|
|
||||||
|
d->delta -= d->round;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (log_level >= 4) {
|
if (log_level >= 4) {
|
||||||
dev_log(d);
|
dev_log(d);
|
||||||
log_puts(": dev_full_cycle");
|
log_puts(": dev_full_cycle: clk=");
|
||||||
|
log_puti(d->delta);
|
||||||
if (d->mode & MODE_PLAY) {
|
if (d->mode & MODE_PLAY) {
|
||||||
log_puts(", poffs = ");
|
log_puts(", poffs = ");
|
||||||
log_puti(d->poffs);
|
log_puti(d->poffs);
|
||||||
|
@ -912,6 +914,12 @@ dev_full_cycle(struct dev *d)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
slot_onmove(struct slot *s, int delta)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* called at every clock tick by the device
|
* called at every clock tick by the device
|
||||||
*/
|
*/
|
||||||
|
@ -921,10 +929,12 @@ dev_onmove(struct dev *d, int delta)
|
||||||
long long pos;
|
long long pos;
|
||||||
struct slot *s, *snext;
|
struct slot *s, *snext;
|
||||||
|
|
||||||
/*
|
d->delta += delta;
|
||||||
* s->ops->onmove() may remove the slot
|
|
||||||
*/
|
|
||||||
for (s = d->slot_list; s != NULL; s = snext) {
|
for (s = d->slot_list; s != NULL; s = snext) {
|
||||||
|
/*
|
||||||
|
* s->ops->onmove() may remove the slot
|
||||||
|
*/
|
||||||
snext = s->next;
|
snext = s->next;
|
||||||
pos = (long long)delta * s->round + s->delta_rem;
|
pos = (long long)delta * s->round + s->delta_rem;
|
||||||
s->delta_rem = pos % d->round;
|
s->delta_rem = pos % d->round;
|
||||||
|
@ -1314,6 +1324,10 @@ dev_wakeup(struct dev *d)
|
||||||
} else {
|
} else {
|
||||||
d->prime = 0;
|
d->prime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* empty cycles don't increment delta */
|
||||||
|
d->delta = 0;
|
||||||
|
|
||||||
d->pstate = DEV_RUN;
|
d->pstate = DEV_RUN;
|
||||||
dev_sio_start(d);
|
dev_sio_start(d);
|
||||||
}
|
}
|
||||||
|
@ -1657,6 +1671,7 @@ slot_attach(struct slot *s)
|
||||||
{
|
{
|
||||||
struct dev *d = s->dev;
|
struct dev *d = s->dev;
|
||||||
unsigned int slot_nch, dev_nch;
|
unsigned int slot_nch, dev_nch;
|
||||||
|
long long pos;
|
||||||
int startpos;
|
int startpos;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1669,14 +1684,22 @@ slot_attach(struct slot *s)
|
||||||
* played and/or recorded
|
* played and/or recorded
|
||||||
*/
|
*/
|
||||||
startpos = dev_getpos(d) * (int)s->round / (int)d->round;
|
startpos = dev_getpos(d) * (int)s->round / (int)d->round;
|
||||||
s->delta = startpos;
|
|
||||||
s->delta_rem = 0;
|
/*
|
||||||
|
* adjust initial clock
|
||||||
|
*/
|
||||||
|
pos = (long long)d->delta * s->round;
|
||||||
|
s->delta = startpos + pos / (int)d->round;
|
||||||
|
s->delta_rem = pos % d->round;
|
||||||
|
|
||||||
s->pstate = SLOT_RUN;
|
s->pstate = SLOT_RUN;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (log_level >= 3) {
|
if (log_level >= 0) {
|
||||||
slot_log(s);
|
slot_log(s);
|
||||||
log_puts(": attached at ");
|
log_puts(": attached at ");
|
||||||
log_puti(startpos);
|
log_puti(startpos);
|
||||||
|
log_puts(", delta = ");
|
||||||
|
log_puti(d->delta);
|
||||||
log_puts("\n");
|
log_puts("\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -128,6 +128,11 @@ struct dev {
|
||||||
struct slot slot[DEV_NSLOT];
|
struct slot slot[DEV_NSLOT];
|
||||||
unsigned int serial; /* for slot allocation */
|
unsigned int serial; /* for slot allocation */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* current position, relative to the current cycle
|
||||||
|
*/
|
||||||
|
int delta;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* desired parameters
|
* desired parameters
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -217,6 +217,9 @@ sock_slot_onmove(void *arg, int delta)
|
||||||
struct sock *f = (struct sock *)arg;
|
struct sock *f = (struct sock *)arg;
|
||||||
struct slot *s = f->slot;
|
struct slot *s = f->slot;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX: remove unused delta argument
|
||||||
|
*/
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (log_level >= 4) {
|
if (log_level >= 4) {
|
||||||
sock_log(f);
|
sock_log(f);
|
||||||
|
|
Loading…
Reference in New Issue