Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

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