]> code.delx.au - pulseaudio/blob - src/pulsecore/esound.h
remap: Change remapping function argument type from void to int16_t / float as approp...
[pulseaudio] / src / pulsecore / esound.h
1 #ifndef fooesoundhfoo
2 #define fooesoundhfoo
3
4 /***
5 This file is part of PulseAudio.
6
7 Copyright 2004-2006 Lennart Poettering
8
9 PulseAudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published
11 by the Free Software Foundation; either version 2.1 of the License,
12 or (at your option) any later version.
13
14 PulseAudio is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with PulseAudio; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 USA.
23 ***/
24
25 /* Most of the following is blatantly stolen from esound. */
26
27 /* path and name of the default EsounD domain socket */
28 #define ESD_UNIX_SOCKET_DIR "/tmp/.esd"
29 #define ESD_UNIX_SOCKET_NAME "/tmp/.esd/socket"
30
31 /* length of the audio buffer size */
32 #define ESD_BUF_SIZE (4 * 1024)
33 /* maximum size we can write(). Otherwise we might overflow */
34 #define ESD_MAX_WRITE_SIZE (21 * 4096)
35
36 /* length of the authorization key, octets */
37 #define ESD_KEY_LEN (16)
38
39 /* default port for the EsounD server */
40 #define ESD_DEFAULT_PORT (16001)
41
42 /* default sample rate for the EsounD server */
43 #define ESD_DEFAULT_RATE (44100)
44
45 /* maximum length of a stream/sample name */
46 #define ESD_NAME_MAX (128)
47
48 /* a magic number to identify the relative endianness of a client */
49 #define ESD_ENDIAN_KEY ((uint32_t) (('E' << 24) + ('N' << 16) + ('D' << 8) + ('N')))
50
51 #define ESD_VOLUME_BASE (256)
52
53 /*************************************/
54 /* what can we do to/with the EsounD */
55 enum esd_proto {
56 ESD_PROTO_CONNECT, /* implied on initial client connection */
57
58 /* pseudo "security" functionality */
59 ESD_PROTO_LOCK, /* disable "foreign" client connections */
60 ESD_PROTO_UNLOCK, /* enable "foreign" client connections */
61
62 /* stream functionality: play, record, monitor */
63 ESD_PROTO_STREAM_PLAY, /* play all following data as a stream */
64 ESD_PROTO_STREAM_REC, /* record data from card as a stream */
65 ESD_PROTO_STREAM_MON, /* send mixed buffer output as a stream */
66
67 /* sample functionality: cache, free, play, loop, EOL, kill */
68 ESD_PROTO_SAMPLE_CACHE, /* cache a sample in the server */
69 ESD_PROTO_SAMPLE_FREE, /* release a sample in the server */
70 ESD_PROTO_SAMPLE_PLAY, /* play a cached sample */
71 ESD_PROTO_SAMPLE_LOOP, /* loop a cached sample, til eoloop */
72 ESD_PROTO_SAMPLE_STOP, /* stop a looping sample when done */
73 ESD_PROTO_SAMPLE_KILL, /* stop the looping sample immediately */
74
75 /* free and reclaim /dev/dsp functionality */
76 ESD_PROTO_STANDBY, /* release /dev/dsp and ignore all data */
77 ESD_PROTO_RESUME, /* reclaim /dev/dsp and play sounds again */
78
79 /* TODO: move these to a more logical place. NOTE: will break the protocol */
80 ESD_PROTO_SAMPLE_GETID, /* get the ID for an already-cached sample */
81 ESD_PROTO_STREAM_FILT, /* filter mixed buffer output as a stream */
82
83 /* esd remote management */
84 ESD_PROTO_SERVER_INFO, /* get server info (ver, sample rate, format) */
85 ESD_PROTO_ALL_INFO, /* get all info (server info, players, samples) */
86 ESD_PROTO_SUBSCRIBE, /* track new and removed players and samples */
87 ESD_PROTO_UNSUBSCRIBE, /* stop tracking updates */
88
89 /* esd remote control */
90 ESD_PROTO_STREAM_PAN, /* set stream panning */
91 ESD_PROTO_SAMPLE_PAN, /* set default sample panning */
92
93 /* esd status */
94 ESD_PROTO_STANDBY_MODE, /* see if server is in standby, autostandby, etc */
95
96 /* esd latency */
97 ESD_PROTO_LATENCY, /* retrieve latency between write()'s and output */
98
99 ESD_PROTO_MAX /* for bounds checking */
100 };
101
102 /******************/
103 /* The EsounD api */
104
105 /* the properties of a sound buffer are logically or'd */
106
107 /* bits of stream/sample data */
108 #define ESD_MASK_BITS ( 0x000F )
109 #define ESD_BITS8 ( 0x0000 )
110 #define ESD_BITS16 ( 0x0001 )
111
112 /* how many interleaved channels of data */
113 #define ESD_MASK_CHAN ( 0x00F0 )
114 #define ESD_MONO ( 0x0010 )
115 #define ESD_STEREO ( 0x0020 )
116
117 /* whether it's a stream or a sample */
118 #define ESD_MASK_MODE ( 0x0F00 )
119 #define ESD_STREAM ( 0x0000 )
120 #define ESD_SAMPLE ( 0x0100 )
121 #define ESD_ADPCM ( 0x0200 ) /* TODO: anyone up for this? =P */
122
123 /* the function of the stream/sample, and common functions */
124 #define ESD_MASK_FUNC ( 0xF000 )
125 #define ESD_PLAY ( 0x1000 )
126 /* functions for streams only */
127 #define ESD_MONITOR ( 0x0000 )
128 #define ESD_RECORD ( 0x2000 )
129 /* functions for samples only */
130 #define ESD_STOP ( 0x0000 )
131 #define ESD_LOOP ( 0x2000 )
132
133 typedef int esd_format_t;
134 typedef int esd_proto_t;
135
136 /*******************************************************************/
137 /* esdmgr.c - functions to implement a "sound manager" for esd */
138
139 /* structures to retrieve information about streams/samples from the server */
140 typedef struct esd_server_info {
141
142 int version; /* server version encoded as an int */
143 esd_format_t format; /* magic int with the format info */
144 int rate; /* sample rate */
145
146 } esd_server_info_t;
147
148 typedef struct esd_player_info {
149
150 struct esd_player_info *next; /* point to next entry in list */
151 esd_server_info_t *server; /* the server that contains this stream */
152
153 int source_id; /* either a stream fd or sample id */
154 char name[ ESD_NAME_MAX ]; /* name of stream for remote control */
155 int rate; /* sample rate */
156 int left_vol_scale; /* volume scaling */
157 int right_vol_scale;
158
159 esd_format_t format; /* magic int with the format info */
160
161 } esd_player_info_t;
162
163 typedef struct esd_sample_info {
164
165 struct esd_sample_info *next; /* point to next entry in list */
166 esd_server_info_t *server; /* the server that contains this sample */
167
168 int sample_id; /* either a stream fd or sample id */
169 char name[ ESD_NAME_MAX ]; /* name of stream for remote control */
170 int rate; /* sample rate */
171 int left_vol_scale; /* volume scaling */
172 int right_vol_scale;
173
174 esd_format_t format; /* magic int with the format info */
175 int length; /* total buffer length */
176
177 } esd_sample_info_t;
178
179 typedef struct esd_info {
180
181 esd_server_info_t *server;
182 esd_player_info_t *player_list;
183 esd_sample_info_t *sample_list;
184
185 } esd_info_t;
186
187 enum esd_standby_mode {
188 ESM_ERROR, ESM_ON_STANDBY, ESM_ON_AUTOSTANDBY, ESM_RUNNING
189 };
190 typedef int esd_standby_mode_t;
191
192 enum esd_client_state {
193 ESD_STREAMING_DATA, /* data from here on is streamed data */
194 ESD_CACHING_SAMPLE, /* midway through caching a sample */
195 ESD_NEEDS_REQDATA, /* more data needed to complete request */
196 ESD_NEXT_REQUEST, /* proceed to next request */
197 ESD_CLIENT_STATE_MAX /* place holder */
198 };
199 typedef int esd_client_state_t;
200
201 /* the endian key is transferred in binary, if it's read into int, */
202 /* and matches ESD_ENDIAN_KEY (ENDN), then the endianness of the */
203 /* server and the client match; if it's SWAP_ENDIAN_KEY, swap data */
204 #define ESD_SWAP_ENDIAN_KEY (PA_UINT32_SWAP(ESD_ENDIAN_KEY))
205
206 #endif