as_fade_p.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Copyright (c) 2017 Actions Semi Co., Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. * Author: jpl<jianpingliao@actions-semi.com>
  16. *
  17. * Change log:
  18. * 2019/12/16: Created by jpl.
  19. */
  20. #ifndef __AS_FADE_P_H__
  21. #define __AS_FADE_P_H__
  22. typedef struct {
  23. unsigned int sample_rate;
  24. unsigned int fade_in_time_ms;
  25. unsigned int fade_out_time_ms;
  26. } as_fade_p_init_t;
  27. //typedef struct {
  28. // /* [OUTPUT] global memory block length array, 3 blocks at maximum */
  29. // int global_buf_len[3];
  30. // /* [OUTPUT] share memory block length array, 3 blocks at maximum */
  31. // int share_buf_len[3];
  32. // /* [INPUT] extended parameters */
  33. // void* param; //here is (as_mix_p_init_t *)&as_mix_p_open_t.as_mix_p_init
  34. //} as_mem_info_t;
  35. typedef struct {
  36. as_fade_p_init_t as_fade_p_init;
  37. as_mem_info_t as_mem_info;
  38. /*! [INPUT] global memory block address array */
  39. void *global_buf_addr[3];
  40. /*! [INPUT] share memory block address array */
  41. void *share_buf_addr[3];
  42. } as_fade_p_open_t;
  43. #define MAX_CHANNEL_AS_FADE_P_INOUT 2
  44. /*!
  45. * \brief
  46. * fade frame process structure
  47. */
  48. typedef struct {
  49. /*! [INPUT] input/output pcm array.
  50. * For interweaved pcm, set channels as 2, pcm_in_out[0] as pcm buffer address, and pcm_in_out[1] as NULL
  51. */
  52. void *pcm_in_out[MAX_CHANNEL_AS_FADE_P_INOUT];
  53. /*! [INPUT] input pcm channels */
  54. int channels;
  55. /*! [INPUT] input pcm samples (pairs) */
  56. int samples;
  57. /*! [INPUT] input pcm sample bits, 16 or 32 */
  58. int sample_bits;
  59. /*! [INPUT] input pcm fraction bits */
  60. int frac_bits;
  61. } as_fade_p_pcm_t;
  62. /*!
  63. * \brief
  64. * fade ops error code
  65. */
  66. typedef enum {
  67. /*! unexpected error */
  68. AS_FADE_P_RET_UNEXPECTED = -3,
  69. /*! not enough memory */
  70. AS_FADE_P_RET_OUTOFMEMORY,
  71. /*! unsupported format */
  72. AS_FADE_P_RET_UNSUPPORTED,
  73. /*! no error */
  74. AS_FADE_P_RET_OK,
  75. /*! data underflow */
  76. AS_FADE_P_RET_DATAUNDERFLOW,
  77. } as_fade_p_ret_t;
  78. /*!
  79. * \brief
  80. * fade ops command
  81. */
  82. typedef enum {
  83. /* open, with argument structure as_fade_p_open_t */
  84. AS_FADE_P_CMD_OPEN = 0,
  85. /* close */
  86. AS_FADE_P_CMD_CLOSE,
  87. /* start fade in, whose argument is fade in time in ms, if set 0 or negative, then use initial value set in AS_FADE_P_CMD_OPEN */
  88. AS_FADE_P_CMD_SET_FADE_IN,
  89. /* start fade out, whose argument is fade out time in ms, if set 0 or negative, then use initial value set in AS_FADE_P_CMD_OPEN
  90. * 1) if fade in started before, then fade out is delayed until fade in completely
  91. * 2) after fade out, pcm output of AS_FADE_P_CMD_FRAME_PROCESS is always 0, that is, slient.
  92. */
  93. AS_FADE_P_CMD_SET_FADE_OUT,
  94. /* get fade out status. 0: fade out not started yet; 1: processing fade out; 2: fade out completely */
  95. AS_FADE_P_CMD_GET_FADE_OUT_STATUS,
  96. /* frame processing with argument, with argument as_fade_p_inout_pcm_t */
  97. AS_FADE_P_CMD_FRAME_PROCESS,
  98. /** get memory require size(bytes) */
  99. AS_FADE_P_CMD_MEM_REQUIRE,
  100. /** get codec verison */
  101. AS_FADE_P_CMD_GET_VERSION,
  102. } as_fade_p_ex_ops_cmd_t;
  103. /**
  104. * @brief as dae fade operation
  105. *
  106. * This routine provides as dae fade operation
  107. *
  108. * @param hnd handle of as dae fade
  109. * @param cmd operation cmd, type of as_dae_ex_ops_cmd_t
  110. * for AS_FADE_P_CMD_MEM_REQUIRE, args type is as_mem_info_t* in audio_codec.h
  111. * for AS_FADE_P_CMD_OPEN, args type is as_fade_p_open_t*
  112. * for AS_FADE_P_CMD_FRAME_PROCESS, args type is as_fade_p_pcm_t*
  113. * @param args args of dae fade parama addr
  114. *
  115. * @return type of as_fade_p_ret_t;
  116. */
  117. int as_fade_p_ops(void *hnd, as_fade_p_ex_ops_cmd_t cmd, unsigned int args);
  118. #endif /* __AS_FADE_P_H__ */