2 * \file include/pcm_extplug.h
3 * \brief External Filter-Plugin SDK
4 * \author Takashi Iwai <tiwai@suse.de>
7 * External Filter-Plugin SDK
11 * ALSA external PCM plugin SDK (draft version)
13 * Copyright (c) 2005 Takashi Iwai <tiwai@suse.de>
15 * This library is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License as
17 * published by the Free Software Foundation; either version 2.1 of
18 * the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU Lesser General Public License for more details.
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #ifndef __ALSA_PCM_EXTPLUG_H
32 #define __ALSA_PCM_EXTPLUG_H
35 * \defgroup PCM_ExtPlug External Filter plugin SDK
37 * See the \ref pcm page for more details.
41 /** hw constraints for extplug */
43 SND_PCM_EXTPLUG_HW_FORMAT, /**< format */
44 SND_PCM_EXTPLUG_HW_CHANNELS, /**< channels */
45 SND_PCM_EXTPLUG_HW_PARAMS /**< max number of hw constraints */
48 /** Handle of external filter plugin */
49 typedef struct snd_pcm_extplug snd_pcm_extplug_t;
50 /** Callback table of extplug */
51 typedef struct snd_pcm_extplug_callback snd_pcm_extplug_callback_t;
53 /* redefine typedefs for stupid doxygen */
54 typedef snd_pcm_extplug snd_pcm_extplug_t;
55 typedef snd_pcm_extplug_callback snd_pcm_extplug_callback_t;
61 #define SND_PCM_EXTPLUG_VERSION_MAJOR 1 /**< Protocol major version */
62 #define SND_PCM_EXTPLUG_VERSION_MINOR 0 /**< Protocol minor version */
63 #define SND_PCM_EXTPLUG_VERSION_TINY 2 /**< Protocol tiny version */
65 * Filter-plugin protocol version
67 #define SND_PCM_EXTPLUG_VERSION ((SND_PCM_EXTPLUG_VERSION_MAJOR<<16) |\
68 (SND_PCM_EXTPLUG_VERSION_MINOR<<8) |\
69 (SND_PCM_EXTPLUG_VERSION_TINY))
71 /** Handle of extplug */
72 struct snd_pcm_extplug {
74 * protocol version; #SND_PCM_EXTPLUG_VERSION must be filled here
75 * before calling #snd_pcm_extplug_create()
79 * name of this plugin; must be filled before calling #snd_pcm_extplug_create()
83 * callbacks of this plugin; must be filled before calling #snd_pcm_extplug_create()
85 const snd_pcm_extplug_callback_t *callback;
87 * private data, which can be used freely in the driver callbacks
91 * PCM handle filled by #snd_pcm_extplug_create()
95 * stream direction; read-only status
97 snd_pcm_stream_t stream;
99 * format hw parameter; filled after hw_params is caled
101 snd_pcm_format_t format;
103 * subformat hw parameter; filled after hw_params is caled
105 snd_pcm_subformat_t subformat;
107 * channels hw parameter; filled after hw_params is caled
109 unsigned int channels;
111 * rate hw parameter; filled after hw_params is caled
115 * slave_format hw parameter; filled after hw_params is caled
117 snd_pcm_format_t slave_format;
119 * slave_subformat hw parameter; filled after hw_params is caled
121 snd_pcm_subformat_t slave_subformat;
123 * slave_channels hw parameter; filled after hw_params is caled
125 unsigned int slave_channels;
128 /** Callback table of extplug */
129 struct snd_pcm_extplug_callback {
131 * transfer between source and destination; this is a required callback
133 snd_pcm_sframes_t (*transfer)(snd_pcm_extplug_t *ext,
134 const snd_pcm_channel_area_t *dst_areas,
135 snd_pcm_uframes_t dst_offset,
136 const snd_pcm_channel_area_t *src_areas,
137 snd_pcm_uframes_t src_offset,
138 snd_pcm_uframes_t size);
140 * close the PCM; optional
142 int (*close)(snd_pcm_extplug_t *ext);
144 * hw_params; optional
146 int (*hw_params)(snd_pcm_extplug_t *ext, snd_pcm_hw_params_t *params);
150 int (*hw_free)(snd_pcm_extplug_t *ext);
154 void (*dump)(snd_pcm_extplug_t *ext, snd_output_t *out);
156 * init; optional initialization called at prepare or reset
158 int (*init)(snd_pcm_extplug_t *ext);
160 * query the channel maps; optional; since v1.0.2
162 snd_pcm_chmap_query_t **(*query_chmaps)(snd_pcm_extplug_t *ext);
164 * get the channel map; optional; since v1.0.2
166 snd_pcm_chmap_t *(*get_chmap)(snd_pcm_extplug_t *ext);
168 * set the channel map; optional; since v1.0.2
170 int (*set_chmap)(snd_pcm_extplug_t *ext, const snd_pcm_chmap_t *map);
174 int snd_pcm_extplug_create(snd_pcm_extplug_t *ext, const char *name,
175 snd_config_t *root, snd_config_t *slave_conf,
176 snd_pcm_stream_t stream, int mode);
177 int snd_pcm_extplug_delete(snd_pcm_extplug_t *ext);
179 /* clear hw_parameter setting */
180 void snd_pcm_extplug_params_reset(snd_pcm_extplug_t *ext);
182 /* hw_parameter setting */
183 int snd_pcm_extplug_set_param_list(snd_pcm_extplug_t *extplug, int type, unsigned int num_list, const unsigned int *list);
184 int snd_pcm_extplug_set_param_minmax(snd_pcm_extplug_t *extplug, int type, unsigned int min, unsigned int max);
185 int snd_pcm_extplug_set_slave_param_list(snd_pcm_extplug_t *extplug, int type, unsigned int num_list, const unsigned int *list);
186 int snd_pcm_extplug_set_slave_param_minmax(snd_pcm_extplug_t *extplug, int type, unsigned int min, unsigned int max);
189 * set the parameter constraint with a single value
191 static __inline__ int snd_pcm_extplug_set_param(snd_pcm_extplug_t *extplug, int type, unsigned int val)
193 return snd_pcm_extplug_set_param_list(extplug, type, 1, &val);
197 * set the parameter constraint for slave PCM with a single value
199 static __inline__ int snd_pcm_extplug_set_slave_param(snd_pcm_extplug_t *extplug, int type, unsigned int val)
201 return snd_pcm_extplug_set_slave_param_list(extplug, type, 1, &val);
206 #endif /* __ALSA_PCM_EXTPLUG_H */