toc.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include "acd.h"
  10. Toc thetoc;
  11. void
  12. tocthread(void *v)
  13. {
  14. Drive *d;
  15. threadsetname("tocthread");
  16. d = v;
  17. DPRINT(2, "recv ctocdisp?...");
  18. while(recv(d->ctocdisp, &thetoc) == 1) {
  19. DPRINT(2, "recv ctocdisp!...");
  20. drawtoc(d->w, d, &thetoc);
  21. DPRINT(2, "send dbreq...\n");
  22. send(d->cdbreq, &thetoc);
  23. }
  24. }
  25. void
  26. freetoc(Toc *t)
  27. {
  28. int i;
  29. free(t->title);
  30. for(i=0; i<t->ntrack; i++)
  31. free(t->track[i].title);
  32. }
  33. void
  34. cddbthread(void *v)
  35. {
  36. Drive *d;
  37. Toc t;
  38. threadsetname("cddbthread");
  39. d = v;
  40. while(recv(d->cdbreply, &t) == 1) {
  41. if(thetoc.nchange == t.nchange) {
  42. freetoc(&thetoc);
  43. thetoc = t;
  44. redrawtoc(d->w, &thetoc);
  45. }
  46. }
  47. }
  48. void
  49. cdstatusthread(void *v)
  50. {
  51. Drive *d;
  52. Cdstatus s;
  53. d = v;
  54. for(;;)
  55. recv(d->cstatus, &s);
  56. }