~ft/npe

85aac117f40895565f61eb703055a29df3c7539f — Sigrid Solveig Haflínudóttir 7 months ago b699be1
sdl/audio: set pipe buffer size when running pcmconv; use the correct device name
1 files changed, 12 insertions(+), 1 deletions(-)

M libnpe_sdl2/audio.c
M libnpe_sdl2/audio.c => libnpe_sdl2/audio.c +12 -1
@@ 144,6 144,16 @@ convspec(SDL_AudioSpec *s, char *spec, int n)
	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 @@ SDL_OpenAudioDevice(char *dev, int rec, SDL_AudioSpec *want, SDL_AudioSpec *have
		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 @@ SDL_OpenAudioDevice(char *dev, int rec, SDL_AudioSpec *want, SDL_AudioSpec *have
		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;