ref: 280f1defcfb292bc604825da676b889360f63649
parent: 1f34ec67713bd4d835dd2c9ae784a084f2b81b78
author: qwx <qwx@sciops.net>
date: Wed Nov 16 13:05:17 EST 2022
increase chunk size and avoid oob on static buffer for drawsamp
--- a/dat.h
+++ b/dat.h
@@ -8,7 +8,7 @@
WriteDelay = Rate / WriteRate, /* 1764 default delay */
Sampsz = 2 * 2,
Outsz = WriteDelay * Sampsz,
- Iochunksz = 1*1024*1024, /* ≈ 6 sec. at 44.1 kHz */
+ Iochunksz = 4*1024*1024, /* ≈ 24 sec. at 44.1 kHz */
Ioreadsz = Iochunksz / 32,
};
struct Chunk{
--- a/draw.c
+++ b/draw.c
@@ -19,7 +19,8 @@
static int bgscalyl, bgscalyr, bgscalf;
static Channel *drawc;
static usize T;
-static uchar sbuf[Iochunksz];
+static uchar *sbuf;
+static usize sbufsz;
static Image *
eallocimage(Rectangle r, int repl, ulong col)
@@ -45,6 +46,10 @@
end:
recvul(drawc);
again:
+ if(sbufsz < T){
+ sbuf = erealloc(sbuf, T, sbufsz);
+ sbufsz = T;
+ }
lockdisplay(display);
draw(viewbg, viewbg->r, display->black, nil, ZP);
unlockdisplay(display);