diff -r a57ed3e919ca Make.pulse --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Make.pulse Tue Nov 05 14:02:59 2019 -0600 @@ -0,0 +1,21 @@ +# Linux with pulse audio +PTHREAD=-pthread +AR=ar +AS=as +RANLIB=ranlib +X11=/usr/X11R6 +CC=gcc +CFLAGS=-Wall -Wno-missing-braces -ggdb -I$(ROOT) -I$(ROOT)/include -I$(ROOT)/kern -c -I$(X11)/include -D_THREAD_SAFE $(PTHREAD) -O2 +O=o +OS=posix +GUI=x11 +LDADD=-L$(X11)/lib64 -L$(X11)/lib -lX11 -ggdb -lpulse-simple +LDFLAGS=$(PTHREAD) +TARG=drawterm +AUDIO=pulse + +all: default + +libmachdep.a: + arch=`uname -m|sed 's/i.86/386/;s/Power Macintosh/power/; s/x86_64/amd64/; s/armv[567].*/arm/'`; \ + (cd posix-$$arch && make) diff -r a57ed3e919ca kern/devaudio-pulse.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kern/devaudio-pulse.c Tue Nov 05 14:02:59 2019 -0600 @@ -0,0 +1,64 @@ +/* + * Linux pulse audio support + */ +#include + +#include "u.h" +#include "lib.h" +#include "dat.h" +#include "fns.h" +#include "error.h" +#include "devaudio.h" + + +pa_simple *s = nil; +static const pa_sample_spec ss = { + .format = PA_SAMPLE_S16LE, + .rate = 44100, + .channels = 2 +}; + +/* maybe this should return -1 instead of sysfatal */ +void +audiodevopen(void) +{ + int err; + if (!(s = pa_simple_new(NULL, "drawterm", PA_STREAM_PLAYBACK, NULL, "playback", &ss, NULL, NULL, &err))) + oserror(); +} + +void +audiodevclose(void) +{ + if(s) + pa_simple_free(s); +} + +int +audiodevread(void *a, int n) +{ + error("no read support"); + return -1; +} + +int +audiodevwrite(void *a, int n) +{ + int err; + if(pa_simple_write(s, a, n, &err) < 0) + oserror(); + return n; +} + +void +audiodevsetvol(int what, int left, int right) +{ + error("no volume support"); +} + +void +audiodevgetvol(int what, int *left, int *right) +{ + error("no volume support"); +} +