source: contrib/API/include/uniaud.h@ 660

Last change on this file since 660 was 578, checked in by David Azarewicz, 11 years ago

API updates

File size: 8.9 KB
Line 
1/*
2 * This file is part of uniaud.dll.
3 *
4 * Copyright (c) 2010 Mensys BV
5 * Copyright (c) 2007 Vlad Stelmahovsky aka Vladest
6 *
7 * This library is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License and the GNU General Public License along with this library.
19 * If not, see <http://www.gnu.org/licenses/>.
20 */
21#ifndef __UNIAUD__
22#define __UNIAUD__
23
24#include "unidef.h"
25
26struct ReSampleContext;
27
28typedef struct ReSampleContext ReSampleContext;
29
30/*
31 * Mixer API
32 */
33
34typedef struct uniaud_pcm {
35 ULONG uni_handle; // handle, returned from UNIAUD32
36 ULONG uni_file; // handle, returned from DosOpen
37 int card_id; // card ID
38 card_type_ids card_type; // card type
39 int type; // type of PCM. 0 - read, 1 - write
40 int instance;
41 int state; // state of stream
42 int channels; // number of channels
43 int multi_channels; // number of channels when multichannel
44 int rate; // sample rate
45 int format; // format of sample
46 int bufsize; // buffer size in driver
47 int bufptr; // current buffer position
48 int period_size; // period size in byte
49 int periods; // number of periods per buffer
50 char *multi_buf; // buffer for multichannel
51 struct uniaud_pcm *pcm_rear; // pointer to rear channels pcm for multichannel
52 struct uniaud_pcm *pcm_center_lfe; // pointer to center&lfe channels pcm for multichannel
53 ReSampleContext *resample;
54 char *resample_buf;
55 int orig_channels; // original number of channels
56 int orig_rate; // original sample rate
57 int orig_format; // original sample rate
58 int resample_size; // total latest resample size in bytes
59 int resample_written; // written bytes from resample buffer to card
60} uniaud_pcm;
61
62static inline snd_interval_t *hw_param_interval(snd_pcm_hw_params_t *params,
63 snd_pcm_hw_param_t var)
64{
65 return &params->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL];
66}
67
68/*
69 * Get current power state for given card
70 * if <= 0 - error
71 */
72int _System uniaud_mixer_get_power_state(int card_id, ULONG *state);
73
74/*
75 * Set power state for given card
76 * if <= 0 - error
77 */
78int _System uniaud_mixer_set_power_state(int card_id, ULONG *state);
79
80/*
81 * Get number of controls for given card
82 * if <= 0 - error
83 */
84int _System uniaud_mixer_get_ctls_number(int card_id);
85
86/*
87 * Get controls list for given card
88 * if NULL - error
89 */
90UniaudControl * _System uniaud_mixer_get_ctl_list(int card_id);
91
92/*
93 * Get control ID by given name
94 * if < 0 - error
95 */
96int _System uniaud_get_id_by_name(int card_id, char *name, int index);
97
98/*
99 * Get control info for given card and control
100 * if < 0 - error
101 */
102int _System uniaud_mixer_get_ctl_info(int card_id, ULONG list_id, UniaudControlInfo *ctl_info);
103
104/*
105 * Get current value for given control
106 * if < 0 - error
107 */
108int _System uniaud_mixer_get_ctl_val(int card_id, ULONG list_id, UniaudControlValue *ctl_val);
109
110/*
111 * Set new value for given control
112 * if < 0 - error
113 */
114int _System uniaud_mixer_put_ctl_val(int card_id, ULONG list_id, UniaudControlValue *ctl_val);
115
116/*
117 * Wait for any control change for given card
118 * if <= 0 - error, otherwise - changed control number
119 * if timeout expired, returns -ETIME (see. errno.h)
120 */
121int _System uniaud_mixer_wait(int card_id, int timeout);
122
123/*
124 * Get range for given control ID
125 * checks min/max parameters for NULL
126 * if < 0 - error
127 */
128int _System uniaud_mixer_get_min_max(int card_id, ULONG ctl_id, int *min, int*max);
129
130/*
131 * Get count of values for given control ID
132 * checks values_cnt parameters for NULL
133 * if < 0 - error
134 */
135int _System uniaud_mixer_get_count_of_values(int card_id, ULONG ctl_id, int *values_cnt);
136
137/*
138 * Simplified version of set new value for given control.
139 * Useful for simple types of data (integers, integer64, boolean, enum)
140 * if < 0 - error
141 */
142int _System uniaud_mixer_put_value(int card_id, ULONG put_id, int put_val, int put_cnt);
143
144/*
145 * Simplified version of get value for given control.
146 * Useful for simple types of data (integers, integer64, boolean, enum)
147 * if < 0 - error
148 */
149int _System uniaud_mixer_get_value(int card_id, ULONG put_id, int get_cnt);
150
151/*
152 * Simplified version of set new value for given control.
153 * Useful for simple types of data (integers, integer64, boolean, enum)
154 * Control is referenses by name
155 * if < 0 - error
156 */
157int _System uniaud_mixer_put_value_by_name(int card_id, char *name, int put_val, int put_cnt, int index);
158
159/*
160 * Simplified version of get value for given control.
161 * Useful for simple types of data (integers, integer64, boolean, enum)
162 * Control is referenses by name
163 * if < 0 - error
164 */
165int _System uniaud_mixer_get_value_by_name(int card_id, char *name, int get_cnt, int index);
166
167/*
168 * Set status bytes for SPDIF
169 * Control is referenses by name
170 * if < 0 - error
171 */
172int _System uniaud_mixer_put_spdif_status(int card_id, char *name, int aes0, int aes1, int aes2, int aes3);
173
174
175/*
176 * PCM API
177 */
178
179/*
180 * Return number of PCM instances for given card
181 * PCM instance is an abstraction layer of an card
182 * Each card may have one or more PCM instance
183 * Each PCM instance may have different properties
184 * Each PCM instance can have one or more PLAY or/and RECORD
185 * substreams
186 * Each PCM instance allowed open so many times as many substreams
187 * it have
188 */
189int _System uniaud_get_pcm_instances(int card_id);
190/*
191 *
192 */
193int _System uniaud_pcm_get_caps(int card_id, POSS32_DEVCAPS pcaps);
194/*
195 *
196 */
197int _System uniaud_pcm_find_pcm_for_chan(POSS32_DEVCAPS pcaps, int pcms, int type, int channels);
198/*
199 *
200 */
201int _System uniaud_pcm_set_pcm(int pcm);
202/*
203 *
204 */
205int _System uniaud_pcm_find_max_chan(POSS32_DEVCAPS pcaps, int pcms, int type);
206
207int _System uniaud_get_max_channels(int card_id);
208
209/**
210 * \brief Return bytes needed to store a quantity of PCM sample
211 * \param format Sample format
212 * \param samples Samples count
213 * \return bytes needed, a negative error code if not integer or unknown
214 */
215ssize_t _System uniaud_pcm_format_size(snd_pcm_format_t format, size_t samples);
216
217/*
218 * Open an PCM.
219 * card_id - logical ID of card from 0 to 7
220 * type - PCM type: 0 - PLAY, 1 - RECORD
221 * pcm_instance - instance of PCM
222 * access_flag - exclusive OPEN or not
223 * sample_rate - sample rate
224 * channels - number of wanted channels
225 * pcm_format - see snd_pcm_format_t
226 * on successful open returns 0 and pointer to uniaud_pcm structure
227 */
228int _System uniaud_pcm_open(int card_id, int type, int pcm_instance, int access_flag,
229 int sample_rate, int channels, int pcm_format,
230 uniaud_pcm **pcm);
231/*
232 *
233 */
234int _System uniaud_pcm_close(uniaud_pcm *pcm);
235
236/*
237 *
238 */
239int _System uniaud_pcm_write(uniaud_pcm *pcm, char* buffer, int size);
240
241/*
242 *
243 */
244int _System uniaud_pcm_read(uniaud_pcm *pcm, char* buffer, int size);
245
246/*
247 *
248 */
249int _System uniaud_pcm_prepare(uniaud_pcm *pcm);
250/*
251 *
252 */
253int _System uniaud_pcm_resume(uniaud_pcm *pcm);
254/*
255 *
256 */
257int _System uniaud_pcm_status(uniaud_pcm *pcm, snd_pcm_status_t *status);
258/*
259 *
260 */
261int _System uniaud_pcm_state(uniaud_pcm *pcm);
262/*
263 *
264 */
265int _System uniaud_pcm_wait(uniaud_pcm *pcm, int timeout);
266/*
267 *
268 */
269int _System uniaud_pcm_pause(uniaud_pcm *pcm);
270/*
271 *
272 */
273int _System uniaud_pcm_start(uniaud_pcm *pcm);
274/*
275 *
276 */
277int _System uniaud_pcm_drop(uniaud_pcm *pcm);
278
279/*
280 *
281 */
282int _System uniaud_close_all_pcms(int unlock);
283
284/*
285 * Common API
286 */
287
288/*
289 *
290 */
291int _System uniaud_get_cards(void);
292/*
293 *
294 */
295int _System uniaud_get_card_info(int card_id, UniaudCardInfo *info);
296/*
297 *
298 */
299int _System uniaud_get_version(void);
300
301void _System _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params);
302
303/**
304 * \brief Fill params with a full configuration space for a PCM
305 * \param pcm PCM handle
306 * \param params Configuration space
307 */
308int _System snd_pcm_hw_params_any(uniaud_pcm *pcm, snd_pcm_hw_params_t *params);
309
310int _System _snd_pcm_hw_param_set(snd_pcm_hw_params_t *params,
311 snd_pcm_hw_param_t var, unsigned int val, int dir);
312
313int _System _uniaud_pcm_refine_hw_params(uniaud_pcm *pcm, snd_pcm_hw_params_t *pparams);
314int _System _uniaud_pcm_set_hw_params(uniaud_pcm *pcm, snd_pcm_hw_params_t *pparams);
315int _System _uniaud_pcm_set_sw_params(uniaud_pcm *pcm, snd_pcm_sw_params_t *pparams);
316
317#endif //__UNIAUD__
Note: See TracBrowser for help on using the repository browser.