ALSA project - the C library reference

Loading...
Searching...
No Matches
pcm_ioplug.h
Go to the documentation of this file.
1
10/*
11 * ALSA external PCM plugin SDK
12 *
13 * Copyright (c) 2005 Takashi Iwai <tiwai@suse.de>
14 *
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.
19 *
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.
24 *
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28 *
29 */
30
31#if !defined(__ALSA_PCM_EXTERNAL_H) && !defined(ALSA_LIBRARY_BUILD)
32#warning "use #include <alsa/pcm_external.h>, <alsa/pcm_ioplug.h> should not be used directly"
33#include <alsa/pcm_external.h>
34#endif
35
36#ifndef __ALSA_PCM_IOPLUG_H
37#define __ALSA_PCM_IOPLUG_H
47 enum {
48 SND_PCM_IOPLUG_HW_ACCESS = 0,
49 SND_PCM_IOPLUG_HW_FORMAT,
50 SND_PCM_IOPLUG_HW_CHANNELS,
51 SND_PCM_IOPLUG_HW_RATE,
52 SND_PCM_IOPLUG_HW_PERIOD_BYTES,
53 SND_PCM_IOPLUG_HW_BUFFER_BYTES,
54 SND_PCM_IOPLUG_HW_PERIODS,
55 SND_PCM_IOPLUG_HW_PARAMS
56};
57
59 typedef struct snd_pcm_ioplug snd_pcm_ioplug_t;
61 typedef struct snd_pcm_ioplug_callback snd_pcm_ioplug_callback_t;
62#ifdef DOC_HIDDEN
63/* redefine typedefs for stupid doxygen */
64 typedef snd_pcm_ioplug snd_pcm_ioplug_t;
65 typedef snd_pcm_ioplug_callback snd_pcm_ioplug_callback_t;
66#endif
67
68/*
69 * bit flags for additional conditions
70 */
71#define SND_PCM_IOPLUG_FLAG_LISTED (1<<0)
72#define SND_PCM_IOPLUG_FLAG_MONOTONIC (1<<1)
74#define SND_PCM_IOPLUG_FLAG_BOUNDARY_WA (1<<2)
75
76/*
77 * Protocol version
78 */
79#define SND_PCM_IOPLUG_VERSION_MAJOR 1
80#define SND_PCM_IOPLUG_VERSION_MINOR 0
81#define SND_PCM_IOPLUG_VERSION_TINY 2
85#define SND_PCM_IOPLUG_VERSION ((SND_PCM_IOPLUG_VERSION_MAJOR<<16) |\
86 (SND_PCM_IOPLUG_VERSION_MINOR<<8) |\
87 (SND_PCM_IOPLUG_VERSION_TINY))
88
90 struct snd_pcm_ioplug {
95 unsigned int version;
99 const char *name;
100 unsigned int flags;
101 int poll_fd;
102 unsigned int poll_events;
103 unsigned int mmap_rw;
107 const snd_pcm_ioplug_callback_t *callback;
111 void *private_data;
115 snd_pcm_t *pcm;
116
117 snd_pcm_stream_t stream;
118 snd_pcm_state_t state;
119 volatile snd_pcm_uframes_t appl_ptr;
120 volatile snd_pcm_uframes_t hw_ptr;
121 int nonblock;
123 snd_pcm_access_t access;
124 snd_pcm_format_t format;
125 unsigned int channels;
126 unsigned int rate;
127 snd_pcm_uframes_t period_size;
128 snd_pcm_uframes_t buffer_size;
129};
130
132 struct snd_pcm_ioplug_callback {
136 int (*start)(snd_pcm_ioplug_t *io);
140 int (*stop)(snd_pcm_ioplug_t *io);
147 snd_pcm_sframes_t (*pointer)(snd_pcm_ioplug_t *io);
151 snd_pcm_sframes_t (*transfer)(snd_pcm_ioplug_t *io,
152 const snd_pcm_channel_area_t *areas,
153 snd_pcm_uframes_t offset,
154 snd_pcm_uframes_t size);
158 int (*close)(snd_pcm_ioplug_t *io);
162 int (*hw_params)(snd_pcm_ioplug_t *io, snd_pcm_hw_params_t *params);
166 int (*hw_free)(snd_pcm_ioplug_t *io);
170 int (*sw_params)(snd_pcm_ioplug_t *io, snd_pcm_sw_params_t *params);
174 int (*prepare)(snd_pcm_ioplug_t *io);
178 int (*drain)(snd_pcm_ioplug_t *io);
182 int (*pause)(snd_pcm_ioplug_t *io, int enable);
186 int (*resume)(snd_pcm_ioplug_t *io);
190 int (*poll_descriptors_count)(snd_pcm_ioplug_t *io);
194 int (*poll_descriptors)(snd_pcm_ioplug_t *io, struct pollfd *pfd, unsigned int space);
198 int (*poll_revents)(snd_pcm_ioplug_t *io, struct pollfd *pfd, unsigned int nfds, unsigned short *revents);
202 void (*dump)(snd_pcm_ioplug_t *io, snd_output_t *out);
206 int (*delay)(snd_pcm_ioplug_t *io, snd_pcm_sframes_t *delayp);
210 snd_pcm_chmap_query_t **(*query_chmaps)(snd_pcm_ioplug_t *io);
214 snd_pcm_chmap_t *(*get_chmap)(snd_pcm_ioplug_t *io);
218 int (*set_chmap)(snd_pcm_ioplug_t *io, const snd_pcm_chmap_t *map);
219};
220
221
222 int snd_pcm_ioplug_create(snd_pcm_ioplug_t *io, const char *name,
223 snd_pcm_stream_t stream, int mode);
224 int snd_pcm_ioplug_delete(snd_pcm_ioplug_t *io);
225
226/* update poll_fd and mmap_rw */
227 int snd_pcm_ioplug_reinit_status(snd_pcm_ioplug_t *ioplug);
228
229/* get a mmap area (for mmap_rw only) */
230 const snd_pcm_channel_area_t *snd_pcm_ioplug_mmap_areas(snd_pcm_ioplug_t *ioplug);
231
232/* clear hw_parameter setting */
233 void snd_pcm_ioplug_params_reset(snd_pcm_ioplug_t *io);
234
235/* hw_parameter setting */
236 int snd_pcm_ioplug_set_param_minmax(snd_pcm_ioplug_t *io, int type, unsigned int min, unsigned int max);
237 int snd_pcm_ioplug_set_param_list(snd_pcm_ioplug_t *io, int type, unsigned int num_list, const unsigned int *list);
238
239/* change PCM status */
240 int snd_pcm_ioplug_set_state(snd_pcm_ioplug_t *ioplug, snd_pcm_state_t state);
241
242/* calucalte the available frames */
243 snd_pcm_uframes_t snd_pcm_ioplug_avail(const snd_pcm_ioplug_t * const ioplug,
244 const snd_pcm_uframes_t hw_ptr,
245 const snd_pcm_uframes_t appl_ptr);
246 snd_pcm_uframes_t snd_pcm_ioplug_hw_avail(const snd_pcm_ioplug_t * const ioplug,
247 const snd_pcm_uframes_t hw_ptr,
248 const snd_pcm_uframes_t appl_ptr);
249
252#endif /* __ALSA_PCM_IOPLUG_H */
snd_output_t
struct _snd_output snd_output_t
Internal structure for an output object.
Definition output.h:60
snd_pcm_ioplug_t
snd_pcm_ioplug snd_pcm_ioplug_t
Definition pcm_ioplug.h:64
snd_pcm_ioplug_avail
snd_pcm_uframes_t snd_pcm_ioplug_avail(const snd_pcm_ioplug_t *const ioplug, const snd_pcm_uframes_t hw_ptr, const snd_pcm_uframes_t appl_ptr)
Get the available frames. This function can be used to calculate the the available frames before call...
Definition pcm_ioplug.c:1256
snd_pcm_ioplug_delete
int snd_pcm_ioplug_delete(snd_pcm_ioplug_t *io)
Delete the ioplug instance.
Definition pcm_ioplug.c:1127
snd_pcm_ioplug_mmap_areas
const snd_pcm_channel_area_t * snd_pcm_ioplug_mmap_areas(snd_pcm_ioplug_t *ioplug)
Get mmap area of ioplug.
Definition pcm_ioplug.c:1225
snd_pcm_ioplug_hw_avail
snd_pcm_uframes_t snd_pcm_ioplug_hw_avail(const snd_pcm_ioplug_t *const ioplug, const snd_pcm_uframes_t hw_ptr, const snd_pcm_uframes_t appl_ptr)
Get the available frames. This function can be used to calculate the the available frames before call...
Definition pcm_ioplug.c:1271
snd_pcm_ioplug_set_state
int snd_pcm_ioplug_set_state(snd_pcm_ioplug_t *ioplug, snd_pcm_state_t state)
Change the ioplug PCM status.
Definition pcm_ioplug.c:1242
snd_pcm_ioplug_set_param_list
int snd_pcm_ioplug_set_param_list(snd_pcm_ioplug_t *io, int type, unsigned int num_list, const unsigned int *list)
Set parameter as the list.
Definition pcm_ioplug.c:1156
snd_pcm_ioplug_create
int snd_pcm_ioplug_create(snd_pcm_ioplug_t *io, const char *name, snd_pcm_stream_t stream, int mode)
Create an ioplug instance.
Definition pcm_ioplug.c:1074
snd_pcm_ioplug_callback_t
snd_pcm_ioplug_callback snd_pcm_ioplug_callback_t
Definition pcm_ioplug.h:65
snd_pcm_ioplug_reinit_status
int snd_pcm_ioplug_reinit_status(snd_pcm_ioplug_t *ioplug)
Reinitialize the poll and mmap status.
Definition pcm_ioplug.c:1205
snd_pcm_ioplug_set_param_minmax
int snd_pcm_ioplug_set_param_minmax(snd_pcm_ioplug_t *io, int type, unsigned int min, unsigned int max)
Set parameter as the min/max values.
Definition pcm_ioplug.c:1180
snd_pcm_ioplug_params_reset
void snd_pcm_ioplug_params_reset(snd_pcm_ioplug_t *io)
Reset ioplug parameters.
Definition pcm_ioplug.c:1139
SND_PCM_IOPLUG_HW_BUFFER_BYTES
@ SND_PCM_IOPLUG_HW_BUFFER_BYTES
Definition pcm_ioplug.h:53
SND_PCM_IOPLUG_HW_PERIODS
@ SND_PCM_IOPLUG_HW_PERIODS
Definition pcm_ioplug.h:54
SND_PCM_IOPLUG_HW_RATE
@ SND_PCM_IOPLUG_HW_RATE
Definition pcm_ioplug.h:51
SND_PCM_IOPLUG_HW_CHANNELS
@ SND_PCM_IOPLUG_HW_CHANNELS
Definition pcm_ioplug.h:50
SND_PCM_IOPLUG_HW_FORMAT
@ SND_PCM_IOPLUG_HW_FORMAT
Definition pcm_ioplug.h:49
SND_PCM_IOPLUG_HW_PERIOD_BYTES
@ SND_PCM_IOPLUG_HW_PERIOD_BYTES
Definition pcm_ioplug.h:52
SND_PCM_IOPLUG_HW_PARAMS
@ SND_PCM_IOPLUG_HW_PARAMS
Definition pcm_ioplug.h:55
SND_PCM_IOPLUG_HW_ACCESS
@ SND_PCM_IOPLUG_HW_ACCESS
Definition pcm_ioplug.h:48
snd_pcm_state_t
snd_pcm_state_t
Definition pcm.h:303
snd_pcm_hw_params_t
struct _snd_pcm_hw_params snd_pcm_hw_params_t
Definition pcm.h:68
snd_pcm_access_t
snd_pcm_access_t
Definition pcm.h:114
snd_pcm_sframes_t
long snd_pcm_sframes_t
Definition pcm.h:402
snd_pcm_sw_params_t
struct _snd_pcm_sw_params snd_pcm_sw_params_t
Definition pcm.h:71
snd_pcm_t
struct _snd_pcm snd_pcm_t
Definition pcm.h:422
snd_pcm_format_t
snd_pcm_format_t
Definition pcm.h:129
snd_pcm_uframes_t
unsigned long snd_pcm_uframes_t
Definition pcm.h:400
snd_pcm_stream_t
snd_pcm_stream_t
Definition pcm.h:105
snd_pcm_channel_area_t
Definition pcm.h:496
snd_pcm_chmap_query_t
Definition pcm.h:652
snd_pcm_chmap_t
Definition pcm.h:646
snd_pcm_ioplug_callback
Definition pcm_ioplug.h:132
snd_pcm_ioplug_callback::prepare
int(* prepare)(snd_pcm_ioplug_t *io)
Definition pcm_ioplug.h:174
snd_pcm_ioplug_callback::resume
int(* resume)(snd_pcm_ioplug_t *io)
Definition pcm_ioplug.h:186
snd_pcm_ioplug_callback::close
int(* close)(snd_pcm_ioplug_t *io)
Definition pcm_ioplug.h:158
snd_pcm_ioplug_callback::pointer
snd_pcm_sframes_t(* pointer)(snd_pcm_ioplug_t *io)
Definition pcm_ioplug.h:147
snd_pcm_ioplug_callback::delay
int(* delay)(snd_pcm_ioplug_t *io, snd_pcm_sframes_t *delayp)
Definition pcm_ioplug.h:206
snd_pcm_ioplug_callback::hw_params
int(* hw_params)(snd_pcm_ioplug_t *io, snd_pcm_hw_params_t *params)
Definition pcm_ioplug.h:162
snd_pcm_ioplug_callback::drain
int(* drain)(snd_pcm_ioplug_t *io)
Definition pcm_ioplug.h:178
snd_pcm_ioplug_callback::poll_descriptors_count
int(* poll_descriptors_count)(snd_pcm_ioplug_t *io)
Definition pcm_ioplug.h:190
snd_pcm_ioplug_callback::poll_descriptors
int(* poll_descriptors)(snd_pcm_ioplug_t *io, struct pollfd *pfd, unsigned int space)
Definition pcm_ioplug.h:194
snd_pcm_ioplug_callback::pause
int(* pause)(snd_pcm_ioplug_t *io, int enable)
Definition pcm_ioplug.h:182
snd_pcm_ioplug_callback::start
int(* start)(snd_pcm_ioplug_t *io)
Definition pcm_ioplug.h:136
snd_pcm_ioplug_callback::poll_revents
int(* poll_revents)(snd_pcm_ioplug_t *io, struct pollfd *pfd, unsigned int nfds, unsigned short *revents)
Definition pcm_ioplug.h:198
snd_pcm_ioplug_callback::dump
void(* dump)(snd_pcm_ioplug_t *io, snd_output_t *out)
Definition pcm_ioplug.h:202
snd_pcm_ioplug_callback::sw_params
int(* sw_params)(snd_pcm_ioplug_t *io, snd_pcm_sw_params_t *params)
Definition pcm_ioplug.h:170
snd_pcm_ioplug_callback::set_chmap
int(* set_chmap)(snd_pcm_ioplug_t *io, const snd_pcm_chmap_t *map)
Definition pcm_ioplug.h:218
snd_pcm_ioplug_callback::hw_free
int(* hw_free)(snd_pcm_ioplug_t *io)
Definition pcm_ioplug.h:166
snd_pcm_ioplug_callback::stop
int(* stop)(snd_pcm_ioplug_t *io)
Definition pcm_ioplug.h:140
snd_pcm_ioplug_callback::transfer
snd_pcm_sframes_t(* transfer)(snd_pcm_ioplug_t *io, const snd_pcm_channel_area_t *areas, snd_pcm_uframes_t offset, snd_pcm_uframes_t size)
Definition pcm_ioplug.h:151
snd_pcm_ioplug
Definition pcm_ioplug.h:90
snd_pcm_ioplug::format
snd_pcm_format_t format
Definition pcm_ioplug.h:124
snd_pcm_ioplug::name
const char * name
Definition pcm_ioplug.h:99
snd_pcm_ioplug::callback
const snd_pcm_ioplug_callback_t * callback
Definition pcm_ioplug.h:107
snd_pcm_ioplug::nonblock
int nonblock
Definition pcm_ioplug.h:121
snd_pcm_ioplug::buffer_size
snd_pcm_uframes_t buffer_size
Definition pcm_ioplug.h:128
snd_pcm_ioplug::appl_ptr
volatile snd_pcm_uframes_t appl_ptr
Definition pcm_ioplug.h:119
snd_pcm_ioplug::version
unsigned int version
Definition pcm_ioplug.h:95
snd_pcm_ioplug::stream
snd_pcm_stream_t stream
Definition pcm_ioplug.h:117
snd_pcm_ioplug::pcm
snd_pcm_t * pcm
Definition pcm_ioplug.h:115
snd_pcm_ioplug::state
snd_pcm_state_t state
Definition pcm_ioplug.h:118
snd_pcm_ioplug::hw_ptr
volatile snd_pcm_uframes_t hw_ptr
Definition pcm_ioplug.h:120
snd_pcm_ioplug::poll_events
unsigned int poll_events
Definition pcm_ioplug.h:102
snd_pcm_ioplug::poll_fd
int poll_fd
Definition pcm_ioplug.h:101
snd_pcm_ioplug::rate
unsigned int rate
Definition pcm_ioplug.h:126
snd_pcm_ioplug::private_data
void * private_data
Definition pcm_ioplug.h:111
snd_pcm_ioplug::access
snd_pcm_access_t access
Definition pcm_ioplug.h:123
snd_pcm_ioplug::channels
unsigned int channels
Definition pcm_ioplug.h:125
snd_pcm_ioplug::mmap_rw
unsigned int mmap_rw
Definition pcm_ioplug.h:103
snd_pcm_ioplug::period_size
snd_pcm_uframes_t period_size
Definition pcm_ioplug.h:127
snd_pcm_ioplug::flags
unsigned int flags
Definition pcm_ioplug.h:100
type
uint8_t type
Definition ump_msg.h:1