pcm_rate.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /**
  2. * \file include/pcm_rate.h
  3. * \brief External Rate-Converter-Plugin SDK
  4. * \author Takashi Iwai <tiwai@suse.de>
  5. * \date 2006
  6. *
  7. * External Rate-Converter-Plugin SDK
  8. */
  9. /*
  10. * ALSA external PCM rate-converter plugin SDK (draft version)
  11. *
  12. * Copyright (c) 2006 Takashi Iwai <tiwai@suse.de>
  13. *
  14. * This library is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU Lesser General Public License as
  16. * published by the Free Software Foundation; either version 2.1 of
  17. * the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Lesser General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Lesser General Public
  25. * License along with this library; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  27. *
  28. */
  29. #ifndef __ALSA_PCM_RATE_H
  30. #define __ALSA_PCM_RATE_H
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /**
  35. * Protocol version
  36. */
  37. #define SND_PCM_RATE_PLUGIN_VERSION 0x010002
  38. /** hw_params information for a single side */
  39. typedef struct snd_pcm_rate_side_info {
  40. snd_pcm_format_t format;
  41. unsigned int rate;
  42. snd_pcm_uframes_t buffer_size;
  43. snd_pcm_uframes_t period_size;
  44. } snd_pcm_rate_side_info_t;
  45. /** hw_params information */
  46. typedef struct snd_pcm_rate_info {
  47. struct snd_pcm_rate_side_info in;
  48. struct snd_pcm_rate_side_info out;
  49. unsigned int channels;
  50. } snd_pcm_rate_info_t;
  51. /** Callback table of rate-converter */
  52. typedef struct snd_pcm_rate_ops {
  53. /**
  54. * close the converter; optional
  55. */
  56. void (*close)(void *obj);
  57. /**
  58. * initialize the converter, called at hw_params
  59. */
  60. int (*init)(void *obj, snd_pcm_rate_info_t *info);
  61. /**
  62. * free the converter; optional
  63. */
  64. void (*free)(void *obj);
  65. /**
  66. * reset the converter, called at prepare; optional
  67. */
  68. void (*reset)(void *obj);
  69. /**
  70. * adjust the pitch, called at sw_params; optional
  71. */
  72. int (*adjust_pitch)(void *obj, snd_pcm_rate_info_t *info);
  73. /**
  74. * convert the data
  75. */
  76. void (*convert)(void *obj,
  77. const snd_pcm_channel_area_t *dst_areas,
  78. snd_pcm_uframes_t dst_offset, unsigned int dst_frames,
  79. const snd_pcm_channel_area_t *src_areas,
  80. snd_pcm_uframes_t src_offset, unsigned int src_frames);
  81. /**
  82. * convert an s16 interleaved-data array; exclusive with convert
  83. */
  84. void (*convert_s16)(void *obj, int16_t *dst, unsigned int dst_frames,
  85. const int16_t *src, unsigned int src_frames);
  86. /**
  87. * compute the frame size for input
  88. */
  89. snd_pcm_uframes_t (*input_frames)(void *obj, snd_pcm_uframes_t frames);
  90. /**
  91. * compute the frame size for output
  92. */
  93. snd_pcm_uframes_t (*output_frames)(void *obj, snd_pcm_uframes_t frames);
  94. /**
  95. * the protocol version the plugin supports;
  96. * new field since version 0x010002
  97. */
  98. unsigned int version;
  99. /**
  100. * return the supported min / max sample rates;
  101. * new ops since version 0x010002
  102. */
  103. int (*get_supported_rates)(void *obj, unsigned int *rate_min,
  104. unsigned int *rate_max);
  105. /**
  106. * show some status messages for verbose mode;
  107. * new ops since version 0x010002
  108. */
  109. void (*dump)(void *obj, snd_output_t *out);
  110. } snd_pcm_rate_ops_t;
  111. /** open function type */
  112. typedef int (*snd_pcm_rate_open_func_t)(unsigned int version, void **objp,
  113. snd_pcm_rate_ops_t *opsp);
  114. /**
  115. * Define the object entry for external PCM rate-converter plugins
  116. */
  117. #define SND_PCM_RATE_PLUGIN_ENTRY(name) _snd_pcm_rate_##name##_open
  118. #ifndef DOC_HIDDEN
  119. /* old rate_ops for protocol version 0x010001 */
  120. typedef struct snd_pcm_rate_old_ops {
  121. void (*close)(void *obj);
  122. int (*init)(void *obj, snd_pcm_rate_info_t *info);
  123. void (*free)(void *obj);
  124. void (*reset)(void *obj);
  125. int (*adjust_pitch)(void *obj, snd_pcm_rate_info_t *info);
  126. void (*convert)(void *obj,
  127. const snd_pcm_channel_area_t *dst_areas,
  128. snd_pcm_uframes_t dst_offset, unsigned int dst_frames,
  129. const snd_pcm_channel_area_t *src_areas,
  130. snd_pcm_uframes_t src_offset, unsigned int src_frames);
  131. void (*convert_s16)(void *obj, int16_t *dst, unsigned int dst_frames,
  132. const int16_t *src, unsigned int src_frames);
  133. snd_pcm_uframes_t (*input_frames)(void *obj, snd_pcm_uframes_t frames);
  134. snd_pcm_uframes_t (*output_frames)(void *obj, snd_pcm_uframes_t frames);
  135. } snd_pcm_rate_old_ops_t;
  136. #endif
  137. #ifdef __cplusplus
  138. }
  139. #endif
  140. #endif /* __ALSA_PCM_RATE_H */