annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/alsa/pcm_ioplug.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 /**
jpayne@69 2 * \file include/pcm_ioplug.h
jpayne@69 3 * \brief External I/O-Plugin SDK
jpayne@69 4 * \author Takashi Iwai <tiwai@suse.de>
jpayne@69 5 * \date 2005
jpayne@69 6 *
jpayne@69 7 * External I/O-Plugin SDK
jpayne@69 8 */
jpayne@69 9
jpayne@69 10 /*
jpayne@69 11 * ALSA external PCM plugin SDK
jpayne@69 12 *
jpayne@69 13 * Copyright (c) 2005 Takashi Iwai <tiwai@suse.de>
jpayne@69 14 *
jpayne@69 15 * This library is free software; you can redistribute it and/or modify
jpayne@69 16 * it under the terms of the GNU Lesser General Public License as
jpayne@69 17 * published by the Free Software Foundation; either version 2.1 of
jpayne@69 18 * the License, or (at your option) any later version.
jpayne@69 19 *
jpayne@69 20 * This program is distributed in the hope that it will be useful,
jpayne@69 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jpayne@69 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
jpayne@69 23 * GNU Lesser General Public License for more details.
jpayne@69 24 *
jpayne@69 25 * You should have received a copy of the GNU Lesser General Public
jpayne@69 26 * License along with this library; if not, write to the Free Software
jpayne@69 27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
jpayne@69 28 *
jpayne@69 29 */
jpayne@69 30
jpayne@69 31 #ifndef __ALSA_PCM_IOPLUG_H
jpayne@69 32 #define __ALSA_PCM_IOPLUG_H
jpayne@69 33
jpayne@69 34 /**
jpayne@69 35 * \defgroup PCM_IOPlug External I/O plugin SDK
jpayne@69 36 * \ingroup Plugin_SDK
jpayne@69 37 * See the \ref pcm page for more details.
jpayne@69 38 * \{
jpayne@69 39 */
jpayne@69 40
jpayne@69 41 /** hw constraints for ioplug */
jpayne@69 42 enum {
jpayne@69 43 SND_PCM_IOPLUG_HW_ACCESS = 0, /**< access type */
jpayne@69 44 SND_PCM_IOPLUG_HW_FORMAT, /**< format */
jpayne@69 45 SND_PCM_IOPLUG_HW_CHANNELS, /**< channels */
jpayne@69 46 SND_PCM_IOPLUG_HW_RATE, /**< rate */
jpayne@69 47 SND_PCM_IOPLUG_HW_PERIOD_BYTES, /**< period bytes */
jpayne@69 48 SND_PCM_IOPLUG_HW_BUFFER_BYTES, /**< buffer bytes */
jpayne@69 49 SND_PCM_IOPLUG_HW_PERIODS, /**< number of periods */
jpayne@69 50 SND_PCM_IOPLUG_HW_PARAMS /**< max number of hw constraints */
jpayne@69 51 };
jpayne@69 52
jpayne@69 53 /** I/O plugin handle */
jpayne@69 54 typedef struct snd_pcm_ioplug snd_pcm_ioplug_t;
jpayne@69 55 /** Callback table of ioplug */
jpayne@69 56 typedef struct snd_pcm_ioplug_callback snd_pcm_ioplug_callback_t;
jpayne@69 57 #ifdef DOC_HIDDEN
jpayne@69 58 /* redefine typedefs for stupid doxygen */
jpayne@69 59 typedef snd_pcm_ioplug snd_pcm_ioplug_t;
jpayne@69 60 typedef snd_pcm_ioplug_callback snd_pcm_ioplug_callback_t;
jpayne@69 61 #endif
jpayne@69 62
jpayne@69 63 /*
jpayne@69 64 * bit flags for additional conditions
jpayne@69 65 */
jpayne@69 66 #define SND_PCM_IOPLUG_FLAG_LISTED (1<<0) /**< list up this PCM */
jpayne@69 67 #define SND_PCM_IOPLUG_FLAG_MONOTONIC (1<<1) /**< monotonic timestamps */
jpayne@69 68 /** hw pointer wrap around at boundary instead of buffer_size */
jpayne@69 69 #define SND_PCM_IOPLUG_FLAG_BOUNDARY_WA (1<<2)
jpayne@69 70
jpayne@69 71 /*
jpayne@69 72 * Protocol version
jpayne@69 73 */
jpayne@69 74 #define SND_PCM_IOPLUG_VERSION_MAJOR 1 /**< Protocol major version */
jpayne@69 75 #define SND_PCM_IOPLUG_VERSION_MINOR 0 /**< Protocol minor version */
jpayne@69 76 #define SND_PCM_IOPLUG_VERSION_TINY 2 /**< Protocol tiny version */
jpayne@69 77 /**
jpayne@69 78 * IO-plugin protocol version
jpayne@69 79 */
jpayne@69 80 #define SND_PCM_IOPLUG_VERSION ((SND_PCM_IOPLUG_VERSION_MAJOR<<16) |\
jpayne@69 81 (SND_PCM_IOPLUG_VERSION_MINOR<<8) |\
jpayne@69 82 (SND_PCM_IOPLUG_VERSION_TINY))
jpayne@69 83
jpayne@69 84 /** Handle of ioplug */
jpayne@69 85 struct snd_pcm_ioplug {
jpayne@69 86 /**
jpayne@69 87 * protocol version; #SND_PCM_IOPLUG_VERSION must be filled here
jpayne@69 88 * before calling #snd_pcm_ioplug_create()
jpayne@69 89 */
jpayne@69 90 unsigned int version;
jpayne@69 91 /**
jpayne@69 92 * name of this plugin; must be filled before calling #snd_pcm_ioplug_create()
jpayne@69 93 */
jpayne@69 94 const char *name;
jpayne@69 95 unsigned int flags; /**< SND_PCM_IOPLUG_FLAG_XXX */
jpayne@69 96 int poll_fd; /**< poll file descriptor */
jpayne@69 97 unsigned int poll_events; /**< poll events */
jpayne@69 98 unsigned int mmap_rw; /**< pseudo mmap mode */
jpayne@69 99 /**
jpayne@69 100 * callbacks of this plugin; must be filled before calling #snd_pcm_ioplug_create()
jpayne@69 101 */
jpayne@69 102 const snd_pcm_ioplug_callback_t *callback;
jpayne@69 103 /**
jpayne@69 104 * private data, which can be used freely in the driver callbacks
jpayne@69 105 */
jpayne@69 106 void *private_data;
jpayne@69 107 /**
jpayne@69 108 * PCM handle filled by #snd_pcm_ioplug_create()
jpayne@69 109 */
jpayne@69 110 snd_pcm_t *pcm;
jpayne@69 111
jpayne@69 112 snd_pcm_stream_t stream; /**< stream direcion; read-only */
jpayne@69 113 snd_pcm_state_t state; /**< current PCM state; read-only */
jpayne@69 114 volatile snd_pcm_uframes_t appl_ptr; /**< application pointer; read-only */
jpayne@69 115 volatile snd_pcm_uframes_t hw_ptr; /**< hw pointer; read-only */
jpayne@69 116 int nonblock; /**< non-block mode; read-only */
jpayne@69 117
jpayne@69 118 snd_pcm_access_t access; /**< access type; filled after hw_params is called */
jpayne@69 119 snd_pcm_format_t format; /**< PCM format; filled after hw_params is called */
jpayne@69 120 unsigned int channels; /**< number of channels; filled after hw_params is called */
jpayne@69 121 unsigned int rate; /**< rate; filled after hw_params is called */
jpayne@69 122 snd_pcm_uframes_t period_size; /**< period size; filled after hw_params is called */
jpayne@69 123 snd_pcm_uframes_t buffer_size; /**< buffer size; filled after hw_params is called */
jpayne@69 124 };
jpayne@69 125
jpayne@69 126 /** Callback table of ioplug */
jpayne@69 127 struct snd_pcm_ioplug_callback {
jpayne@69 128 /**
jpayne@69 129 * start the PCM; required, called inside mutex lock
jpayne@69 130 */
jpayne@69 131 int (*start)(snd_pcm_ioplug_t *io);
jpayne@69 132 /**
jpayne@69 133 * stop the PCM; required, called inside mutex lock
jpayne@69 134 */
jpayne@69 135 int (*stop)(snd_pcm_ioplug_t *io);
jpayne@69 136 /**
jpayne@69 137 * get the current DMA position; required, called inside mutex lock
jpayne@69 138 * \return buffer position up to buffer_size or
jpayne@69 139 * when #SND_PCM_IOPLUG_FLAG_BOUNDARY_WA flag is set up to boundary or
jpayne@69 140 * a negative error code for Xrun
jpayne@69 141 */
jpayne@69 142 snd_pcm_sframes_t (*pointer)(snd_pcm_ioplug_t *io);
jpayne@69 143 /**
jpayne@69 144 * transfer the data; optional, called inside mutex lock
jpayne@69 145 */
jpayne@69 146 snd_pcm_sframes_t (*transfer)(snd_pcm_ioplug_t *io,
jpayne@69 147 const snd_pcm_channel_area_t *areas,
jpayne@69 148 snd_pcm_uframes_t offset,
jpayne@69 149 snd_pcm_uframes_t size);
jpayne@69 150 /**
jpayne@69 151 * close the PCM; optional
jpayne@69 152 */
jpayne@69 153 int (*close)(snd_pcm_ioplug_t *io);
jpayne@69 154 /**
jpayne@69 155 * hw_params; optional
jpayne@69 156 */
jpayne@69 157 int (*hw_params)(snd_pcm_ioplug_t *io, snd_pcm_hw_params_t *params);
jpayne@69 158 /**
jpayne@69 159 * hw_free; optional
jpayne@69 160 */
jpayne@69 161 int (*hw_free)(snd_pcm_ioplug_t *io);
jpayne@69 162 /**
jpayne@69 163 * sw_params; optional
jpayne@69 164 */
jpayne@69 165 int (*sw_params)(snd_pcm_ioplug_t *io, snd_pcm_sw_params_t *params);
jpayne@69 166 /**
jpayne@69 167 * prepare; optional
jpayne@69 168 */
jpayne@69 169 int (*prepare)(snd_pcm_ioplug_t *io);
jpayne@69 170 /**
jpayne@69 171 * drain; optional
jpayne@69 172 */
jpayne@69 173 int (*drain)(snd_pcm_ioplug_t *io);
jpayne@69 174 /**
jpayne@69 175 * toggle pause; optional, called inside mutex lock
jpayne@69 176 */
jpayne@69 177 int (*pause)(snd_pcm_ioplug_t *io, int enable);
jpayne@69 178 /**
jpayne@69 179 * resume; optional
jpayne@69 180 */
jpayne@69 181 int (*resume)(snd_pcm_ioplug_t *io);
jpayne@69 182 /**
jpayne@69 183 * poll descriptors count; optional
jpayne@69 184 */
jpayne@69 185 int (*poll_descriptors_count)(snd_pcm_ioplug_t *io);
jpayne@69 186 /**
jpayne@69 187 * poll descriptors; optional
jpayne@69 188 */
jpayne@69 189 int (*poll_descriptors)(snd_pcm_ioplug_t *io, struct pollfd *pfd, unsigned int space);
jpayne@69 190 /**
jpayne@69 191 * mangle poll events; optional
jpayne@69 192 */
jpayne@69 193 int (*poll_revents)(snd_pcm_ioplug_t *io, struct pollfd *pfd, unsigned int nfds, unsigned short *revents);
jpayne@69 194 /**
jpayne@69 195 * dump; optional
jpayne@69 196 */
jpayne@69 197 void (*dump)(snd_pcm_ioplug_t *io, snd_output_t *out);
jpayne@69 198 /**
jpayne@69 199 * get the delay for the running PCM; optional; since v1.0.1
jpayne@69 200 */
jpayne@69 201 int (*delay)(snd_pcm_ioplug_t *io, snd_pcm_sframes_t *delayp);
jpayne@69 202 /**
jpayne@69 203 * query the channel maps; optional; since v1.0.2
jpayne@69 204 */
jpayne@69 205 snd_pcm_chmap_query_t **(*query_chmaps)(snd_pcm_ioplug_t *io);
jpayne@69 206 /**
jpayne@69 207 * get the channel map; optional; since v1.0.2
jpayne@69 208 */
jpayne@69 209 snd_pcm_chmap_t *(*get_chmap)(snd_pcm_ioplug_t *io);
jpayne@69 210 /**
jpayne@69 211 * set the channel map; optional; since v1.0.2
jpayne@69 212 */
jpayne@69 213 int (*set_chmap)(snd_pcm_ioplug_t *io, const snd_pcm_chmap_t *map);
jpayne@69 214 };
jpayne@69 215
jpayne@69 216
jpayne@69 217 int snd_pcm_ioplug_create(snd_pcm_ioplug_t *io, const char *name,
jpayne@69 218 snd_pcm_stream_t stream, int mode);
jpayne@69 219 int snd_pcm_ioplug_delete(snd_pcm_ioplug_t *io);
jpayne@69 220
jpayne@69 221 /* update poll_fd and mmap_rw */
jpayne@69 222 int snd_pcm_ioplug_reinit_status(snd_pcm_ioplug_t *ioplug);
jpayne@69 223
jpayne@69 224 /* get a mmap area (for mmap_rw only) */
jpayne@69 225 const snd_pcm_channel_area_t *snd_pcm_ioplug_mmap_areas(snd_pcm_ioplug_t *ioplug);
jpayne@69 226
jpayne@69 227 /* clear hw_parameter setting */
jpayne@69 228 void snd_pcm_ioplug_params_reset(snd_pcm_ioplug_t *io);
jpayne@69 229
jpayne@69 230 /* hw_parameter setting */
jpayne@69 231 int snd_pcm_ioplug_set_param_minmax(snd_pcm_ioplug_t *io, int type, unsigned int min, unsigned int max);
jpayne@69 232 int snd_pcm_ioplug_set_param_list(snd_pcm_ioplug_t *io, int type, unsigned int num_list, const unsigned int *list);
jpayne@69 233
jpayne@69 234 /* change PCM status */
jpayne@69 235 int snd_pcm_ioplug_set_state(snd_pcm_ioplug_t *ioplug, snd_pcm_state_t state);
jpayne@69 236
jpayne@69 237 /* calucalte the available frames */
jpayne@69 238 snd_pcm_uframes_t snd_pcm_ioplug_avail(const snd_pcm_ioplug_t * const ioplug,
jpayne@69 239 const snd_pcm_uframes_t hw_ptr,
jpayne@69 240 const snd_pcm_uframes_t appl_ptr);
jpayne@69 241 snd_pcm_uframes_t snd_pcm_ioplug_hw_avail(const snd_pcm_ioplug_t * const ioplug,
jpayne@69 242 const snd_pcm_uframes_t hw_ptr,
jpayne@69 243 const snd_pcm_uframes_t appl_ptr);
jpayne@69 244
jpayne@69 245 /** \} */
jpayne@69 246
jpayne@69 247 #endif /* __ALSA_PCM_IOPLUG_H */