#include "audio_io.h"
#include "CAudioIODef.h"
+#include <system_info.h>
+
+#define FEATURE_MICROPHONE "http://tizen.org/feature/microphone"
using namespace std;
using namespace tizen_media_audio;
*/
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);
__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");
CAudioInfo audioInfo = __generate_audio_input_info(sample_rate, channel, type);
handle->audioIoHandle = new CAudioInput(audioInfo);
- if (handle == NULL) {
+ if (handle->audioIoHandle == NULL) {
THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed allocation internal handle");
}
CAudioInfo audioInfo = __generate_audio_input_loopback_info(sample_rate, channel, type);
handle->audioIoHandle = new CAudioInput(audioInfo);
- if (handle == NULL) {
+ if (handle->audioIoHandle == NULL) {
THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed allocation internal handle");
}
return AUDIO_IO_ERROR_NONE;
}
-int cpp_audio_in_set_stream_info(audio_in_h input, sound_stream_info_h stream_info) {
+int cpp_audio_in_set_sound_stream_info(audio_in_h input, sound_stream_info_h stream_info) {
audio_io_s* handle = static_cast<audio_io_s*>(input);
try {
CAudioInfo audioInfo = __generate_audio_output_info(sample_rate, channel, type, SOUND_TYPE_MEDIA /* default sound_type */);
handle->audioIoHandle = new CAudioOutput(audioInfo);
- if (handle == NULL) {
+ if (handle->audioIoHandle == NULL) {
THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed allocation internal handle");
}
return AUDIO_IO_ERROR_NONE;
}
-int cpp_audio_out_set_stream_info(audio_out_h output, sound_stream_info_h stream_info) {
+int cpp_audio_out_set_sound_stream_info(audio_out_h output, sound_stream_info_h stream_info) {
audio_io_s* handle = static_cast<audio_io_s*>(output);
try {
if (outputHandle == NULL) {
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_HANDLE, "Handle is NULL");
}
- size_t writen = outputHandle->write(buffer, static_cast<size_t>(length));
- ret = static_cast<int>(writen);
+ size_t written = outputHandle->write(buffer, static_cast<size_t>(length));
+ ret = static_cast<int>(written);
#ifdef _AUDIO_IO_DEBUG_TIMING_
- AUDIO_IO_LOGD("writen:%d", writen);
+ AUDIO_IO_LOGD("written:%d", written);
#endif
} catch (CAudioError e) {
AUDIO_IO_LOGE("%s", e.getErrorMsg());