9front - general discussion about 9front
 help / color / mirror / Atom feed
* [drawterm] Pulse audio support for Linux
@ 2019-11-05 20:07 Jacob Moody
  2020-09-22 11:34 ` [9front] " hiro
  0 siblings, 1 reply; 6+ messages in thread
From: Jacob Moody @ 2019-11-05 20:07 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 199 bytes --]

Hello all,

I've got a quick patch to add pulse audio support in for drawterm.
This allows for drawterm to show up as an application in pulse. I've
attached the diff file.


Thanks,

-- 
Jacob Moody

[-- Attachment #2: pulse.diff --]
[-- Type: text/x-patch, Size: 1819 bytes --]

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 <pulse/simple.h>
+
+#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");
+}
+

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-09-22 19:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-05 20:07 [drawterm] Pulse audio support for Linux Jacob Moody
2020-09-22 11:34 ` [9front] " hiro
2020-09-22 17:53   ` Jacob Moody
2020-09-22 17:56     ` Kurt H Maier
2020-09-22 18:17       ` ori
2020-09-22 19:59         ` hiro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).