jpayne@69: /** jpayne@69: * \file include/pcm_rate.h jpayne@69: * \brief External Rate-Converter-Plugin SDK jpayne@69: * \author Takashi Iwai jpayne@69: * \date 2006 jpayne@69: * jpayne@69: * External Rate-Converter-Plugin SDK jpayne@69: */ jpayne@69: jpayne@69: /* jpayne@69: * ALSA external PCM rate-converter plugin SDK (draft version) jpayne@69: * jpayne@69: * Copyright (c) 2006 Takashi Iwai jpayne@69: * jpayne@69: * This library is free software; you can redistribute it and/or modify jpayne@69: * it under the terms of the GNU Lesser General Public License as jpayne@69: * published by the Free Software Foundation; either version 2.1 of jpayne@69: * the License, or (at your option) any later version. jpayne@69: * jpayne@69: * This program is distributed in the hope that it will be useful, jpayne@69: * but WITHOUT ANY WARRANTY; without even the implied warranty of jpayne@69: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jpayne@69: * GNU Lesser General Public License for more details. jpayne@69: * jpayne@69: * You should have received a copy of the GNU Lesser General Public jpayne@69: * License along with this library; if not, write to the Free Software jpayne@69: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA jpayne@69: * jpayne@69: */ jpayne@69: jpayne@69: #ifndef __ALSA_PCM_RATE_H jpayne@69: #define __ALSA_PCM_RATE_H jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * Protocol version jpayne@69: */ jpayne@69: #define SND_PCM_RATE_PLUGIN_VERSION 0x010002 jpayne@69: jpayne@69: /** hw_params information for a single side */ jpayne@69: typedef struct snd_pcm_rate_side_info { jpayne@69: snd_pcm_format_t format; jpayne@69: unsigned int rate; jpayne@69: snd_pcm_uframes_t buffer_size; jpayne@69: snd_pcm_uframes_t period_size; jpayne@69: } snd_pcm_rate_side_info_t; jpayne@69: jpayne@69: /** hw_params information */ jpayne@69: typedef struct snd_pcm_rate_info { jpayne@69: struct snd_pcm_rate_side_info in; jpayne@69: struct snd_pcm_rate_side_info out; jpayne@69: unsigned int channels; jpayne@69: } snd_pcm_rate_info_t; jpayne@69: jpayne@69: /** Callback table of rate-converter */ jpayne@69: typedef struct snd_pcm_rate_ops { jpayne@69: /** jpayne@69: * close the converter; optional jpayne@69: */ jpayne@69: void (*close)(void *obj); jpayne@69: /** jpayne@69: * initialize the converter, called at hw_params jpayne@69: */ jpayne@69: int (*init)(void *obj, snd_pcm_rate_info_t *info); jpayne@69: /** jpayne@69: * free the converter; optional jpayne@69: */ jpayne@69: void (*free)(void *obj); jpayne@69: /** jpayne@69: * reset the converter, called at prepare; optional jpayne@69: */ jpayne@69: void (*reset)(void *obj); jpayne@69: /** jpayne@69: * adjust the pitch, called at sw_params; optional jpayne@69: */ jpayne@69: int (*adjust_pitch)(void *obj, snd_pcm_rate_info_t *info); jpayne@69: /** jpayne@69: * convert the data jpayne@69: */ jpayne@69: void (*convert)(void *obj, jpayne@69: const snd_pcm_channel_area_t *dst_areas, jpayne@69: snd_pcm_uframes_t dst_offset, unsigned int dst_frames, jpayne@69: const snd_pcm_channel_area_t *src_areas, jpayne@69: snd_pcm_uframes_t src_offset, unsigned int src_frames); jpayne@69: /** jpayne@69: * convert an s16 interleaved-data array; exclusive with convert jpayne@69: */ jpayne@69: void (*convert_s16)(void *obj, int16_t *dst, unsigned int dst_frames, jpayne@69: const int16_t *src, unsigned int src_frames); jpayne@69: /** jpayne@69: * compute the frame size for input jpayne@69: */ jpayne@69: snd_pcm_uframes_t (*input_frames)(void *obj, snd_pcm_uframes_t frames); jpayne@69: /** jpayne@69: * compute the frame size for output jpayne@69: */ jpayne@69: snd_pcm_uframes_t (*output_frames)(void *obj, snd_pcm_uframes_t frames); jpayne@69: /** jpayne@69: * the protocol version the plugin supports; jpayne@69: * new field since version 0x010002 jpayne@69: */ jpayne@69: unsigned int version; jpayne@69: /** jpayne@69: * return the supported min / max sample rates; jpayne@69: * new ops since version 0x010002 jpayne@69: */ jpayne@69: int (*get_supported_rates)(void *obj, unsigned int *rate_min, jpayne@69: unsigned int *rate_max); jpayne@69: /** jpayne@69: * show some status messages for verbose mode; jpayne@69: * new ops since version 0x010002 jpayne@69: */ jpayne@69: void (*dump)(void *obj, snd_output_t *out); jpayne@69: } snd_pcm_rate_ops_t; jpayne@69: jpayne@69: /** open function type */ jpayne@69: typedef int (*snd_pcm_rate_open_func_t)(unsigned int version, void **objp, jpayne@69: snd_pcm_rate_ops_t *opsp); jpayne@69: jpayne@69: typedef int (*snd_pcm_rate_open_conf_func_t)(unsigned int version, void **objp, jpayne@69: snd_pcm_rate_ops_t *opsp, const snd_config_t *conf); jpayne@69: jpayne@69: /** jpayne@69: * Define the object entry for external PCM rate-converter plugins jpayne@69: */ jpayne@69: #define SND_PCM_RATE_PLUGIN_ENTRY(name) _snd_pcm_rate_##name##_open jpayne@69: #define SND_PCM_RATE_PLUGIN_CONF_ENTRY(name) _snd_pcm_rate_##name##_open_conf jpayne@69: jpayne@69: #ifndef DOC_HIDDEN jpayne@69: /* old rate_ops for protocol version 0x010001 */ jpayne@69: typedef struct snd_pcm_rate_old_ops { jpayne@69: void (*close)(void *obj); jpayne@69: int (*init)(void *obj, snd_pcm_rate_info_t *info); jpayne@69: void (*free)(void *obj); jpayne@69: void (*reset)(void *obj); jpayne@69: int (*adjust_pitch)(void *obj, snd_pcm_rate_info_t *info); jpayne@69: void (*convert)(void *obj, jpayne@69: const snd_pcm_channel_area_t *dst_areas, jpayne@69: snd_pcm_uframes_t dst_offset, unsigned int dst_frames, jpayne@69: const snd_pcm_channel_area_t *src_areas, jpayne@69: snd_pcm_uframes_t src_offset, unsigned int src_frames); jpayne@69: void (*convert_s16)(void *obj, int16_t *dst, unsigned int dst_frames, jpayne@69: const int16_t *src, unsigned int src_frames); jpayne@69: snd_pcm_uframes_t (*input_frames)(void *obj, snd_pcm_uframes_t frames); jpayne@69: snd_pcm_uframes_t (*output_frames)(void *obj, snd_pcm_uframes_t frames); jpayne@69: } snd_pcm_rate_old_ops_t; jpayne@69: #endif jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #endif /* __ALSA_PCM_RATE_H */