2 * \file include/pcm_ioplug.h
3 * \brief External I/O-Plugin SDK
4 * \author Takashi Iwai <tiwai@suse.de>
7 * External I/O-Plugin SDK
11 * ALSA external PCM plugin SDK
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_IOPLUG_H
32 #define __ALSA_PCM_IOPLUG_H
35 * \defgroup PCM_IOPlug External I/O plugin SDK
37 * See the \ref pcm page for more details.
41 /** hw constraints for ioplug */
43 SND_PCM_IOPLUG_HW_ACCESS = 0, /**< access type */
44 SND_PCM_IOPLUG_HW_FORMAT, /**< format */
45 SND_PCM_IOPLUG_HW_CHANNELS, /**< channels */
46 SND_PCM_IOPLUG_HW_RATE, /**< rate */
47 SND_PCM_IOPLUG_HW_PERIOD_BYTES, /**< period bytes */
48 SND_PCM_IOPLUG_HW_BUFFER_BYTES, /**< buffer bytes */
49 SND_PCM_IOPLUG_HW_PERIODS, /**< number of periods */
50 SND_PCM_IOPLUG_HW_PARAMS /**< max number of hw constraints */
53 /** I/O plugin handle */
54 typedef struct snd_pcm_ioplug snd_pcm_ioplug_t;
55 /** Callback table of ioplug */
56 typedef struct snd_pcm_ioplug_callback snd_pcm_ioplug_callback_t;
58 /* redefine typedefs for stupid doxygen */
59 typedef snd_pcm_ioplug snd_pcm_ioplug_t;
60 typedef snd_pcm_ioplug_callback snd_pcm_ioplug_callback_t;
64 * bit flags for additional conditions
66 #define SND_PCM_IOPLUG_FLAG_LISTED (1<<0) /**< list up this PCM */
67 #define SND_PCM_IOPLUG_FLAG_MONOTONIC (1<<1) /**< monotonic timestamps */
72 #define SND_PCM_IOPLUG_VERSION_MAJOR 1 /**< Protocol major version */
73 #define SND_PCM_IOPLUG_VERSION_MINOR 0 /**< Protocol minor version */
74 #define SND_PCM_IOPLUG_VERSION_TINY 2 /**< Protocol tiny version */
76 * IO-plugin protocol version
78 #define SND_PCM_IOPLUG_VERSION ((SND_PCM_IOPLUG_VERSION_MAJOR<<16) |\
79 (SND_PCM_IOPLUG_VERSION_MINOR<<8) |\
80 (SND_PCM_IOPLUG_VERSION_TINY))
82 /** Handle of ioplug */
83 struct snd_pcm_ioplug {
85 * protocol version; #SND_PCM_IOPLUG_VERSION must be filled here
86 * before calling #snd_pcm_ioplug_create()
90 * name of this plugin; must be filled before calling #snd_pcm_ioplug_create()
93 unsigned int flags; /**< SND_PCM_IOPLUG_FLAG_XXX */
94 int poll_fd; /**< poll file descriptor */
95 unsigned int poll_events; /**< poll events */
96 unsigned int mmap_rw; /**< pseudo mmap mode */
98 * callbacks of this plugin; must be filled before calling #snd_pcm_ioplug_create()
100 const snd_pcm_ioplug_callback_t *callback;
102 * private data, which can be used freely in the driver callbacks
106 * PCM handle filled by #snd_pcm_extplug_create()
110 snd_pcm_stream_t stream; /**< stream direcion; read-only */
111 snd_pcm_state_t state; /**< current PCM state; read-only */
112 volatile snd_pcm_uframes_t appl_ptr; /**< application pointer; read-only */
113 volatile snd_pcm_uframes_t hw_ptr; /**< hw pointer; read-only */
114 int nonblock; /**< non-block mode; read-only */
116 snd_pcm_access_t access; /**< access type; filled after hw_params is called */
117 snd_pcm_format_t format; /**< PCM format; filled after hw_params is called */
118 unsigned int channels; /**< number of channels; filled after hw_params is called */
119 unsigned int rate; /**< rate; filled after hw_params is called */
120 snd_pcm_uframes_t period_size; /**< period size; filled after hw_params is called */
121 snd_pcm_uframes_t buffer_size; /**< buffer size; filled after hw_params is called */
124 /** Callback table of ioplug */
125 struct snd_pcm_ioplug_callback {
127 * start the PCM; required
129 int (*start)(snd_pcm_ioplug_t *io);
131 * stop the PCM; required
133 int (*stop)(snd_pcm_ioplug_t *io);
135 * get the current DMA position; required
137 snd_pcm_sframes_t (*pointer)(snd_pcm_ioplug_t *io);
139 * transfer the data; optional
141 snd_pcm_sframes_t (*transfer)(snd_pcm_ioplug_t *io,
142 const snd_pcm_channel_area_t *areas,
143 snd_pcm_uframes_t offset,
144 snd_pcm_uframes_t size);
146 * close the PCM; optional
148 int (*close)(snd_pcm_ioplug_t *io);
150 * hw_params; optional
152 int (*hw_params)(snd_pcm_ioplug_t *io, snd_pcm_hw_params_t *params);
156 int (*hw_free)(snd_pcm_ioplug_t *io);
158 * sw_params; optional
160 int (*sw_params)(snd_pcm_ioplug_t *io, snd_pcm_sw_params_t *params);
164 int (*prepare)(snd_pcm_ioplug_t *io);
168 int (*drain)(snd_pcm_ioplug_t *io);
170 * toggle pause; optional
172 int (*pause)(snd_pcm_ioplug_t *io, int enable);
176 int (*resume)(snd_pcm_ioplug_t *io);
178 * poll descriptors count; optional
180 int (*poll_descriptors_count)(snd_pcm_ioplug_t *io);
182 * poll descriptors; optional
184 int (*poll_descriptors)(snd_pcm_ioplug_t *io, struct pollfd *pfd, unsigned int space);
186 * mangle poll events; optional
188 int (*poll_revents)(snd_pcm_ioplug_t *io, struct pollfd *pfd, unsigned int nfds, unsigned short *revents);
192 void (*dump)(snd_pcm_ioplug_t *io, snd_output_t *out);
194 * get the delay for the running PCM; optional; since v1.0.1
196 int (*delay)(snd_pcm_ioplug_t *io, snd_pcm_sframes_t *delayp);
198 * query the channel maps; optional; since v1.0.2
200 snd_pcm_chmap_query_t **(*query_chmaps)(snd_pcm_ioplug_t *io);
202 * get the channel map; optional; since v1.0.2
204 snd_pcm_chmap_t *(*get_chmap)(snd_pcm_ioplug_t *io);
206 * set the channel map; optional; since v1.0.2
208 int (*set_chmap)(snd_pcm_ioplug_t *io, const snd_pcm_chmap_t *map);
212 int snd_pcm_ioplug_create(snd_pcm_ioplug_t *io, const char *name,
213 snd_pcm_stream_t stream, int mode);
214 int snd_pcm_ioplug_delete(snd_pcm_ioplug_t *io);
216 /* update poll_fd and mmap_rw */
217 int snd_pcm_ioplug_reinit_status(snd_pcm_ioplug_t *ioplug);
219 /* get a mmap area (for mmap_rw only) */
220 const snd_pcm_channel_area_t *snd_pcm_ioplug_mmap_areas(snd_pcm_ioplug_t *ioplug);
222 /* clear hw_parameter setting */
223 void snd_pcm_ioplug_params_reset(snd_pcm_ioplug_t *io);
225 /* hw_parameter setting */
226 int snd_pcm_ioplug_set_param_minmax(snd_pcm_ioplug_t *io, int type, unsigned int min, unsigned int max);
227 int snd_pcm_ioplug_set_param_list(snd_pcm_ioplug_t *io, int type, unsigned int num_list, const unsigned int *list);
229 /* change PCM status */
230 int snd_pcm_ioplug_set_state(snd_pcm_ioplug_t *ioplug, snd_pcm_state_t state);
234 #endif /* __ALSA_PCM_IOPLUG_H */