dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / audio / include / audio_device.h
blobb7522d6fcf8c18e87378af40e68c3e69e3fae40c
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright (c) 1992-2001 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #ifndef _MULTIMEDIA_AUDIO_DEVICE_H
28 #define _MULTIMEDIA_AUDIO_DEVICE_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
36 #include <sys/types.h>
37 #include <sys/ioccom.h>
38 #include <sys/audioio.h>
40 typedef audio_info_t Audio_info;
43 * The following macros read the current audio device configuration
44 * and convert the data encoding format into an Audio_hdr.
45 * 'F' is an open audio file descriptor.
46 * 'H' is a pointer to an Audio_hdr.
47 * The structure '*H' is updated after the device state has been read.
49 #define audio_get_play_config(F, H) \
50 audio__setplayhdr((F), (H), AUDIO__PLAY)
51 #define audio_get_record_config(F, H) \
52 audio__setplayhdr((F), (H), AUDIO__RECORD)
55 * The following macros attempt to reconfigure the audio device so that
56 * it operates on data encoded according to a given Audio_hdr.
57 * 'F' is an open audio file descriptor.
58 * 'H' is a pointer to an Audio_hdr describing the desired encoding.
59 * The structure '*H' is updated after the device state has been read
60 * to reflect the actual state of the device.
62 * AUDIO_SUCCESS is returned if the device configuration matches the
63 * requested encoding. AUDIO_ERR_NOEFFECT is returned if it does not.
65 #define audio_set_play_config(F, H) \
66 audio__setplayhdr((F), (H), AUDIO__SET|AUDIO__PLAY)
67 #define audio_set_record_config(F, H) \
68 audio__setplayhdr((F), (H), AUDIO__SET|AUDIO__RECORD)
72 * The following macros pause or resume the audio play and/or record channels.
73 * Note that requests to pause a channel that is not open will have no effect.
74 * In such cases, AUDIO_ERR_NOEFFECT is returned.
76 #define audio_pause(F) \
77 audio__setpause((F), AUDIO__PLAYREC|AUDIO__PAUSE)
78 #define audio_pause_play(F) \
79 audio__setpause((F), AUDIO__PLAY|AUDIO__PAUSE)
80 #define audio_pause_record(F) \
81 audio__setpause((F), AUDIO__RECORD|AUDIO__PAUSE)
83 #define audio_resume(F) \
84 audio__setpause((F), AUDIO__PLAYREC|AUDIO__RESUME)
85 #define audio_resume_play(F) \
86 audio__setpause((F), AUDIO__PLAY|AUDIO__RESUME)
87 #define audio_resume_record(F) \
88 audio__setpause((F), AUDIO__RECORD|AUDIO__RESUME)
92 * The following macros get individual state values.
93 * 'F' is an open audio file descriptor.
94 * 'V' is a pointer to an unsigned int.
95 * The value '*V' is updated after the device state has been read.
97 #define audio_get_play_port(F, V) \
98 audio__setval((F), (V), AUDIO__PLAY|AUDIO__PORT)
99 #define audio_get_record_port(F, V) \
100 audio__setval((F), (V), AUDIO__RECORD|AUDIO__PORT)
101 #define audio_get_play_balance(F, V) \
102 audio__setval((F), (V), AUDIO__PLAY|AUDIO__BALANCE)
103 #define audio_get_record_balance(F, V) \
104 audio__setval((F), (V), AUDIO__RECORD|AUDIO__BALANCE)
105 #define audio_get_play_samples(F, V) \
106 audio__setval((F), (V), AUDIO__PLAY|AUDIO__SAMPLES)
107 #define audio_get_record_samples(F, V) \
108 audio__setval((F), (V), AUDIO__RECORD|AUDIO__SAMPLES)
109 #define audio_get_play_error(F, V) \
110 audio__setval((F), (V), AUDIO__PLAY|AUDIO__ERROR)
111 #define audio_get_record_error(F, V) \
112 audio__setval((F), (V), AUDIO__RECORD|AUDIO__ERROR)
113 #define audio_get_play_eof(F, V) \
114 audio__setval((F), (V), AUDIO__PLAY|AUDIO__EOF)
116 #define audio_get_play_open(F, V) \
117 audio__setval((F), (V), AUDIO__PLAY|AUDIO__OPEN)
118 #define audio_get_record_open(F, V) \
119 audio__setval((F), (V), AUDIO__RECORD|AUDIO__OPEN)
120 #define audio_get_play_active(F, V) \
121 audio__setval((F), (V), AUDIO__PLAY|AUDIO__ACTIVE)
122 #define audio_get_record_active(F, V) \
123 audio__setval((F), (V), AUDIO__RECORD|AUDIO__ACTIVE)
124 #define audio_get_play_waiting(F, V) \
125 audio__setval((F), (V), AUDIO__PLAY|AUDIO__WAITING)
126 #define audio_get_record_waiting(F, V) \
127 audio__setval((F), (V), AUDIO__RECORD|AUDIO__WAITING)
130 * The following macros set individual state values.
131 * 'F' is an open audio file descriptor.
132 * 'V' is a pointer to an unsigned int.
133 * The value '*V' is updated after the device state has been read.
135 #define audio_set_play_port(F, V) \
136 audio__setval((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__PORT)
137 #define audio_set_record_port(F, V) \
138 audio__setval((F), (V), AUDIO__SET|AUDIO__RECORD|AUDIO__PORT)
141 * The value returned for these is the value *before* the state was changed.
142 * This allows you to atomically read and reset their values.
144 #define audio_set_play_balance(F, V) \
145 audio__setval((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__BALANCE)
146 #define audio_set_record_balance(F, V) \
147 audio__setval((F), (V), AUDIO__SET|AUDIO__RECORD|AUDIO__BALANCE)
148 #define audio_set_play_samples(F, V) \
149 audio__setval((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__SAMPLES)
150 #define audio_set_record_samples(F, V) \
151 audio__setval((F), (V), AUDIO__SET|AUDIO__RECORD|AUDIO__SAMPLES)
152 #define audio_set_play_error(F, V) \
153 audio__setval((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__ERROR)
154 #define audio_set_record_error(F, V) \
155 audio__setval((F), (V), AUDIO__SET|AUDIO__RECORD|AUDIO__ERROR)
156 #define audio_set_play_eof(F, V) \
157 audio__setval((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__EOF)
159 /* The value can only be set to one. It is reset to zero on close(). */
160 #define audio_set_play_waiting(F, V) \
161 audio__setval((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__WAITING)
162 #define audio_set_record_waiting(F, V) \
163 audio__setval((F), (V), AUDIO__SET|AUDIO__RECORD|AUDIO__WAITING)
166 * Gain routines take double values, mapping the valid range of gains
167 * to a floating-point value between zero and one, inclusive.
168 * The value returned will likely be slightly different than the value set.
169 * This is because the value is quantized by the device.
171 * Make sure that 'V' is a (double *)!
173 #define audio_get_play_gain(F, V) \
174 audio__setgain((F), (V), AUDIO__PLAY|AUDIO__GAIN)
175 #define audio_get_record_gain(F, V) \
176 audio__setgain((F), (V), AUDIO__RECORD|AUDIO__GAIN)
177 #define audio_get_monitor_gain(F, V) \
178 audio__setgain((F), (V), AUDIO__MONGAIN)
180 #define audio_set_play_gain(F, V) \
181 audio__setgain((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__GAIN)
182 #define audio_set_record_gain(F, V) \
183 audio__setgain((F), (V), AUDIO__SET|AUDIO__RECORD|AUDIO__GAIN)
184 #define audio_set_monitor_gain(F, V) \
185 audio__setgain((F), (V), AUDIO__SET|AUDIO__MONGAIN)
188 * The following macros flush the audio play and/or record queues.
189 * Note that requests to flush a channel that is not open will have no effect.
191 #define audio_flush(F) \
192 audio__flush((F), AUDIO__PLAYREC)
193 #define audio_flush_play(F) \
194 audio__flush((F), AUDIO__PLAY)
195 #define audio_flush_record(F) \
196 audio__flush((F), AUDIO__RECORD)
199 /* The following is used for 'which' arguments to get/set info routines */
200 #define AUDIO__PLAY (0x10000)
201 #define AUDIO__RECORD (0x20000)
202 #define AUDIO__PLAYREC (AUDIO__PLAY | AUDIO__RECORD)
204 #define AUDIO__PORT (1)
205 #define AUDIO__SAMPLES (2)
206 #define AUDIO__ERROR (3)
207 #define AUDIO__EOF (4)
208 #define AUDIO__OPEN (5)
209 #define AUDIO__ACTIVE (6)
210 #define AUDIO__WAITING (7)
211 #define AUDIO__GAIN (8)
212 #define AUDIO__MONGAIN (9)
213 #define AUDIO__PAUSE (10)
214 #define AUDIO__RESUME (11)
215 #define AUDIO__BALANCE (12)
217 #define AUDIO__SET (0x80000000)
218 #define AUDIO__SETVAL_MASK (0xff)
220 #ifdef __cplusplus
222 #endif
224 #endif /* !_MULTIMEDIA_AUDIO_DEVICE_H */