mirror of https://github.com/ericonr/sndio.git
sndiod: Make play-only and rec-only start at the same position
This is necessary to make rec-only device properly work in full-duplex. Fixes full-duplex clients stuck on rec-only device.
This commit is contained in:
parent
5a20439ec8
commit
9a5092b08e
16
sndiod/dev.c
16
sndiod/dev.c
|
@ -42,7 +42,6 @@ void dev_sub_bcopy(struct dev *, struct slot *);
|
|||
void dev_onmove(struct dev *, int);
|
||||
void dev_master(struct dev *, unsigned int);
|
||||
void dev_cycle(struct dev *);
|
||||
int dev_getpos(struct dev *);
|
||||
struct dev *dev_new(char *, struct aparams *, unsigned int, unsigned int,
|
||||
unsigned int, unsigned int, unsigned int, unsigned int);
|
||||
void dev_adjpar(struct dev *, int, int, int);
|
||||
|
@ -302,7 +301,7 @@ mtc_midi_full(struct mtc *mtc)
|
|||
struct sysex x;
|
||||
unsigned int fps;
|
||||
|
||||
mtc->delta = MTC_SEC * dev_getpos(mtc->dev);
|
||||
mtc->delta = -MTC_SEC * (int)mtc->dev->bufsz;
|
||||
if (mtc->dev->rate % (30 * 4 * mtc->dev->round) == 0) {
|
||||
mtc->fps_id = MTC_FPS_30;
|
||||
mtc->fps = 30;
|
||||
|
@ -900,15 +899,6 @@ dev_master(struct dev *d, unsigned int master)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* return the latency that a stream would have if it's attached
|
||||
*/
|
||||
int
|
||||
dev_getpos(struct dev *d)
|
||||
{
|
||||
return (d->mode & MODE_PLAY) ? -d->bufsz : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a sndio device
|
||||
*/
|
||||
|
@ -2009,7 +1999,7 @@ slot_start(struct slot *s)
|
|||
/*
|
||||
* N-th recorded block is the N-th played block
|
||||
*/
|
||||
s->sub.prime = -dev_getpos(d) / d->round;
|
||||
s->sub.prime = d->bufsz / d->round;
|
||||
}
|
||||
s->skip = 0;
|
||||
|
||||
|
@ -2017,7 +2007,7 @@ slot_start(struct slot *s)
|
|||
* get the current position, the origin is when the first sample
|
||||
* played and/or recorded
|
||||
*/
|
||||
s->delta = dev_getpos(d) * (int)s->round / (int)d->round;
|
||||
s->delta = -(long long)d->bufsz * s->round / d->round;
|
||||
s->delta_rem = 0;
|
||||
|
||||
if (s->mode & MODE_PLAY) {
|
||||
|
|
Loading…
Reference in New Issue