playlist.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. typedef struct Worker Worker;
  2. typedef struct Req Req;
  3. typedef struct Fid Fid;
  4. typedef struct File File;
  5. typedef struct Playlist Playlist;
  6. typedef struct Wmsg Wmsg;
  7. typedef union Pmsg Pmsg;
  8. typedef struct Pacbuf Pacbuf;
  9. enum {
  10. Qdir,
  11. Qplayctl,
  12. Qplaylist,
  13. Qplayvol,
  14. Qplaystat,
  15. Nqid,
  16. };
  17. enum {
  18. DbgPcm = 0x01000,
  19. DbgPac = 0x02000,
  20. DbgFs = 0x10000,
  21. DbgWorker = 0x20000,
  22. DbgPlayer = 0x40000,
  23. DbgError = 0x80000,
  24. };
  25. enum {
  26. Messagesize = 8*1024+IOHDRSZ,
  27. Undef = 0x80000000,
  28. /* 256 buffers of 4096 bytes represents 5.9 seconds
  29. * of playout at 44100 Hz (2*16bit samples)
  30. */
  31. NPacbuf = 256,
  32. Pacbufsize = 4096,
  33. NSparebuf = 16, /* For in-line commands (Pause, Resume, Error) */
  34. };
  35. enum {
  36. /* Named commands (see fs.c): */
  37. Nostate, // can't use zero for state
  38. Error,
  39. Stop,
  40. Pause,
  41. Play,
  42. Resume,
  43. Skip,
  44. /* Unnamed commands */
  45. Work,
  46. Check,
  47. Flush,
  48. Prep,
  49. Preq,
  50. };
  51. union Pmsg {
  52. ulong m;
  53. struct{
  54. ushort cmd;
  55. ushort off;
  56. };
  57. };
  58. struct Wmsg {
  59. Pmsg;
  60. void *arg; /* if(cmd != Work) mallocated by sender, freed by receiver */
  61. };
  62. struct Playlist {
  63. /* The play list consists of a sequence of {objectref, filename}
  64. * entries. Object ref and file name are separated by a tab.
  65. * An object ref may not contain a tab. Entries are seperated
  66. * by newline characters. Neither file names, nor object refs
  67. * may contain newlines.
  68. */
  69. ulong *lines;
  70. ulong nlines;
  71. char *data;
  72. ulong ndata;
  73. };
  74. struct File {
  75. Dir dir;
  76. Channel *workers;
  77. };
  78. struct Worker
  79. {
  80. Req *r;
  81. Channel *eventc;
  82. };
  83. struct Fid
  84. {
  85. int fid;
  86. File *file;
  87. ushort flags;
  88. short readers;
  89. ulong vers; /* set to file's version when completely read */
  90. Fid *next;
  91. };
  92. struct Req
  93. {
  94. uchar indata[Messagesize];
  95. uchar outdata[Messagesize];
  96. Fcall ifcall;
  97. Fcall ofcall;
  98. Fid* fid;
  99. };
  100. struct Pacbuf {
  101. Pmsg;
  102. int len;
  103. char data[Pacbufsize];
  104. };
  105. void allocwork(Req*);
  106. Wmsg waitmsg(Worker*, Channel*);
  107. int sendmsg(Channel*, Wmsg*);
  108. void bcastmsg(Channel*, Wmsg*);
  109. void reqfree(Req*);
  110. Req *reqalloc(void);
  111. void readbuf(Req*, void*, long);
  112. void readstr(Req*, char*);
  113. void volumeset(int *v);
  114. void playupdate(Pmsg, char*);
  115. void playinit(void);
  116. void volumeproc(void*);
  117. void srv(void *);
  118. long robustread(int, void*, long);
  119. void volumeupdate(int*);
  120. char *getplaylist(int);
  121. char *getplaystat(char*, char*);
  122. extern int debug, aflag;
  123. extern char *user;
  124. extern Channel *playc;
  125. extern char *statetxt[];
  126. extern int volume[8];
  127. extern Playlist playlist;
  128. extern Channel *workers;
  129. extern Channel *volumechan;
  130. extern Channel *playchan;
  131. extern Channel *playlistreq;
  132. extern File files[];
  133. extern int srvfd[];