xref: /plan9/acme/bin/source/acd/toc.c (revision 9a747e4fd48b9f4522c70c07e8f882a15030f964)
1 #include "acd.h"
2 
3 Toc thetoc;
4 
5 void
tocthread(void * v)6 tocthread(void *v)
7 {
8 	Drive *d;
9 
10 	threadsetname("tocthread");
11 	d = v;
12 	DPRINT(2, "recv ctocdisp?...");
13 	while(recv(d->ctocdisp, &thetoc) == 1) {
14 		DPRINT(2, "recv ctocdisp!...");
15 		drawtoc(d->w, &thetoc);
16 		DPRINT(2, "send dbreq...\n");
17 		send(d->ctocdbreq, &thetoc);
18 	}
19 }
20 
21 void
freetoc(Toc * t)22 freetoc(Toc *t)
23 {
24 	int i;
25 
26 	free(t->title);
27 	for(i=0; i<t->ntrack; i++)
28 		free(t->track[i].title);
29 }
30 
31 void
cddbthread(void * v)32 cddbthread(void *v)
33 {
34 	Drive *d;
35 	Toc t;
36 
37 	threadsetname("cddbthread");
38 	d = v;
39 	while(recv(d->ctocdbreply, &t) == 1) {
40 		if(thetoc.nchange == t.nchange) {
41 			freetoc(&thetoc);
42 			thetoc = t;
43 			redrawtoc(d->w, &thetoc);
44 		}
45 	}
46 }
47 
48 void
cdstatusthread(void * v)49 cdstatusthread(void *v)
50 {
51 	Drive *d;
52 	Cdstatus s;
53 
54 	d = v;
55 
56 	for(;;)
57 		recv(d->cstat, &s);
58 
59 }
60