71 lines
1.5 KiB
C
71 lines
1.5 KiB
C
|
|
||
|
#include <apr_sdk.h>
|
||
|
#include <apr_sdk_def.h>
|
||
|
#include <tdmin_interface.h>
|
||
|
#include <dlfcn.h>
|
||
|
#include <mic-asp.h>
|
||
|
|
||
|
static PCMContainer_t g_pcmParam;
|
||
|
static apr_aiwrap_t* g_aprHandle;
|
||
|
static void* g_libInterface;
|
||
|
|
||
|
#define MAX_BUF_TIME 128000
|
||
|
#define NUM_CHANNELS 8
|
||
|
#define SAMPLE_RATE 16000
|
||
|
|
||
|
#define DECL_API_PROC(name) static Proc_##name _##name = NULL;
|
||
|
#define LOAD_API_PROC(name) _##name = (Proc_##name)dlsym(g_aprHandle, #name);
|
||
|
|
||
|
API_LIST_SDK(DECL_API_PROC);
|
||
|
|
||
|
|
||
|
void mic_asp_uninit() {
|
||
|
if(g_aprHandle) {
|
||
|
_apr_aiwrap_stop(g_aprHandle);
|
||
|
_apr_aiwrap_destory(g_aprHandle);
|
||
|
dlclose(g_libInterface);
|
||
|
}
|
||
|
|
||
|
alsa_tdmin_uninit(&g_pcmParam);
|
||
|
}
|
||
|
|
||
|
|
||
|
int mic_asp_init(MicDataCallback cb) {
|
||
|
int err;
|
||
|
|
||
|
g_libInterface = dlopen("/usr/lib64/libaiwrap_6mic_c500.so", RTLD_LAZY);
|
||
|
|
||
|
if(NULL == g_libInterface) {
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
g_aprHandle = (apr_aiwrap_t*)g_libInterface;
|
||
|
|
||
|
API_LIST_SDK(LOAD_API_PROC);
|
||
|
|
||
|
err = alsa_tdmin_init(&g_pcmParam, SAMPLE_RATE, NUM_CHANNELS, MAX_BUF_TIME);
|
||
|
if (err != 0) {
|
||
|
return -2;
|
||
|
}
|
||
|
|
||
|
err = _apr_aiwrap_create(&g_aprHandle, "/data/res/conf_6mic_c500_nr_release.ini", "/data/res/auth.param");
|
||
|
|
||
|
if (err != 0) {
|
||
|
return -3;
|
||
|
}
|
||
|
|
||
|
err = _apr_aiwrap_cb_set(g_aprHandle, "presswk", (void*)cb, 0);
|
||
|
if(err !=0){
|
||
|
return -4;
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
int mic_asp_start() {
|
||
|
return _apr_aiwrap_start(g_aprHandle);
|
||
|
}
|
||
|
|
||
|
int mic_asp_stop() {
|
||
|
return _apr_aiwrap_stop(g_aprHandle);
|
||
|
}
|