ref: 7616b2f22d8e090dcbea817aee2cd819bc41bda7
parent: 88418ce4fd49ee62171f01ba90d591e3e6858fc8
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Tue Nov 7 17:04:57 EST 2023
snd (plan9): proper (de)initialization
--- a/snd_plan9.c
+++ b/snd_plan9.c
@@ -22,7 +22,6 @@
break;
}
}
- chanclose(p);
threadexits(nil);
}
@@ -34,12 +33,8 @@
void
sndwrite(uchar *buf, long sz)
{
- if(afd < 0)
+ if(ach == nil)
return;
- if(ach == nil){
- ach = chancreate(sizeof(ulong), 0);
- proccreate(auproc, ach, 4096);
- }
qlock(&alock);
sendul(ach, sz);
mixbuf = buf;
@@ -49,8 +44,11 @@
void
sndclose(void)
{
- close(afd);
- afd = -1;
+ if(ach != nil){
+ chanclose(ach);
+ close(afd);
+ afd = -1;
+ }
}
int
@@ -58,5 +56,7 @@
{
if((afd = open("/dev/audio", OWRITE)) < 0)
return -1;
+ ach = chancreate(sizeof(ulong), 0);
+ proccreate(auproc, ach, 4096);
return 0;
}