pcm_extplug.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /**
  2. * \file include/pcm_extplug.h
  3. * \brief External Filter-Plugin SDK
  4. * \author Takashi Iwai <tiwai@suse.de>
  5. * \date 2005
  6. *
  7. * External Filter-Plugin SDK
  8. */
  9. /*
  10. * ALSA external PCM plugin SDK (draft version)
  11. *
  12. * Copyright (c) 2005 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_EXTPLUG_H
  30. #define __ALSA_PCM_EXTPLUG_H
  31. /**
  32. * \defgroup PCM_ExtPlug External Filter plugin SDK
  33. * \ingroup Plugin_SDK
  34. * See the \ref pcm page for more details.
  35. * \{
  36. */
  37. /** hw constraints for extplug */
  38. enum {
  39. SND_PCM_EXTPLUG_HW_FORMAT, /**< format */
  40. SND_PCM_EXTPLUG_HW_CHANNELS, /**< channels */
  41. SND_PCM_EXTPLUG_HW_PARAMS /**< max number of hw constraints */
  42. };
  43. /** Handle of external filter plugin */
  44. typedef struct snd_pcm_extplug snd_pcm_extplug_t;
  45. /** Callback table of extplug */
  46. typedef struct snd_pcm_extplug_callback snd_pcm_extplug_callback_t;
  47. #ifdef DOC_HIDDEN
  48. /* redefine typedefs for stupid doxygen */
  49. typedef snd_pcm_extplug snd_pcm_extplug_t;
  50. typedef snd_pcm_extplug_callback snd_pcm_extplug_callback_t;
  51. #endif
  52. /*
  53. * Protocol version
  54. */
  55. #define SND_PCM_EXTPLUG_VERSION_MAJOR 1 /**< Protocol major version */
  56. #define SND_PCM_EXTPLUG_VERSION_MINOR 0 /**< Protocol minor version */
  57. #define SND_PCM_EXTPLUG_VERSION_TINY 2 /**< Protocol tiny version */
  58. /**
  59. * Filter-plugin protocol version
  60. */
  61. #define SND_PCM_EXTPLUG_VERSION ((SND_PCM_EXTPLUG_VERSION_MAJOR<<16) |\
  62. (SND_PCM_EXTPLUG_VERSION_MINOR<<8) |\
  63. (SND_PCM_EXTPLUG_VERSION_TINY))
  64. /** Handle of extplug */
  65. struct snd_pcm_extplug {
  66. /**
  67. * protocol version; #SND_PCM_EXTPLUG_VERSION must be filled here
  68. * before calling #snd_pcm_extplug_create()
  69. */
  70. unsigned int version;
  71. /**
  72. * name of this plugin; must be filled before calling #snd_pcm_extplug_create()
  73. */
  74. const char *name;
  75. /**
  76. * callbacks of this plugin; must be filled before calling #snd_pcm_extplug_create()
  77. */
  78. const snd_pcm_extplug_callback_t *callback;
  79. /**
  80. * private data, which can be used freely in the driver callbacks
  81. */
  82. void *private_data;
  83. /**
  84. * PCM handle filled by #snd_pcm_extplug_create()
  85. */
  86. snd_pcm_t *pcm;
  87. /**
  88. * stream direction; read-only status
  89. */
  90. snd_pcm_stream_t stream;
  91. /**
  92. * format hw parameter; filled after hw_params is caled
  93. */
  94. snd_pcm_format_t format;
  95. /**
  96. * subformat hw parameter; filled after hw_params is caled
  97. */
  98. snd_pcm_subformat_t subformat;
  99. /**
  100. * channels hw parameter; filled after hw_params is caled
  101. */
  102. unsigned int channels;
  103. /**
  104. * rate hw parameter; filled after hw_params is caled
  105. */
  106. unsigned int rate;
  107. /**
  108. * slave_format hw parameter; filled after hw_params is caled
  109. */
  110. snd_pcm_format_t slave_format;
  111. /**
  112. * slave_subformat hw parameter; filled after hw_params is caled
  113. */
  114. snd_pcm_subformat_t slave_subformat;
  115. /**
  116. * slave_channels hw parameter; filled after hw_params is caled
  117. */
  118. unsigned int slave_channels;
  119. };
  120. /** Callback table of extplug */
  121. struct snd_pcm_extplug_callback {
  122. /**
  123. * transfer between source and destination; this is a required callback
  124. */
  125. snd_pcm_sframes_t (*transfer)(snd_pcm_extplug_t *ext,
  126. const snd_pcm_channel_area_t *dst_areas,
  127. snd_pcm_uframes_t dst_offset,
  128. const snd_pcm_channel_area_t *src_areas,
  129. snd_pcm_uframes_t src_offset,
  130. snd_pcm_uframes_t size);
  131. /**
  132. * close the PCM; optional
  133. */
  134. int (*close)(snd_pcm_extplug_t *ext);
  135. /**
  136. * hw_params; optional
  137. */
  138. int (*hw_params)(snd_pcm_extplug_t *ext, snd_pcm_hw_params_t *params);
  139. /**
  140. * hw_free; optional
  141. */
  142. int (*hw_free)(snd_pcm_extplug_t *ext);
  143. /**
  144. * dump; optional
  145. */
  146. void (*dump)(snd_pcm_extplug_t *ext, snd_output_t *out);
  147. /**
  148. * init; optional initialization called at prepare or reset
  149. */
  150. int (*init)(snd_pcm_extplug_t *ext);
  151. /**
  152. * query the channel maps; optional; since v1.0.2
  153. */
  154. snd_pcm_chmap_query_t **(*query_chmaps)(snd_pcm_extplug_t *ext);
  155. /**
  156. * get the channel map; optional; since v1.0.2
  157. */
  158. snd_pcm_chmap_t *(*get_chmap)(snd_pcm_extplug_t *ext);
  159. /**
  160. * set the channel map; optional; since v1.0.2
  161. */
  162. int (*set_chmap)(snd_pcm_extplug_t *ext, const snd_pcm_chmap_t *map);
  163. };
  164. int snd_pcm_extplug_create(snd_pcm_extplug_t *ext, const char *name,
  165. snd_config_t *root, snd_config_t *slave_conf,
  166. snd_pcm_stream_t stream, int mode);
  167. int snd_pcm_extplug_delete(snd_pcm_extplug_t *ext);
  168. /* clear hw_parameter setting */
  169. void snd_pcm_extplug_params_reset(snd_pcm_extplug_t *ext);
  170. /* hw_parameter setting */
  171. int snd_pcm_extplug_set_param_list(snd_pcm_extplug_t *extplug, int type, unsigned int num_list, const unsigned int *list);
  172. int snd_pcm_extplug_set_param_minmax(snd_pcm_extplug_t *extplug, int type, unsigned int min, unsigned int max);
  173. int snd_pcm_extplug_set_slave_param_list(snd_pcm_extplug_t *extplug, int type, unsigned int num_list, const unsigned int *list);
  174. int snd_pcm_extplug_set_slave_param_minmax(snd_pcm_extplug_t *extplug, int type, unsigned int min, unsigned int max);
  175. /**
  176. * set the parameter constraint with a single value
  177. */
  178. static __inline__ int snd_pcm_extplug_set_param(snd_pcm_extplug_t *extplug, int type, unsigned int val)
  179. {
  180. return snd_pcm_extplug_set_param_list(extplug, type, 1, &val);
  181. }
  182. /**
  183. * set the parameter constraint for slave PCM with a single value
  184. */
  185. static __inline__ int snd_pcm_extplug_set_slave_param(snd_pcm_extplug_t *extplug, int type, unsigned int val)
  186. {
  187. return snd_pcm_extplug_set_slave_param_list(extplug, type, 1, &val);
  188. }
  189. /** \} */
  190. #endif /* __ALSA_PCM_EXTPLUG_H */