pcm_rate.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Copyright (c) 2019-2025 Allwinner Technology Co., Ltd. ALL rights reserved.
  3. *
  4. * Allwinner is a trademark of Allwinner Technology Co.,Ltd., registered in
  5. * the the people's Republic of China and other countries.
  6. * All Allwinner Technology Co.,Ltd. trademarks are used with permission.
  7. *
  8. * DISCLAIMER
  9. * THIRD PARTY LICENCES MAY BE REQUIRED TO IMPLEMENT THE SOLUTION/PRODUCT.
  10. * IF YOU NEED TO INTEGRATE THIRD PARTY’S TECHNOLOGY (SONY, DTS, DOLBY, AVS OR MPEGLA, ETC.)
  11. * IN ALLWINNERS’SDK OR PRODUCTS, YOU SHALL BE SOLELY RESPONSIBLE TO OBTAIN
  12. * ALL APPROPRIATELY REQUIRED THIRD PARTY LICENCES.
  13. * ALLWINNER SHALL HAVE NO WARRANTY, INDEMNITY OR OTHER OBLIGATIONS WITH RESPECT TO MATTERS
  14. * COVERED UNDER ANY REQUIRED THIRD PARTY LICENSE.
  15. * YOU ARE SOLELY RESPONSIBLE FOR YOUR USAGE OF THIRD PARTY’S TECHNOLOGY.
  16. *
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY ALLWINNER"AS IS" AND TO THE MAXIMUM EXTENT
  19. * PERMITTED BY LAW, ALLWINNER EXPRESSLY DISCLAIMS ALL WARRANTIES OF ANY KIND,
  20. * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION REGARDING
  21. * THE TITLE, NON-INFRINGEMENT, ACCURACY, CONDITION, COMPLETENESS, PERFORMANCE
  22. * OR MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  23. * IN NO EVENT SHALL ALLWINNER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  25. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  26. * LOSS OF USE, DATA, OR PROFITS, OR BUSINESS INTERRUPTION)
  27. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  28. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  30. * OF THE POSSIBILITY OF SUCH DAMAGE.
  31. */
  32. #ifndef __AW_ALSA_LIB_PCM_RATE_H
  33. #define __AW_ALSA_LIB_PCM_RATE_H
  34. #include <aw-alsa-lib/pcm.h>
  35. #include <sys/types.h>
  36. #define SND_PCM_RATE_PLUGIN_VERSION 0x010002
  37. #define SND_PCM_RATE_PLUGIN_ENTRY(name) _snd_pcm_rate_##name##_open
  38. #define SND_PCM_RATE_PLUGIN_CONF_ENTRY(name) _snd_pcm_rate_##name##_open_conf
  39. #define SND_PCM_PLUGIN_RATE_MIN 4000
  40. #define SND_PCM_PLUGIN_RATE_MAX 192000
  41. typedef struct _snd_pcm_rate snd_pcm_rate_t;
  42. /** hw_params information for a single side */
  43. typedef struct snd_pcm_rate_side_info {
  44. snd_pcm_format_t format;
  45. unsigned int rate;
  46. snd_pcm_uframes_t buffer_size;
  47. snd_pcm_uframes_t period_size;
  48. } snd_pcm_rate_side_info_t;
  49. /** hw_params information */
  50. typedef struct snd_pcm_rate_info {
  51. struct snd_pcm_rate_side_info in;
  52. struct snd_pcm_rate_side_info out;
  53. unsigned int channels;
  54. } snd_pcm_rate_info_t;
  55. /** Callback table of rate-converter */
  56. typedef struct snd_pcm_rate_ops {
  57. /**
  58. * close the converter; optional
  59. */
  60. void (*close)(void *obj);
  61. /**
  62. * initialize the converter, called at hw_params
  63. */
  64. int (*init)(void *obj, snd_pcm_rate_info_t *info);
  65. /**
  66. * free the converter; optional
  67. */
  68. void (*free)(void *obj);
  69. /**
  70. * reset the converter, called at prepare; optional
  71. */
  72. void (*reset)(void *obj);
  73. /**
  74. * adjust the pitch, called at sw_params; optional
  75. */
  76. int (*adjust_pitch)(void *obj, snd_pcm_rate_info_t *info);
  77. /**
  78. * convert the data
  79. */
  80. void (*convert)(void *obj,
  81. const snd_pcm_channel_area_t *dst_areas,
  82. snd_pcm_uframes_t dst_offset, unsigned int dst_frames,
  83. const snd_pcm_channel_area_t *src_areas,
  84. snd_pcm_uframes_t src_offset, unsigned int src_frames);
  85. /**
  86. * convert an s16 interleaved-data array; exclusive with convert
  87. */
  88. void (*convert_s16)(void *obj, int16_t *dst, unsigned int dst_frames,
  89. const int16_t *src, unsigned int src_frames);
  90. void (*convert_s16_fix)(void *obj, int16_t *dst, unsigned int *dst_frames,
  91. const int16_t *src, unsigned int *src_frames);
  92. /**
  93. * compute the frame size for input
  94. */
  95. snd_pcm_uframes_t (*input_frames)(void *obj, snd_pcm_uframes_t frames);
  96. /**
  97. * compute the frame size for output
  98. */
  99. snd_pcm_uframes_t (*output_frames)(void *obj, snd_pcm_uframes_t frames);
  100. /**
  101. * the protocol version the plugin supports;
  102. * new field since version 0x010002
  103. */
  104. unsigned int version;
  105. /**
  106. * return the supported min / max sample rates;
  107. * new ops since version 0x010002
  108. */
  109. int (*get_supported_rates)(void *obj, unsigned int *rate_min,
  110. unsigned int *rate_max);
  111. /**
  112. * show some status messages for verbose mode;
  113. * new ops since version 0x010002
  114. */
  115. void (*dump)(void *obj);
  116. } snd_pcm_rate_ops_t;
  117. /** open function type */
  118. typedef int (*snd_pcm_rate_open_func_t)(unsigned int version, void **objp,
  119. snd_pcm_rate_ops_t *opsp);
  120. typedef struct {
  121. const char *pcm;
  122. snd_pcm_format_t format;
  123. unsigned int rate;
  124. } snd_pcm_rate_slave_config_t;
  125. typedef struct {
  126. const char *type;
  127. snd_pcm_rate_slave_config_t slave;
  128. const char *converter;
  129. } snd_pcm_rate_config_t;
  130. #endif /* __AW_ALSA_LIB_PCM_RATE_H */