shithub: drawterm-fdroid

ref: 01dc1e2c37938eea4226ac299dc518bfab6ef0c0
dir: /kern/devaudio-sndio.c/

View raw version
#include	<sndio.h>

#include	"u.h"
#include	"lib.h"
#include	"dat.h"
#include	"fns.h"
#include	"error.h"
#include	"devaudio.h"

enum
{
	Channels = 2,
	Rate = 44100,
	Bits = 16,
};

static struct sio_hdl *hdl;
static struct sio_par par;

void
audiodevopen(void)
{
	hdl = sio_open(NULL, SIO_PLAY, 0);
	if(hdl == NULL)
		return;

	sio_initpar(&par);

	par.bits = Bits;
	par.pchan = Channels;
	par.rate = Rate;
	par.appbufsz = 288000;

	if(!sio_setpar(hdl, &par) || !sio_start(hdl)){
		sio_close(hdl);
		return;
	}
}

void
audiodevclose(void)
{
	sio_close(hdl);
}

void
audiodevsetvol(int what, int left, int right)
{
	USED(what);
	USED(left);
	USED(right);
	error("not supported");
}

void
audiodevgetvol(int what, int *left, int *right)
{
	USED(what);
	USED(left);
	USED(right);
	error("not supported");
}

int
audiodevwrite(void *v, int n)
{
	return sio_write(hdl, v, n);
}

int
audiodevread(void *v, int n)
{
	error("no reading");
	return -1;
}