xref: /haiku/src/add-ons/media/media-add-ons/esound_sink/esdproto.h (revision 71916458440abe2ff7649b2b151e48903bdd6b98)
1 /*
2  * ESounD media addon for BeOS
3  *
4  * Copyright (c) 2006 François Revol (revol@free.fr)
5  *
6  * Based on Multi Audio addon for Haiku,
7  * Copyright (c) 2002, 2003 Jerome Duval (jerome.duval@free.fr)
8  *
9  * All rights reserved.
10  * Redistribution and use in source and binary forms, with or without modification,
11  * are permitted provided that the following conditions are met:
12  *
13  * - Redistributions of source code must retain the above copyright notice,
14  *   this list of conditions and the following disclaimer.
15  * - Redistributions in binary form must reproduce the above copyright notice,
16  *   this list of conditions and the following disclaimer in the documentation
17  *   and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
25  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  */
31 #ifndef _ESDPROTO_H
32 #define _ESDPROTO_H
33 /*
34  * ESounD protocol
35  * cf. http://www.jcraft.com/jesd/EsounD-protocol.txt
36  */
37 
38 #include <inttypes.h>
39 
40 /* limits */
41 #define ESD_MAX_BUF (4 * 1024)
42 #define ESD_MAX_KEY 16
43 #define ESD_MAX_NAME 128
44 
45 typedef uint32_t	esd_rate_t;
46 typedef uint32_t	esd_format_t;
47 typedef uint32_t	esd_command_t;
48 typedef char	esd_key_t[ESD_MAX_KEY];
49 typedef char	esd_name_t[ESD_MAX_NAME];
50 
51 /* defaults */
52 //#define ESD_DEFAULT_PORT 5001
53 #define ESD_DEFAULT_PORT 16001
54 
55 #define ESD_DEFAULT_RATE 44100
56 //#define ESD_DEFAULT_RATE 22050
57 
58 #define ESD_ENDIAN_TAG 'ENDN'
59 
60 enum {
61 	/* init */
62 	ESD_PROTO_CONNECT = 0,
63 
64 	/* security  */
65 	ESD_PROTO_LOCK,
66 	ESD_PROTO_UNLOCK,
67 
68 	ESD_PROTO_STREAM_PLAY,
69 	ESD_PROTO_STREAM_REC,
70 	ESD_PROTO_STREAM_MON,
71 
72 	ESD_PROTO_SAMPLE_CACHE,
73 	ESD_PROTO_SAMPLE_FREE,
74 	ESD_PROTO_SAMPLE_PLAY,
75 	ESD_PROTO_SAMPLE_LOOP,
76 	ESD_PROTO_SAMPLE_STOP,
77 	ESD_PROTO_SAMPLE_KILL,
78 
79 	ESD_PROTO_STANDBY,
80 	ESD_PROTO_RESUME,
81 
82 	ESD_PROTO_SAMPLE_GETID,
83 	ESD_PROTO_STREAM_FILTER,
84 
85 	ESD_PROTO_SERVER_INFO,
86 	ESD_PROTO_SERVER_ALL_INFO,
87 	ESD_PROTO_SUBSCRIBE,
88 	ESD_PROTO_UNSUBSCRIBE,
89 
90 	ESD_PROTO_STREAM_PAN,
91 	ESD_PROTO_SAMPLE_PAN,
92 
93 	ESD_PROTO_STANDBY_MODE,
94 	ESD_PROTO_LATENCY,
95 	ESD_PROTO_MAX
96 };
97 
98 #define ESD_MASK_BITS	0x000F
99 #define ESD_MASK_CHAN	0x00F0
100 #define ESD_MASK_MODE	0x0F00
101 #define ESD_MASK_FUNC	0xF000
102 
103 /* sample size */
104 #define ESD_BITS8	0x0000
105 #define ESD_BITS16	0x0001
106 
107 /* channel count */
108 #define ESD_MONO	0x0010
109 #define ESD_STEREO	0x0020
110 
111 /* mode */
112 #define ESD_STREAM	0x0000
113 #define ESD_SAMPLE	0x0100
114 #define ESD_ADPCM	0x0200
115 
116 /* functions */
117 #define ESD_FUNC_PLAY		0x1000
118 #define ESD_FUNC_MONITOR	0x0000
119 #define ESD_FUNC_RECORD		0x2000
120 #define ESD_FUNC_STOP	0x0000
121 #define ESD_FUNC_LOOP		0x2000
122 
123 /* errors */
124 #define ESD_OK	0
125 #define ESD_ERROR_STANDBY	1
126 #define ESD_ERROR_AUTOSTANDBY	2
127 #define ESD_ERROR_RUNNING	3
128 
129 #define ESD_FALSE	0
130 #define ESD_TRUE	1
131 
132 #endif /* _ESDPROTO_H */
133