On Sun, Sep 08, 2019 at 08:19:18PM +0100, Joe Davis wrote:
> >
> > fwiw my X1 gen2 works fine with that snap.
> >
> > The hardware is quite different though and I'm on a considerably older
> > bios...
> >
>
> Well, this is embarassing. I discovered that I had a quite large buffer
> size:
>
> sndiod_flags=-b 24000
>
You found a real bug, I reproduced it and the the fix is below. Could
you confirm this works for you?
Index: audio.c
===================================================================
RCS file: /cvs/src/sys/dev/audio.c,v
retrieving revision 1.181
diff -u -p -u -p -r1.181 audio.c
--- audio.c 5 Sep 2019 05:33:57 -0000 1.181
+++ audio.c 9 Sep 2019 15:37:19 -0000
@@ -657,8 +657,23 @@ audio_setpar_blksz(struct audio_softc *s
unsigned int blk_mult, blk_max;
if (sc->ops->set_blksz) {
+ /*
+ * Don't allow block size to exceed half the buffer size
+ */
+ if (sc->mode & AUMODE_PLAY) {
+ max = sc->play.datalen / 2 / (sc->pchan * sc->bps);
+ if (sc->round > max)
+ sc->round = max;
+ }
+ if (sc->mode & AUMODE_RECORD) {
+ max = sc->rec.datalen / 2 / (sc->rchan * sc->bps);
+ if (sc->round > max)
+ sc->round = max;
+ }
+
sc->round = sc->ops->set_blksz(sc->arg, sc->mode,
p, r, sc->round);
+
DPRINTF("%s: block size set to: %u\n", DEVNAME(sc), sc->round);
return 0;
}
Index: pci/azalia.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/azalia.c,v
retrieving revision 1.251
diff -u -p -u -p -r1.251 azalia.c
--- pci/azalia.c 5 Sep 2019 05:36:31 -0000 1.251
+++ pci/azalia.c 9 Sep 2019 15:37:21 -0000
@@ -3978,8 +3978,9 @@ azalia_set_blksz(void *v, int mode,
/* must be multiple of 128 bytes */
mult = audio_blksz_bytes(mode, p, r, 128);
- blksz += mult - 1;
blksz -= blksz % mult;
+ if (blksz == 0)
+ blksz = mult;
return blksz;
}