From ee75d4c9f9112671a0690f27ea05d47fdb5d7ad0 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Fri, 26 Jul 2019 11:20:42 +0900 Subject: [PATCH] Add get_audio_format handler in dependency_resolver Change-Id: I63a979b17f8f4865d3932898ba23ad3419af8bb8 --- .../dependency-default/inc/dependency_default.h | 1 + .../inc/dependency_default_audio.h | 1 + .../dependency-default/src/dependency_default.cpp | 8 +++++++- .../src/dependency_default_audio.cpp | 10 +++++++++ plugins/wakeup-manager/inc/dependency_resolver.h | 4 ++++ plugins/wakeup-manager/src/dependency_resolver.cpp | 24 ++++++++++++++++++++++ plugins/wakeup-manager/src/wakeup_manager.cpp | 4 +--- 7 files changed, 48 insertions(+), 4 deletions(-) diff --git a/plugins/wakeup-manager/dependency-default/inc/dependency_default.h b/plugins/wakeup-manager/dependency-default/inc/dependency_default.h index 51fd6d2..274f7c2 100644 --- a/plugins/wakeup-manager/dependency-default/inc/dependency_default.h +++ b/plugins/wakeup-manager/dependency-default/inc/dependency_default.h @@ -55,6 +55,7 @@ EXPORT_API int mas_dependency_start_recording(void); EXPORT_API int mas_dependency_stop_recording(void); EXPORT_API int mas_dependency_change_system_volume(void); EXPORT_API int mas_dependency_recover_system_volume(void); +EXPORT_API int mas_dependency_get_audio_format(int* rate, int* channel, int* audio_type); #ifdef __cplusplus } diff --git a/plugins/wakeup-manager/dependency-default/inc/dependency_default_audio.h b/plugins/wakeup-manager/dependency-default/inc/dependency_default_audio.h index b46dcf8..6a603c1 100644 --- a/plugins/wakeup-manager/dependency-default/inc/dependency_default_audio.h +++ b/plugins/wakeup-manager/dependency-default/inc/dependency_default_audio.h @@ -28,4 +28,5 @@ void dependency_default_audio_voice_key_pressed_set(bool pressed); void dependency_default_audio_change_system_volume(); void dependency_default_audio_recover_system_volume(); +void dependency_default_audio_get_audio_format(int* rate, int* channel, int* audio_type); #endif //_DEPENDENCY_DEFAULT_AUDIO_H_ diff --git a/plugins/wakeup-manager/dependency-default/src/dependency_default.cpp b/plugins/wakeup-manager/dependency-default/src/dependency_default.cpp index c14145d..171f24f 100644 --- a/plugins/wakeup-manager/dependency-default/src/dependency_default.cpp +++ b/plugins/wakeup-manager/dependency-default/src/dependency_default.cpp @@ -55,4 +55,10 @@ int mas_dependency_recover_system_volume() { dependency_default_audio_recover_system_volume(); return 0; -} \ No newline at end of file +} + +int mas_dependency_get_audio_format(int* rate, int* channel, int* audio_type) +{ + dependency_default_audio_get_audio_format(rate, channel, audio_type); + return 0; +} diff --git a/plugins/wakeup-manager/dependency-default/src/dependency_default_audio.cpp b/plugins/wakeup-manager/dependency-default/src/dependency_default_audio.cpp index 4bceca6..570b44c 100644 --- a/plugins/wakeup-manager/dependency-default/src/dependency_default_audio.cpp +++ b/plugins/wakeup-manager/dependency-default/src/dependency_default_audio.cpp @@ -351,4 +351,14 @@ void dependency_default_audio_recover_system_volume() } g_volume_stream = NULL; } +} + +void dependency_default_audio_get_audio_format(int* rate, int* channel, int* audio_type) +{ + if (!audio_type || !rate || !channel) { + return; + } + *rate = 16000; + *channel = 0; + *audio_type = 0; } \ No newline at end of file diff --git a/plugins/wakeup-manager/inc/dependency_resolver.h b/plugins/wakeup-manager/inc/dependency_resolver.h index 6693ba5..e4fcdf7 100644 --- a/plugins/wakeup-manager/inc/dependency_resolver.h +++ b/plugins/wakeup-manager/inc/dependency_resolver.h @@ -41,6 +41,7 @@ int dependency_resolver_start_recording(); int dependency_resolver_stop_recording(); int dependency_resolver_change_system_volume(); int dependency_resolver_recover_system_volume(); +int dependency_resolver_get_audio_format(int* rate, int* channel, int* audio_type); /************************************************************************************** *** Definitions for dependencies @@ -63,6 +64,8 @@ typedef int (*mas_dependency_stop_recording)(void); typedef int (*mas_dependency_change_system_volume)(void); #define MAS_DEPENDENCY_FUNC_RECOVER_SYSTEM_VOLUME "mas_dependency_recover_system_volume" typedef int (*mas_dependency_recover_system_volume)(void); +#define MAS_DEPENDENCY_FUNC_GET_AUDIO_FORMAT "mas_dependency_get_audio_format" +typedef int (*mas_dependency_get_audio_format)(int* rate, int* channel, int* audio_type); typedef struct { mas_dependency_initialize initialize; @@ -72,6 +75,7 @@ typedef struct { mas_dependency_stop_recording stop_recording; mas_dependency_change_system_volume change_system_volume; mas_dependency_recover_system_volume recover_system_volume; + mas_dependency_get_audio_format get_audio_format; } mas_dependency; #ifdef __cplusplus diff --git a/plugins/wakeup-manager/src/dependency_resolver.cpp b/plugins/wakeup-manager/src/dependency_resolver.cpp index a34d697..eda0f3b 100644 --- a/plugins/wakeup-manager/src/dependency_resolver.cpp +++ b/plugins/wakeup-manager/src/dependency_resolver.cpp @@ -78,6 +78,9 @@ int dependency_resolver_initialize(mas_proxy_interface interface) g_mas_dependency.recover_system_volume = (mas_dependency_recover_system_volume)dlsym(g_handle, MAS_DEPENDENCY_FUNC_RECOVER_SYSTEM_VOLUME); + g_mas_dependency.get_audio_format = + (mas_dependency_get_audio_format)dlsym(g_handle, + MAS_DEPENDENCY_FUNC_GET_AUDIO_FORMAT); int ret = -1; int dependency_version = 0; @@ -222,3 +225,24 @@ int dependency_resolver_recover_system_volume() return ret; } + +int dependency_resolver_get_audio_format(int* rate, int* channel, int* audio_type) +{ + int ret = -1; + if (NULL != g_handle) { + mas_dependency_get_audio_format func = g_mas_dependency.get_audio_format; + if (NULL == func) { + MAS_LOGE("[ERROR] symbol lookup failed : %s", MAS_DEPENDENCY_FUNC_GET_AUDIO_FORMAT); + } else { + ret = func(rate, channel, audio_type); + if (0 != ret) { + MAS_LOGE("[ERROR] Fail to get audio format, ret(%d)", ret); + } + } + } else { + MAS_LOGE("[ERROR] g_handle is not valid"); + } + + return ret; +} + diff --git a/plugins/wakeup-manager/src/wakeup_manager.cpp b/plugins/wakeup-manager/src/wakeup_manager.cpp index 103585b..565ca1d 100644 --- a/plugins/wakeup-manager/src/wakeup_manager.cpp +++ b/plugins/wakeup-manager/src/wakeup_manager.cpp @@ -565,9 +565,7 @@ bool CWakeupManager::get_audio_format(int* rate, int* channel, int* audio_type) return false; } - *rate = 16000; - *channel = 0; - *audio_type = 0; + dependency_resolver_get_audio_format(rate, channel, audio_type); MWR_LOGD("[END] rate(%d), channel(%d), audio_type(%d)", *rate, *channel, *audio_type); return true; -- 2.7.4