ref: 85aac117f40895565f61eb703055a29df3c7539f
parent: b699be1156cb41be910dadb3c8a6df0bea12bf67
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Mon Oct 2 13:44:40 EDT 2023
sdl/audio: set pipe buffer size when running pcmconv; use the correct device name
--- a/libnpe_sdl2/audio.c
+++ b/libnpe_sdl2/audio.c
@@ -144,6 +144,16 @@
return ssz;
}
+static void
+setpipebuf(int f, int sz)
+{
+ Dir d;
+
+ nulldir(&d);
+ d.length = sz;
+ dirfwstat(f, &d);
+}
+
SDL_AudioDeviceID
SDL_OpenAudioDevice(char *dev, int rec, SDL_AudioSpec *want, SDL_AudioSpec *have, u32int change)
{
@@ -196,6 +206,7 @@
if((fd = open(a->name, a->mode)) < 0)
goto err;
pipe(p);
+ setpipebuf(p[0], a->bufsz);
if((a->pidconv = rfork(RFPROC|RFNOTEG|RFFDG|RFCENVG)) == 0){
dup(fd, rec ? 0 : 1); close(fd);
dup(p[0], rec ? 1 : 0); close(p[0]);
@@ -211,7 +222,7 @@
a->fd = p[1];
close(p[0]);
close(fd);
- }else if(a->fd < 0 && (a->fd = open("/dev/audio", a->mode|OCEXEC)) < 0)
+ }else if(a->fd < 0 && (a->fd = open(a->name, a->mode|OCEXEC)) < 0)
goto err;
return id;