From ba499178dd9ce3ff477a91741e8f5c8a3c911c0c Mon Sep 17 00:00:00 2001 From: Seungbae Shin Date: Thu, 28 Jul 2016 12:15:02 +0900 Subject: [PATCH] Add microphone feature check for audio_in [Version] 0.3.40 [Profile] Common [Issue Type] Enhancement Change-Id: I5bf9a90cd3ea474529bd1a7ed813f87ae5caca18 --- CMakeLists.txt | 2 +- packaging/capi-media-audio-io.spec | 3 ++- src/cpp/cpp_audio_io.cpp | 12 ++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4eceba8..0cc11de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) -SET(dependents "dlog mm-sound capi-base-common capi-media-sound-manager mm-common mm-session libpulse vconf dpm") +SET(dependents "dlog mm-sound capi-base-common capi-media-sound-manager mm-common mm-session libpulse vconf dpm capi-system-info") SET(pc_dependents "capi-base-common capi-media-sound-manager") INCLUDE(FindPkgConfig) diff --git a/packaging/capi-media-audio-io.spec b/packaging/capi-media-audio-io.spec index 53fdd6f..b46f218 100644 --- a/packaging/capi-media-audio-io.spec +++ b/packaging/capi-media-audio-io.spec @@ -1,6 +1,6 @@ Name: capi-media-audio-io Summary: An Audio Input & Audio Output library in Tizen Native API -Version: 0.3.39 +Version: 0.3.40 Release: 0 Group: Multimedia/API License: Apache-2.0 @@ -16,6 +16,7 @@ BuildRequires: pkgconfig(capi-media-sound-manager) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(libpulse) BuildRequires: pkgconfig(dpm) +BuildRequires: pkgconfig(capi-system-info) %description An Audio Input & Audio Output library in Tizen Native API diff --git a/src/cpp/cpp_audio_io.cpp b/src/cpp/cpp_audio_io.cpp index 936873f..55d1f7b 100644 --- a/src/cpp/cpp_audio_io.cpp +++ b/src/cpp/cpp_audio_io.cpp @@ -20,6 +20,9 @@ #include "audio_io.h" #include "CAudioIODef.h" +#include + +#define FEATURE_MICROPHONE "http://tizen.org/feature/microphone" using namespace std; using namespace tizen_media_audio; @@ -363,6 +366,8 @@ static audio_io_interrupted_code_e __convert_interrupted_code(IAudioSessionEvent */ int cpp_audio_in_create(int sample_rate, audio_channel_e channel, audio_sample_type_e type, audio_in_h *input) { audio_io_s* handle = NULL; + bool mic_enable = false; + int ret = 0; try { if (input == NULL) { THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameters are NULL input:%p", input); @@ -370,6 +375,13 @@ int cpp_audio_in_create(int sample_rate, audio_channel_e channel, audio_sample_t __check_audio_param(sample_rate, channel, type); + /* If MIC is not supported, return NOT_SUPPORTED error */ + ret = system_info_get_platform_bool(FEATURE_MICROPHONE, &mic_enable); + AUDIO_IO_LOGD("system_info_platform [%s]=[%d], ret[%d]", FEATURE_MICROPHONE, mic_enable, ret); + if (ret != SYSTEM_INFO_ERROR_NONE || !mic_enable) { + THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_SUPPORTED, "System doesn't support microphone!"); + } + handle = new audio_io_s; if (handle == NULL) { THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed allocation handle"); -- 2.7.4