1 /** 2 * \file include/pcm_rate.h 3 * \brief External Rate-Converter-Plugin SDK 4 * \author Takashi Iwai <tiwai (at) suse.de> 5 * \date 2006 6 * 7 * External Rate-Converter-Plugin SDK 8 */ 9 10 /* 11 * ALSA external PCM rate-converter plugin SDK (draft version) 12 * 13 * Copyright (c) 2006 Takashi Iwai <tiwai (at) 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 28 * 29 */ 30 31 #ifndef __ALSA_PCM_RATE_H 32 #define __ALSA_PCM_RATE_H 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 /** 39 * Protocol version 40 */ 41 #define SND_PCM_RATE_PLUGIN_VERSION 0x010001 42 43 /** hw_params information for a single side */ 44 typedef struct snd_pcm_rate_side_info { 45 snd_pcm_format_t format; 46 unsigned int rate; 47 snd_pcm_uframes_t buffer_size; 48 snd_pcm_uframes_t period_size; 49 } snd_pcm_rate_side_info_t; 50 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; 57 58 /** Callback table of rate-converter */ 59 typedef struct snd_pcm_rate_ops { 60 /** 61 * close the converter; optional 62 */ 63 void (*close)(void *obj); 64 /** 65 * initialize the converter, called at hw_params 66 */ 67 int (*init)(void *obj, snd_pcm_rate_info_t *info); 68 /** 69 * free the converter; optional 70 */ 71 void (*free)(void *obj); 72 /** 73 * reset the converter, called at prepare; optional 74 */ 75 void (*reset)(void *obj); 76 /** 77 * adjust the pitch, called at sw_params; optional 78 */ 79 int (*adjust_pitch)(void *obj, snd_pcm_rate_info_t *info); 80 /** 81 * convert the data 82 */ 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); 88 /** 89 * convert an s16 interleaved-data array; exclusive with convert 90 */ 91 void (*convert_s16)(void *obj, int16_t *dst, unsigned int dst_frames, 92 const int16_t *src, unsigned int src_frames); 93 /** 94 * compute the frame size for input 95 */ 96 snd_pcm_uframes_t (*input_frames)(void *obj, snd_pcm_uframes_t frames); 97 /** 98 * compute the frame size for output 99 */ 100 snd_pcm_uframes_t (*output_frames)(void *obj, snd_pcm_uframes_t frames); 101 } snd_pcm_rate_ops_t; 102 103 /** open function type */ 104 typedef int (*snd_pcm_rate_open_func_t)(unsigned int version, void **objp, 105 snd_pcm_rate_ops_t *opsp); 106 107 /** 108 * Define the object entry for external PCM rate-converter plugins 109 */ 110 #define SND_PCM_RATE_PLUGIN_ENTRY(name) _snd_pcm_rate_##name##_open 111 112 113 #ifdef __cplusplus 114 } 115 #endif 116 117 #endif /* __ALSA_PCM_RATE_H */ 118