History

increase buffer for mcfs video stream to 64k

Sigrid Solveig Haflínudóttir committed 5 years ago

Commit cc9ca351 parent ee5b9873 files · +34 −3Browse files

Unified · Split

3 files
  1. stream.c +2 −0
  2. stream.h +2 −0
  3. stream_mc.c +30 −3
stream.c+2−0
@@ -50,6 +50,8 @@ Sclose(Stream *s) · 49 unmodified lines
5050 return;
5151 s->ops.close(s);
5252 s->type = -1;
53+ if(s->freeaux != nil)
54+ s->freeaux(s->aux);
5355 }
5456
5557 int
stream.h+2−0
@@ -67,6 +67,8 @@ struct Stream { · 66 unmodified lines
6767 void *b;
6868 u8int *buf;
6969 int bufsz;
70+ void *aux;
71+ void (*freeaux)(void *);
7072 };
7173
7274 Stream *Sopen(char *filename, int *num);
stream_mc.c+30−3
@@ -6,6 +6,15 @@ · 5 unmodified lines
66
77 enum {
88 Maxstreams = 2,
9+ Bufsz = 64*1024,
10+};
11+
12+typedef struct MCaux MCaux;
13+
14+struct MCaux {
15+ int fd;
16+ Biobuf bio;
17+ u8int buf[Bufsz];
918 };
1019
1120 static int
@@ -47,6 +56,16 @@ audfmt(char *fmt) · 35 unmodified lines
4756 return -1;
4857 }
4958
59+static void
60+freeaux(void *aux)
61+{
62+ MCaux *a;
63+
64+ a = aux;
65+ close(a->fd);
66+ free(a);
67+}
68+
5069 static Stream *
5170 mcopen(char *filename, int *num, int *failed)
5271 {
@@ -54,6 +73,7 @@ mcopen(char *filename, int *num, int *failed) · 1 unmodified line
5473 char *line;
5574 int p, pid, n, ns;
5675 Biobuf b;
76+ MCaux *a;
5777 char *argv[] = {
5878 "mcfs",
5979 filename,
@@ -82,9 +102,16 @@ mcopen(char *filename, int *num, int *failed) · 22 unmodified lines
82102 if(nvideo < 1 && strcmp(v[1], "video") == 0){
83103 s->video.w = atoi(v[3]);
84104 s->video.h = atoi(v[4]);
85− if(mcfs(argv, &sp) > 0 && ivfopenb(Bfdopen(sp, OREAD), s, failed) == 0){
86− nvideo++;
87− ns++;
105+ if(mcfs(argv, &sp) > 0){
106+ if((a = malloc(sizeof(*a))) == nil)
107+ sysfatal("memory");
108+ a->fd = sp;
109+ s->aux = a;
110+ s->freeaux = freeaux;
111+ if(Binits(&a->bio, sp, OREAD, a->buf, Bufsz) == 0 && ivfopenb(&a->bio, s, failed) == 0){
112+ nvideo++;
113+ ns++;
114+ }
88115 }
89116 }else if(naudio < 1 && strcmp(v[1], "audio") == 0 && (s->fmt = audfmt(v[2])) >= 0){
90117 s->audio.nchan = atoi(v[3]);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t