Page MenuHomeFreeBSD

D59444.id185920.diff
No OneTemporary

D59444.id185920.diff

diff --git a/sys/dev/sound/pci/emu10kx-pcm.c b/sys/dev/sound/pci/emu10kx-pcm.c
--- a/sys/dev/sound/pci/emu10kx-pcm.c
+++ b/sys/dev/sound/pci/emu10kx-pcm.c
@@ -768,13 +768,30 @@
{
struct emu_pcm_pchinfo *ch = c_devinfo;
struct emu_pcm_info *sc = ch->pcm;
+ uint32_t blkcnt;
+
+ /*
+ * The channel always plays the whole EMU_PLAY_BUFSZ buffer, so the
+ * blocks have to cover it exactly, or the part they do not cover is
+ * "played" without ever being written to.
+ *
+ * sndbuf_resize() needs at least two blocks, so a block can be at most
+ * half the buffer's size. The block count has to be a power of two as
+ * well, because only then does the division come out exact.
+ */
+ if (blocksize == 0 || blocksize > EMU_PLAY_BUFSZ / 2)
+ blocksize = EMU_PLAY_BUFSZ / 2;
+ blkcnt = 1 << (fls(EMU_PLAY_BUFSZ / blocksize) - 1);
+ blocksize = EMU_PLAY_BUFSZ / blkcnt;
+
+ if (sndbuf_resize(ch->buffer, blkcnt, blocksize) != 0)
+ return (ch->blksz);
- if (blocksize > ch->pcm->bufsz)
- blocksize = ch->pcm->bufsz;
mtx_lock(&sc->lock);
ch->blksz = blocksize;
emu_timer_set(sc->card, ch->timer, ch->blksz / ch->buffer->align);
mtx_unlock(&sc->lock);
+
return (ch->blksz);
}

File Metadata

Mime Type
text/plain
Expires
Thu, Sep 10, 1:51 PM (17 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38416192
Default Alt Text
D59444.id185920.diff (1 KB)

Event Timeline