From: Ji-hoon Lee Date: Mon, 6 Jan 2020 08:30:14 +0000 (+0900) Subject: Add test code for dumping pcm data from ma-service X-Git-Tag: submit/tizen/20200113.120709^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e6c19697ba722233dc6a3e03f5da9581ec2bd9d9;p=platform%2Fcore%2Fuifw%2Fmulti-assistant.git Add test code for dumping pcm data from ma-service Change-Id: Ie72187b27c42b267064acd6482d2313ebc9a723f --- diff --git a/client/ma.c b/client/ma.c index 47f479a..9dfd10f 100644 --- a/client/ma.c +++ b/client/ma.c @@ -30,6 +30,11 @@ #include "ma_defs.h" #include "ma_config_mgr.h" +/* Sound buf save for test */ +#if 0 +#define BUF_SAVE_MODE +#endif + #define MAX_ASSISTANT_INFO_STR_LEN 128 #define MAX_ASSISTANT_NUM 10 #define ENABLED_ASSISTANTS_URL "db/multi-assistant/enabled_assistants" @@ -597,6 +602,59 @@ int __ma_cb_audio_streaming(int event, char* buffer, int len) } #endif +#ifdef BUF_SAVE_MODE + static char g_temp_file_name[128] = {'\0',}; + static FILE* g_pFile = NULL; + static int g_count = 1; + if (MA_AUDIO_STREAMING_EVENT_START == event) { + if (g_pFile) { + fclose(g_pFile); + g_pFile = NULL; + } else { + MA_LOGD("[Recorder Info] File not found!"); + } + + while (1) { + snprintf(g_temp_file_name, sizeof(g_temp_file_name), "/tmp/ma_%d_%d", getpid(), g_count); + int ret = access(g_temp_file_name, 0); + + if (0 == ret) { + MA_LOGD("[Recorder ERROR] File is already exist"); + if (0 == remove(g_temp_file_name)) { + MA_LOGD("[Recorder] Remove file"); + break; + } else { + g_count++; + } + } else { + break; + } + } + + MA_LOGD("[Recorder] Temp file name=[%s]", g_temp_file_name); + + /* open test file */ + g_pFile = fopen(g_temp_file_name, "wb+x"); + if (!g_pFile) { + MA_LOGD("[Recorder ERROR] File not found!"); + } + g_count++; + } + + if (g_pFile) + fwrite(buffer, 1, len, g_pFile); + + if (MA_AUDIO_STREAMING_EVENT_FINISH == event) { + if (g_pFile) { + MA_LOGE("[Recorder SUCCESS] File Close"); + fclose(g_pFile); + g_pFile = NULL; + } else { + MA_LOGE("[Recorder ERROR] File not found!"); + } + } +#endif + ma_client_get_audio_streaming_cb(g_ma, &callback, &user_data); if (NULL != callback) {