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