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