shithub: aplay

Download patch

ref: 80ab537c59db16b84c6691cef8765b88f5bbfe42
parent: 4a0ecb35b83a3312f291b763dd93d48162be7fae
author: Benjamin Scher Purcell <bpurcell@backstopsolutions.com>
date: Wed Jan 13 02:45:28 EST 2016

make channel static

--- a/aplay.c
+++ b/aplay.c
@@ -181,8 +181,10 @@
 startstop(Codecargs *codecargs)
 {
 	static int inpid;
-	Channel *c;
+	static Channel *inchan;
 
+	if(inchan == nil)
+		inchan = chancreate(sizeof(int), 0);
 	if(pause == 0){
 		assert(codecpid != 0 && inpid != 0);
 		postnote(PNPROC, codecpid, "die yankee pig dog");
@@ -194,10 +196,8 @@
 			threadsfatal();
 		proccreate(codecproc, codecargs, STACK);
 		codecpid = recvul(codecargs->pidchan);
-		c = chancreate(sizeof(int), 0);
-		inpid = proccreate(inproc, c, STACK);
-		send(c, &codecargs->infd[1]);
-		chanfree(c);
+		inpid = proccreate(inproc, inchan, STACK);
+		send(inchan, &codecargs->infd[1]);
 		close(codecargs->infd[0]);
 		close(codecargs->infd[1]);
 	}