这里写自定义目录标题
sox是著名的音频处理开源库,号称音频界的瑞士军刀,被广泛应用于音频处理。在调用sox的API对音频进行处理时,需调用sox_init()初始化sox库的一些全局参数。
sox_init()函数调用关系
函数源码
init_fft_cache()源码如下,主要负责全局变量的初始化。
static int * lsx_fft_br;
static double * lsx_fft_sc;
static int fft_len = -1;
#if defined HAVE_OPENMP
static ccrw2_t fft_cache_ccrw;
#endif
void init_fft_cache(void)
{
assert(lsx_fft_br == NULL);
assert(lsx_fft_sc == NULL);
assert(fft_len == -1);
ccrw2_init(fft_cache_ccrw);
fft_len = 0;
}
ccrw2_init()是一个宏,定义如下,主要负责对结构体fft_cache_ccrw的初始化。
#define ccrw2_init(p) do {\
omp_init_lock(&p.mutex_1);\
omp_init_lock(&p.mutex_2);\
omp_init_lock(&p.mutex_3);\
omp_init_lock(&p.w);\
omp_init_lock(&p.r);\
} while (0)
#define omp_init_lock(omp_lock_t) (void)0
fft_cache_ccrw是结构体ccrw2_t的声明,结构体ccrw2_t定义如下,可以看出主要是读、写计数器及相关互斥锁。
typedef struct {
int readcount, writecount; /* initial value = 0 */
omp_lock_t mutex_1, mutex_2, mutex_3, w, r; /* initial value = 1 */
} ccrw2_t; /* Problem #2: `writers-preference' */
sox_quit()函数调用关系
sox_quit(),sox_init()的逆过程,主要负责清理sox库中的全局参数,需要调用sox_format_quit()对格式文件进行清理。