2 * \file include/pcm_rate.h
3 * \brief External Rate-Converter-Plugin SDK
4 * \author Takashi Iwai <tiwai@suse.de>
7 * External Rate-Converter-Plugin SDK
11 * ALSA external PCM rate-converter plugin SDK (draft version)
13 * Copyright (c) 2006 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_RATE_H
32 #define __ALSA_PCM_RATE_H
41 #define SND_PCM_RATE_PLUGIN_VERSION 0x010002
43 /** hw_params information for a single side */
44 typedef struct snd_pcm_rate_side_info {
45 snd_pcm_format_t format;
47 snd_pcm_uframes_t buffer_size;
48 snd_pcm_uframes_t period_size;
49 } snd_pcm_rate_side_info_t;
51 /** hw_params information */
52 typedef struct snd_pcm_rate_info {
53 struct snd_pcm_rate_side_info in;
54 struct snd_pcm_rate_side_info out;
55 unsigned int channels;
56 } snd_pcm_rate_info_t;
58 /** Callback table of rate-converter */
59 typedef struct snd_pcm_rate_ops {
61 * close the converter; optional
63 void (*close)(void *obj);
65 * initialize the converter, called at hw_params
67 int (*init)(void *obj, snd_pcm_rate_info_t *info);
69 * free the converter; optional
71 void (*free)(void *obj);
73 * reset the converter, called at prepare; optional
75 void (*reset)(void *obj);
77 * adjust the pitch, called at sw_params; optional
79 int (*adjust_pitch)(void *obj, snd_pcm_rate_info_t *info);
83 void (*convert)(void *obj,
84 const snd_pcm_channel_area_t *dst_areas,
85 snd_pcm_uframes_t dst_offset, unsigned int dst_frames,
86 const snd_pcm_channel_area_t *src_areas,
87 snd_pcm_uframes_t src_offset, unsigned int src_frames);
89 * convert an s16 interleaved-data array; exclusive with convert
91 void (*convert_s16)(void *obj, int16_t *dst, unsigned int dst_frames,
92 const int16_t *src, unsigned int src_frames);
94 * compute the frame size for input
96 snd_pcm_uframes_t (*input_frames)(void *obj, snd_pcm_uframes_t frames);
98 * compute the frame size for output
100 snd_pcm_uframes_t (*output_frames)(void *obj, snd_pcm_uframes_t frames);
102 * the protocol version the plugin supports;
103 * new field since version 0x010002
105 unsigned int version;
107 * return the supported min / max sample rates;
108 * new ops since version 0x010002
110 int (*get_supported_rates)(void *obj, unsigned int *rate_min,
111 unsigned int *rate_max);
113 * show some status messages for verbose mode;
114 * new ops since version 0x010002
116 void (*dump)(void *obj, snd_output_t *out);
117 } snd_pcm_rate_ops_t;
119 /** open function type */
120 typedef int (*snd_pcm_rate_open_func_t)(unsigned int version, void **objp,
121 snd_pcm_rate_ops_t *opsp);
124 * Define the object entry for external PCM rate-converter plugins
126 #define SND_PCM_RATE_PLUGIN_ENTRY(name) _snd_pcm_rate_##name##_open
130 /* old rate_ops for protocol version 0x010001 */
131 typedef struct snd_pcm_rate_old_ops {
132 void (*close)(void *obj);
133 int (*init)(void *obj, snd_pcm_rate_info_t *info);
134 void (*free)(void *obj);
135 void (*reset)(void *obj);
136 int (*adjust_pitch)(void *obj, snd_pcm_rate_info_t *info);
137 void (*convert)(void *obj,
138 const snd_pcm_channel_area_t *dst_areas,
139 snd_pcm_uframes_t dst_offset, unsigned int dst_frames,
140 const snd_pcm_channel_area_t *src_areas,
141 snd_pcm_uframes_t src_offset, unsigned int src_frames);
142 void (*convert_s16)(void *obj, int16_t *dst, unsigned int dst_frames,
143 const int16_t *src, unsigned int src_frames);
144 snd_pcm_uframes_t (*input_frames)(void *obj, snd_pcm_uframes_t frames);
145 snd_pcm_uframes_t (*output_frames)(void *obj, snd_pcm_uframes_t frames);
146 } snd_pcm_rate_old_ops_t;
153 #endif /* __ALSA_PCM_RATE_H */