version 1.80, 2021/01/28 11:06:58 |
version 1.81, 2021/01/28 11:10:00 |
|
|
void |
void |
slot_start(struct slot *s) |
slot_start(struct slot *s) |
{ |
{ |
|
struct dev *d = s->dev; |
#ifdef DEBUG |
#ifdef DEBUG |
if (s->pstate != SLOT_INIT) { |
if (s->pstate != SLOT_INIT) { |
slot_log(s); |
slot_log(s); |
|
|
log_puts(": playing "); |
log_puts(": playing "); |
aparams_log(&s->par); |
aparams_log(&s->par); |
log_puts(" -> "); |
log_puts(" -> "); |
aparams_log(&s->dev->par); |
aparams_log(&d->par); |
log_puts("\n"); |
log_puts("\n"); |
} |
} |
} |
} |
|
|
log_puts(": recording "); |
log_puts(": recording "); |
aparams_log(&s->par); |
aparams_log(&s->par); |
log_puts(" <- "); |
log_puts(" <- "); |
aparams_log(&s->dev->par); |
aparams_log(&d->par); |
log_puts("\n"); |
log_puts("\n"); |
} |
} |
} |
} |
|
|
/* |
/* |
* N-th recorded block is the N-th played block |
* N-th recorded block is the N-th played block |
*/ |
*/ |
s->sub.prime = -dev_getpos(s->dev) / s->dev->round; |
s->sub.prime = -dev_getpos(d) / d->round; |
} |
} |
s->skip = 0; |
s->skip = 0; |
|
|
|
|
* get the current position, the origin is when the first sample |
* get the current position, the origin is when the first sample |
* played and/or recorded |
* played and/or recorded |
*/ |
*/ |
s->delta = dev_getpos(s->dev) * (int)s->round / (int)s->dev->round; |
s->delta = dev_getpos(d) * (int)s->round / (int)d->round; |
s->delta_rem = 0; |
s->delta_rem = 0; |
|
|
if (s->mode & MODE_PLAY) { |
if (s->mode & MODE_PLAY) { |
|
|
slot_detach(struct slot *s) |
slot_detach(struct slot *s) |
{ |
{ |
struct slot **ps; |
struct slot **ps; |
struct dev *d; |
struct dev *d = s->dev; |
long long pos; |
long long pos; |
|
|
|
for (ps = &d->slot_list; *ps != s; ps = &(*ps)->next) { |
#ifdef DEBUG |
#ifdef DEBUG |
if (log_level >= 3) { |
|
slot_log(s); |
|
log_puts(": detaching\n"); |
|
} |
|
#endif |
|
for (ps = &s->dev->slot_list; *ps != s; ps = &(*ps)->next) { |
|
#ifdef DEBUG |
|
if (*ps == NULL) { |
if (*ps == NULL) { |
slot_log(s); |
slot_log(s); |
log_puts(": can't detach, not on list\n"); |
log_puts(": can't detach, not on list\n"); |
|
|
} |
} |
*ps = s->next; |
*ps = s->next; |
|
|
d = s->dev; |
|
|
|
/* |
/* |
* adjust clock, go back d->delta ticks so that slot_attach() |
* adjust clock, go back d->delta ticks so that slot_attach() |
* could be called with the resulting state |
* could be called with the resulting state |
|
|
} |
} |
#endif |
#endif |
if (s->mode & MODE_PLAY) |
if (s->mode & MODE_PLAY) |
dev_mix_adjvol(s->dev); |
dev_mix_adjvol(d); |
} |
} |
|
|
/* |
/* |