Blame include/pcm_rate.h

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