shithub: treason

Download patch

ref: cc9ca3545bb7e030a3fb4f95fa7fdf8b0ebfdeff
parent: ee5b9871ff10c3a30d93845125c8568d12f8951f
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Mon Dec 14 08:05:01 EST 2020

increase buffer for mcfs video stream to 64k

--- a/stream.c
+++ b/stream.c
@@ -50,6 +50,8 @@
 		return;
 	s->ops.close(s);
 	s->type = -1;
+	if(s->freeaux != nil)
+		s->freeaux(s->aux);
 }
 
 int
--- a/stream.h
+++ b/stream.h
@@ -67,6 +67,8 @@
 	void *b;
 	u8int *buf;
 	int bufsz;
+	void *aux;
+	void (*freeaux)(void *);
 };
 
 Stream *Sopen(char *filename, int *num);
--- a/stream_mc.c
+++ b/stream_mc.c
@@ -6,8 +6,17 @@
 
 enum {
 	Maxstreams = 2,
+	Bufsz = 64*1024,
 };
 
+typedef struct MCaux MCaux;
+
+struct MCaux {
+	int fd;
+	Biobuf bio;
+	u8int buf[Bufsz];
+};
+
 static int
 mcfs(char **argv, int *pipefd)
 {
@@ -47,6 +56,16 @@
 	return -1;
 }
 
+static void
+freeaux(void *aux)
+{
+	MCaux *a;
+
+	a = aux;
+	close(a->fd);
+	free(a);
+}
+
 static Stream *
 mcopen(char *filename, int *num, int *failed)
 {
@@ -54,6 +73,7 @@
 	char *line;
 	int p, pid, n, ns;
 	Biobuf b;
+	MCaux *a;
 	char *argv[] = {
 		"mcfs",
 		filename,
@@ -82,9 +102,16 @@
 			if(nvideo < 1 && strcmp(v[1], "video") == 0){
 				s->video.w = atoi(v[3]);
 				s->video.h = atoi(v[4]);
-				if(mcfs(argv, &sp) > 0 && ivfopenb(Bfdopen(sp, OREAD), s, failed) == 0){
-					nvideo++;
-					ns++;
+				if(mcfs(argv, &sp) > 0){
+					if((a = malloc(sizeof(*a))) == nil)
+						sysfatal("memory");
+					a->fd = sp;
+					s->aux = a;
+					s->freeaux = freeaux;
+					if(Binits(&a->bio, sp, OREAD, a->buf, Bufsz) == 0 && ivfopenb(&a->bio, s, failed) == 0){
+						nvideo++;
+						ns++;
+					}
 				}
 			}else if(naudio < 1 && strcmp(v[1], "audio") == 0 && (s->fmt = audfmt(v[2])) >= 0){
 				s->audio.nchan = atoi(v[3]);