acd.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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 <u.h>
  10. #include <libc.h>
  11. #include <bio.h>
  12. #include <disk.h>
  13. #include <auth.h>
  14. #include <fcall.h>
  15. #include <thread.h>
  16. #include <9p.h>
  17. /* acme */
  18. typedef struct Event Event;
  19. typedef struct Window Window;
  20. enum
  21. {
  22. STACK = 16384,
  23. EVENTSIZE = 256,
  24. NEVENT = 5,
  25. };
  26. struct Event
  27. {
  28. int c1;
  29. int c2;
  30. int q0;
  31. int q1;
  32. int flag;
  33. int nb;
  34. int nr;
  35. char b[EVENTSIZE*UTFmax+1];
  36. Rune r[EVENTSIZE+1];
  37. };
  38. struct Window
  39. {
  40. /* file descriptors */
  41. int ctl;
  42. int event;
  43. int addr;
  44. int data;
  45. Biobuf *body;
  46. /* event input */
  47. char buf[512];
  48. char *bufp;
  49. int nbuf;
  50. Event e[NEVENT];
  51. int id;
  52. int open;
  53. Channel *cevent; /* chan(Event*) */
  54. };
  55. extern Window* newwindow(void);
  56. extern int winopenfile(Window*, char*);
  57. extern void winopenbody(Window*, int);
  58. extern void winclosebody(Window*);
  59. extern void wintagwrite(Window*, char*, int);
  60. extern void winname(Window*, char*);
  61. extern void winwriteevent(Window*, Event*);
  62. extern void winread(Window*, uint, uint, char*);
  63. extern int windel(Window*, int);
  64. extern void wingetevent(Window*, Event*);
  65. extern void wineventproc(void*);
  66. extern void winwritebody(Window*, char*, int);
  67. extern void winclean(Window*);
  68. extern int winselect(Window*, char*, int);
  69. extern int winsetaddr(Window*, char*, int);
  70. extern char* winreadbody(Window*, int*);
  71. extern void windormant(Window*);
  72. extern void winsetdump(Window*, char*, char*);
  73. extern char* readfile(char*, char*, int*);
  74. extern void ctlprint(int, char*, ...);
  75. extern void* emalloc(uint);
  76. extern char* estrdup(char*);
  77. extern char* estrstrdup(char*, char*);
  78. extern char* egrow(char*, char*, char*);
  79. extern char* eappend(char*, char*, char*);
  80. extern void error(char*, ...);
  81. extern int tokenizec(char*, char**, int, char*);
  82. /* cd stuff */
  83. typedef struct Msf Msf; /* minute, second, frame */
  84. struct Msf {
  85. int m;
  86. int s;
  87. int f;
  88. };
  89. typedef struct Track Track;
  90. struct Track {
  91. Msf start;
  92. Msf end;
  93. uint32_t bstart;
  94. uint32_t bend;
  95. char *title;
  96. };
  97. enum {
  98. MTRACK = 64,
  99. };
  100. typedef struct Toc Toc;
  101. struct Toc {
  102. int ntrack;
  103. int nchange;
  104. int changetime;
  105. int track0;
  106. Track track[MTRACK];
  107. char *title;
  108. };
  109. extern int msfconv(Fmt*);
  110. enum { /* state */
  111. Sunknown,
  112. Splaying,
  113. Spaused,
  114. Scompleted,
  115. Serror,
  116. };
  117. typedef struct Cdstatus Cdstatus;
  118. struct Cdstatus {
  119. int state;
  120. int track;
  121. int index;
  122. Msf abs;
  123. Msf rel;
  124. };
  125. typedef struct Drive Drive;
  126. struct Drive {
  127. Window *w;
  128. Channel *cstatus; /* chan(Cdstatus) */
  129. Channel *ctocdisp; /* chan(Toc) */
  130. Channel *cdbreq; /* chan(Toc) */
  131. Channel *cdbreply; /* chan(Toc) */
  132. Scsi *scsi;
  133. Toc toc;
  134. Cdstatus status;
  135. };
  136. int gettoc(Scsi*, Toc*);
  137. void drawtoc(Window*, Drive*, Toc*);
  138. void redrawtoc(Window*, Toc*);
  139. void tocproc(void*); /* Drive* */
  140. void cddbproc(void*); /* Drive* */
  141. void cdstatusproc(void*); /* Drive* */
  142. extern int debug;
  143. #define DPRINT if(debug)fprint
  144. void acmeevent(Drive*, Window*, Event*);
  145. int playtrack(Drive*, int, int);
  146. int pause(Drive*);
  147. int resume(Drive*);
  148. int stop(Drive*);
  149. int eject(Drive*);
  150. int ingest(Drive*);
  151. int markplay(Window*, uint32_t);
  152. int setplaytime(Window*, char*);
  153. void advancetrack(Drive*, Window*);