From: KimJeongYeon Date: Fri, 17 Jul 2015 00:43:37 +0000 (+0900) Subject: audio-io handles not supported stream type X-Git-Tag: accepted/tizen/mobile/20150721.092105^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7e9f563ebfc3c1b8b575d7c053ca4826b5a116a5;p=platform%2Fcore%2Fapi%2Faudio-io.git audio-io handles not supported stream type [Version] 0.3.8 [Profile] Common [Issue Type] Feature [Dependency module] NA [Dependency commit] NA [Comment] supported stream type: - audio-in/out : voip, media - audio-in only : voice recognition, loopback - audio-out only : system, alarm, notification, emergency, voice information, ringtone voip, ringtone call (reference : platform/core/multimedia/mmfw-sysconf / mmfw-sysconf-target-n4/etc/pulse/stream-map.json) additionally, fixed TCT issues. Signed-off-by: KimJeongYeon Change-Id: I8f94980eb78041bfc94ccfea57c72e503f7bb10e --- diff --git a/include/CAudioError.h b/include/CAudioError.h index de1e1fb..3dc36b9 100644 --- a/include/CAudioError.h +++ b/include/CAudioError.h @@ -45,6 +45,7 @@ namespace tizen_media_audio { ERROR_NOT_INITIALIZED, ERROR_NOT_SUPPORTED, + ERROR_NOT_SUPPORTED_TYPE, ERROR_PERMISSION_DENIED, diff --git a/include/CAudioInfo.h b/include/CAudioInfo.h index 420042f..8feab06 100644 --- a/include/CAudioInfo.h +++ b/include/CAudioInfo.h @@ -45,28 +45,37 @@ namespace tizen_media_audio { }; enum EAudioType { - /* Only Input */ + /* Input Type */ AUDIO_IN_TYPE_MEDIA = 0, - AUDIO_IN_TYPE_SYSTEM, - AUDIO_IN_TYPE_ALARM, - AUDIO_IN_TYPE_NOTIFICATION, - AUDIO_IN_TYPE_EMERGENCY, - AUDIO_IN_TYPE_VOICE_INFORMATION, + //AUDIO_IN_TYPE_SYSTEM, + //AUDIO_IN_TYPE_ALARM, + //AUDIO_IN_TYPE_NOTIFICATION, + //AUDIO_IN_TYPE_EMERGENCY, + //AUDIO_IN_TYPE_VOICE_INFORMATION, AUDIO_IN_TYPE_VOICE_RECOGNITION, - AUDIO_IN_TYPE_RINGTONE_VOIP, + //AUDIO_IN_TYPE_RINGTONE_VOIP, AUDIO_IN_TYPE_VOIP, - AUDIO_IN_TYPE_LOOPBACK, /**< only for loopback */ + //AUDIO_IN_TYPE_RINGTONE_CALL, + //AUDIO_IN_TYPE_VOICE_CALL, + //AUDIO_IN_TYPE_VIDEO_CALL, + //AUDIO_IN_TYPE_RADIO, + AUDIO_IN_TYPE_LOOPBACK, - /* Only Output */ + /* Output Type */ AUDIO_OUT_TYPE_MEDIA, AUDIO_OUT_TYPE_SYSTEM, AUDIO_OUT_TYPE_ALARM, AUDIO_OUT_TYPE_NOTIFICATION, AUDIO_OUT_TYPE_EMERGENCY, AUDIO_OUT_TYPE_VOICE_INFORMATION, - AUDIO_OUT_TYPE_VOICE_RECOGNITION, + //AUDIO_OUT_TYPE_VOICE_RECOGNITION, AUDIO_OUT_TYPE_RINGTONE_VOIP, AUDIO_OUT_TYPE_VOIP, + AUDIO_OUT_TYPE_RINGTONE_CALL, + //AUDIO_OUT_TYPE_VOICE_CALL, + //AUDIO_OUT_TYPE_VIDEO_CALL, + //AUDIO_OUT_TYPE_RADIO, + //AUDIO_OUT_TYPE_LOOPBACK, AUDIO_TYPE_MAX }; @@ -86,28 +95,37 @@ namespace tizen_media_audio { int mAudioIndex; const char *StreamTypeTable[AUDIO_TYPE_MAX] = { - /* Only Input */ + /* Input Type */ "media", /**< AUDIO_IN_TYPE_MEDIA */ - "system", /**< AUDIO_IN_TYPE_SYSTEM */ - "alarm", /**< AUDIO_IN_TYPE_ALARM */ - "notification", /**< AUDIO_IN_TYPE_NOTIFICATION */ - "emergency", /**< AUDIO_IN_TYPE_EMERGENCY */ - "voice-information", /**< AUDIO_IN_TYPE_VOICE_INFORMATION */ + //"system", /**< AUDIO_IN_TYPE_SYSTEM */ + //"alarm", /**< AUDIO_IN_TYPE_ALARM */ + //"notification", /**< AUDIO_IN_TYPE_NOTIFICATION */ + //"emergency", /**< AUDIO_IN_TYPE_EMERGENCY */ + //"voice-information", /**< AUDIO_IN_TYPE_VOICE_INFORMATION */ "voice-recognition", /**< AUDIO_IN_TYPE_VOICE_RECOGNITION */ - "ringtone-voip", /**< AUDIO_IN_TYPE_RINGTONE_VOIP */ + //"ringtone-voip", /**< AUDIO_IN_TYPE_RINGTONE_VOIP */ "voip", /**< AUDIO_IN_TYPE_VOIP */ - "loopback", /**< AUDIO_IN_TYPE_LOOPBACK */ /**< only for loopback */ + //"ringtone-call", /**< AUDIO_IN_TYPE_RINGTONE_CALL */ + //"call-voice", /**< AUDIO_IN_TYPE_VOICE_CALL */ + //"call-video", /**< AUDIO_IN_TYPE_VIDEO_CALL */ + //"radio", /**< AUDIO_IN_TYPE_RADIO */ + "loopback", /**< AUDIO_IN_TYPE_LOOPBACK */ - /* Only Output */ + /* Output Type */ "media", /**< AUDIO_OUT_TYPE_MEDIA */ "system", /**< AUDIO_OUT_TYPE_SYSTEM */ "alarm", /**< AUDIO_OUT_TYPE_ALARM */ "notification", /**< AUDIO_OUT_TYPE_NOTIFICATION */ "emergency", /**< AUDIO_OUT_TYPE_EMERGENCY */ "voice-information", /**< AUDIO_OUT_TYPE_VOICE_INFORMATION */ - "voice-recognition", /**< AUDIO_OUT_TYPE_VOICE_RECOGNITION */ + //"voice-recognition", /**< AUDIO_OUT_TYPE_VOICE_RECOGNITION */ "ringtone-voip", /**< AUDIO_OUT_TYPE_RINGTONE_VOIP */ "voip", /**< AUDIO_OUT_TYPE_VOIP */ + "ringtone-call", /**< AUDIO_OUT_TYPE_RINGTONE_CALL */ + //"call-voice", /**< AUDIO_OUT_TYPE_VOICE_CALL */ + //"call-video", /**< AUDIO_OUT_TYPE_VIDEO_CALL */ + //"radio", /**< AUDIO_OUT_TYPE_RADIO */ + //"loopback", /**< AUDIO_OUT_TYPE_LOOPBACK */ }; public: @@ -124,7 +142,8 @@ namespace tizen_media_audio { int getAudioIndex(); void setAudioIndex(int AudioIndex); void convertAudioType2StreamType (CAudioInfo::EAudioType audioType, char **streamType); - void convertStreamType2AudioType (char *streamType, CAudioInfo::EAudioType *audioType); + void convertInputStreamType2AudioType (char *streamType, CAudioInfo::EAudioType *audioType); + void convertOutputStreamType2AudioType (char *streamType, CAudioInfo::EAudioType *audioType); }; } /* namespace tizen_media_audio */ diff --git a/include/audio_io.h b/include/audio_io.h index 767011a..397235a 100644 --- a/include/audio_io.h +++ b/include/audio_io.h @@ -112,6 +112,7 @@ typedef enum{ AUDIO_IO_ERROR_INVALID_BUFFER = TIZEN_ERROR_AUDIO_IO | 0x03, /**< Invalid buffer pointer */ AUDIO_IO_ERROR_SOUND_POLICY = TIZEN_ERROR_AUDIO_IO | 0x04, /**< Sound policy error */ AUDIO_IO_ERROR_INVALID_STATE = TIZEN_ERROR_AUDIO_IO | 0x05, /**< Invalid state (Since 3.0) */ + AUDIO_IO_ERROR_NOT_SUPPORTED_TYPE = TIZEN_ERROR_AUDIO_IO | 0x06, /**< Not supported stream type (Since 3.0) */ } audio_io_error_e; /** @@ -275,6 +276,7 @@ int audio_in_destroy(audio_in_h input); * * @remarks @a the sound stream information includes audio routing and volume type. * For more details, you can refer to @ref CAPI_MEDIA_SOUND_MANAGER_MODULE + * System, Alarm, Notification, Emergency, Voice Information, Ringtone VOIP and Ringtone Call stream types are not supported in this API. * * @param[in] input The handle to the audio input * @param[in] stream_info The handle of stream information @@ -284,6 +286,7 @@ int audio_in_destroy(audio_in_h input); * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state + * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED_TYPE Not supported stream type * * @pre The state should be #AUDIO_IO_STATE_IDLE.\n * Call audio_in_create() before calling this function. @@ -773,7 +776,8 @@ int audio_out_destroy(audio_out_h output); * @since_tizen 3.0 * * @remarks @a the sound stream information includes audio routing and volume type. - * For more details, you can refer to sound_manager.h + * For more details, you can refer to @ref CAPI_MEDIA_SOUND_MANAGER_MODULE + * Voice Recognition and Loopback stream types are not supported in this API. * * @param[in] output The handle to the audio output * @param[in] stream_info The handle of stream information @@ -783,6 +787,7 @@ int audio_out_destroy(audio_out_h output); * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state + * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED_TYPE Not supported stream type * * @pre The state should be #AUDIO_IO_STATE_IDLE.\n * Call audio_out_create_new() before calling this function. diff --git a/packaging/capi-media-audio-io.spec b/packaging/capi-media-audio-io.spec index 1b3b88f..9b198e6 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.7 +Version: 0.3.8 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/cpp/CAudioError.cpp b/src/cpp/CAudioError.cpp index b0bbfdb..8244bbd 100644 --- a/src/cpp/CAudioError.cpp +++ b/src/cpp/CAudioError.cpp @@ -76,7 +76,6 @@ CAudioError::~CAudioError() { const char* CAudioError::_convertErrorToString(EError err) { switch (err) { - default: case ERROR_NONE: return COLOR_GREEN "ERROR_NONE" COLOR_END; case ERROR_INVALID_ARGUMENT: return COLOR_RED "ERROR_INVALID_ARGUMENT" COLOR_END; @@ -88,6 +87,7 @@ const char* CAudioError::_convertErrorToString(EError err) { case ERROR_INVALID_OPERATION: return COLOR_RED "ERROR_INVALID_OPERATION" COLOR_END; case ERROR_NOT_INITIALIZED: return COLOR_RED "ERROR_NOT_INITIALIZED" COLOR_END; case ERROR_NOT_SUPPORTED: return COLOR_RED "ERROR_NOT_SUPPORTED" COLOR_END; + case ERROR_NOT_SUPPORTED_TYPE: return COLOR_RED "ERROR_NOT_SUPPORTED_TYPE" COLOR_END; case ERROR_PERMISSION_DENIED: return COLOR_RED "ERROR_PERMISSION_DENIED" COLOR_END; case ERROR_DEVICE_NOT_OPENED: return COLOR_RED "ERROR_DEVICE_NOT_OPENED" COLOR_END; case ERROR_DEVICE_NOT_CLOSED: return COLOR_RED "ERROR_DEVICE_NOT_CLOSED" COLOR_END; diff --git a/src/cpp/CAudioInfo.cpp b/src/cpp/CAudioInfo.cpp index 0c18bf4..c6c3d1d 100644 --- a/src/cpp/CAudioInfo.cpp +++ b/src/cpp/CAudioInfo.cpp @@ -85,22 +85,37 @@ void CAudioInfo::setAudioIndex(int AudioIndex) { void CAudioInfo::convertAudioType2StreamType (CAudioInfo::EAudioType audioType, char **streamType) { if (audioType < CAudioInfo::AUDIO_IN_TYPE_MEDIA || audioType >= CAudioInfo::AUDIO_TYPE_MAX) { - THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "The audioType is invalid [audioType:%d]", audioType); + THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_NOT_SUPPORTED_TYPE, "The audioType is not supported [audioType:%d]", audioType); } *streamType = (char *)StreamTypeTable[audioType]; return; } -void CAudioInfo::convertStreamType2AudioType (char *streamType, CAudioInfo::EAudioType *audioType) +void CAudioInfo::convertInputStreamType2AudioType (char *streamType, CAudioInfo::EAudioType *audioType) +{ + unsigned int i; + for (i = CAudioInfo::AUDIO_IN_TYPE_MEDIA ; i < CAudioInfo::AUDIO_OUT_TYPE_MEDIA ; i++) { + if (!strcmp((char *)StreamTypeTable[i], streamType)) { + break; + } + } + if (i >= CAudioInfo::AUDIO_OUT_TYPE_MEDIA) { + THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_NOT_SUPPORTED_TYPE, "The streamType is not supported [streamType:%s]", streamType); + } + *audioType = (CAudioInfo::EAudioType)i; + return; +} + +void CAudioInfo::convertOutputStreamType2AudioType (char *streamType, CAudioInfo::EAudioType *audioType) { unsigned int i; - for (i = 0 ; i < CAudioInfo::AUDIO_TYPE_MAX ; i++) { + for (i = CAudioInfo::AUDIO_OUT_TYPE_MEDIA ; i < CAudioInfo::AUDIO_TYPE_MAX ; i++) { if (!strcmp((char *)StreamTypeTable[i], streamType)) { break; } } - if (i < CAudioInfo::AUDIO_IN_TYPE_MEDIA || i >= CAudioInfo::AUDIO_TYPE_MAX) { - THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "The streamType is invalid [streamType:%s]", streamType); + if (i >= CAudioInfo::AUDIO_TYPE_MAX) { + THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_NOT_SUPPORTED_TYPE, "The streamType is not supported [streamType:%s]", streamType); } *audioType = (CAudioInfo::EAudioType)i; return; diff --git a/src/cpp/CAudioInput.cpp b/src/cpp/CAudioInput.cpp index 8835236..93a5b90 100644 --- a/src/cpp/CAudioInput.cpp +++ b/src/cpp/CAudioInput.cpp @@ -360,7 +360,7 @@ size_t CAudioInput::read(void* buffer, size_t length) throw (CAudioError) { /* Checks synchronous flag */ if (mIsUsedSyncRead == false) { - THROW_ERROR_MSG(CAudioError::ERROR_NOT_SUPPORTED, "Does not support read() if receive stream callback"); + THROW_ERROR_MSG(CAudioError::ERROR_INVALID_OPERATION, "Invalid operation of read() if receive stream callback"); } internalLock(); @@ -451,11 +451,9 @@ int CAudioInput::peek(const void** buffer, size_t* length) throw (CAudioError) { } /* Checks synchronous flag */ - internalLock(); if (mIsUsedSyncRead == true) { - THROW_ERROR_MSG(CAudioError::ERROR_NOT_SUPPORTED, "Does not support peek() if does not receive a stream callback"); + THROW_ERROR_MSG(CAudioError::ERROR_INVALID_OPERATION, "Invalid operation of peek() if does not receive a stream callback"); } - internalUnlock(); int ret = 0; @@ -477,11 +475,9 @@ int CAudioInput::drop() throw (CAudioError) { } /* Checks synchronous flag */ - internalLock(); if (mIsUsedSyncRead == true) { - THROW_ERROR_MSG(CAudioError::ERROR_NOT_SUPPORTED, "Does not support drop() if does not receive a stream callback"); + THROW_ERROR_MSG(CAudioError::ERROR_INVALID_OPERATION, "Invalid operation of drop() if does not receive a stream callback"); } - internalUnlock(); int ret = 0; diff --git a/src/cpp/cpp_audio_io.cpp b/src/cpp/cpp_audio_io.cpp index 76f87b3..3fddd75 100644 --- a/src/cpp/cpp_audio_io.cpp +++ b/src/cpp/cpp_audio_io.cpp @@ -99,7 +99,6 @@ static audio_io_error_e _convert_CAudioError(CAudioError& error) { case CAudioError::ERROR_NONE: ret = AUDIO_IO_ERROR_NONE; break; - case CAudioError::ERROR_INVALID_ARGUMENT: case CAudioError::ERROR_INVALID_HANDLE: case CAudioError::ERROR_INVALID_SAMPLERATE: @@ -107,23 +106,21 @@ static audio_io_error_e _convert_CAudioError(CAudioError& error) { case CAudioError::ERROR_INVALID_FORMAT: ret = AUDIO_IO_ERROR_INVALID_PARAMETER; break; - case CAudioError::ERROR_DEVICE_NOT_OPENED: ret = AUDIO_IO_ERROR_DEVICE_NOT_OPENED; break; - case CAudioError::ERROR_DEVICE_NOT_CLOSED: ret = AUDIO_IO_ERROR_DEVICE_NOT_CLOSED; break; - case CAudioError::ERROR_PERMISSION_DENIED: ret = AUDIO_IO_ERROR_PERMISSION_DENIED; break; - case CAudioError::ERROR_NOT_SUPPORTED: ret = AUDIO_IO_ERROR_NOT_SUPPORTED; break; - + case CAudioError::ERROR_NOT_SUPPORTED_TYPE: + ret = AUDIO_IO_ERROR_NOT_SUPPORTED_TYPE; + break; case CAudioError::ERROR_MAX: case CAudioError::ERROR_INTERNAL_OPERATION: case CAudioError::ERROR_NOT_INITIALIZED: @@ -131,20 +128,18 @@ static audio_io_error_e _convert_CAudioError(CAudioError& error) { case CAudioError::ERROR_INVALID_OPERATION: ret = AUDIO_IO_ERROR_INVALID_OPERATION; break; - case CAudioError::ERROR_OUT_OF_MEMORY: case CAudioError::ERROR_INVALID_POINTER: ret = AUDIO_IO_ERROR_INVALID_BUFFER; break; - case CAudioError::ERROR_POLICY_BLOCKED: case CAudioError::ERROR_POLICY_INTERRUPTED: case CAudioError::ERROR_POLICY_DUPLICATED: ret = AUDIO_IO_ERROR_SOUND_POLICY; break; } - return ret; + return ret; } static void _convert_channel_2_audio_info_channel(const audio_channel_e& src_channel, CAudioInfo::EChannel& dst_channel) { @@ -201,65 +196,64 @@ static void _convert_audio_info_sample_type_2_sample_type(const CAudioInfo::ESam static void _convert_sound_type_2_audio_info_audio_type(const sound_type_e& src_type, CAudioInfo::EAudioType& dst_type) { switch (src_type) { - case SOUND_TYPE_SYSTEM: - dst_type = CAudioInfo::AUDIO_OUT_TYPE_SYSTEM; - break; - case SOUND_TYPE_NOTIFICATION: - dst_type = CAudioInfo::AUDIO_OUT_TYPE_NOTIFICATION; - break; - case SOUND_TYPE_ALARM: - dst_type = CAudioInfo::AUDIO_OUT_TYPE_ALARM; - break; - case SOUND_TYPE_RINGTONE: - dst_type = CAudioInfo::AUDIO_OUT_TYPE_RINGTONE_VOIP; - break; - case SOUND_TYPE_MEDIA: - dst_type = CAudioInfo::AUDIO_OUT_TYPE_MEDIA; - break; - case SOUND_TYPE_CALL: - dst_type = CAudioInfo::AUDIO_OUT_TYPE_SYSTEM; - break; - case SOUND_TYPE_VOIP: - dst_type = CAudioInfo::AUDIO_OUT_TYPE_VOIP; - break; - case SOUND_TYPE_VOICE: - dst_type = CAudioInfo::AUDIO_OUT_TYPE_VOICE_INFORMATION; - break; - default: - dst_type = CAudioInfo::AUDIO_OUT_TYPE_MEDIA; - break; - } + case SOUND_TYPE_SYSTEM: + dst_type = CAudioInfo::AUDIO_OUT_TYPE_SYSTEM; + break; + case SOUND_TYPE_NOTIFICATION: + dst_type = CAudioInfo::AUDIO_OUT_TYPE_NOTIFICATION; + break; + case SOUND_TYPE_ALARM: + dst_type = CAudioInfo::AUDIO_OUT_TYPE_ALARM; + break; + case SOUND_TYPE_RINGTONE: + dst_type = CAudioInfo::AUDIO_OUT_TYPE_RINGTONE_VOIP; + break; + case SOUND_TYPE_MEDIA: + dst_type = CAudioInfo::AUDIO_OUT_TYPE_MEDIA; + break; + case SOUND_TYPE_CALL: + dst_type = CAudioInfo::AUDIO_OUT_TYPE_SYSTEM; + break; + case SOUND_TYPE_VOIP: + dst_type = CAudioInfo::AUDIO_OUT_TYPE_VOIP; + break; + case SOUND_TYPE_VOICE: + dst_type = CAudioInfo::AUDIO_OUT_TYPE_VOICE_INFORMATION; + break; + default: + dst_type = CAudioInfo::AUDIO_OUT_TYPE_MEDIA; + break; + } } static void _convert_audio_info_audio_type_2_sound_type(const CAudioInfo::EAudioType& src_type, sound_type_e& dst_type) { switch (src_type) { - case CAudioInfo::AUDIO_OUT_TYPE_MEDIA: - dst_type = SOUND_TYPE_MEDIA; - break; - case CAudioInfo::AUDIO_OUT_TYPE_SYSTEM: - dst_type = SOUND_TYPE_SYSTEM; - break; - case CAudioInfo::AUDIO_OUT_TYPE_ALARM: - dst_type = SOUND_TYPE_ALARM; - break; - case CAudioInfo::AUDIO_OUT_TYPE_NOTIFICATION: - case CAudioInfo::AUDIO_OUT_TYPE_EMERGENCY: - dst_type = SOUND_TYPE_NOTIFICATION; - break; - case CAudioInfo::AUDIO_OUT_TYPE_VOICE_INFORMATION: - case CAudioInfo::AUDIO_OUT_TYPE_VOICE_RECOGNITION: - dst_type = SOUND_TYPE_VOICE; - break; - case CAudioInfo::AUDIO_OUT_TYPE_RINGTONE_VOIP: - dst_type = SOUND_TYPE_RINGTONE; - break; - case CAudioInfo::AUDIO_OUT_TYPE_VOIP: - dst_type = SOUND_TYPE_VOIP; - break; - default: - dst_type = SOUND_TYPE_MEDIA; - break; - } + case CAudioInfo::AUDIO_OUT_TYPE_MEDIA: + dst_type = SOUND_TYPE_MEDIA; + break; + case CAudioInfo::AUDIO_OUT_TYPE_SYSTEM: + dst_type = SOUND_TYPE_SYSTEM; + break; + case CAudioInfo::AUDIO_OUT_TYPE_ALARM: + dst_type = SOUND_TYPE_ALARM; + break; + case CAudioInfo::AUDIO_OUT_TYPE_NOTIFICATION: + case CAudioInfo::AUDIO_OUT_TYPE_EMERGENCY: + dst_type = SOUND_TYPE_NOTIFICATION; + break; + case CAudioInfo::AUDIO_OUT_TYPE_VOICE_INFORMATION: + dst_type = SOUND_TYPE_VOICE; + break; + case CAudioInfo::AUDIO_OUT_TYPE_RINGTONE_VOIP: + dst_type = SOUND_TYPE_RINGTONE; + break; + case CAudioInfo::AUDIO_OUT_TYPE_VOIP: + dst_type = SOUND_TYPE_VOIP; + break; + default: + dst_type = SOUND_TYPE_MEDIA; + break; + } } static audio_io_state_e _convert_state_type(const CAudioInfo::EAudioIOState src_state) { @@ -418,6 +412,8 @@ int cpp_audio_in_create_loopback(int sample_rate, audio_channel_e channel, audio THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "Parameters are NULL input:%p", input); } + _check_audio_param(sample_rate, channel, type); + handle = new audio_io_s; if (handle == NULL) { THROW_ERROR_MSG(CAudioError::ERROR_OUT_OF_MEMORY, "Failed allocation handle"); @@ -491,7 +487,7 @@ int cpp_audio_in_set_stream_info(audio_in_h input, sound_stream_info_h stream_in if ((errorCode = sound_manager_get_type_from_stream_information (stream_info, &type)) != SOUND_MANAGER_ERROR_NONE) { THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "Parameter stream_info->stream_type is invalid [ret:%d]", errorCode); } - handle->audioIoHandle->getAudioInfo().convertStreamType2AudioType(type, &AudioType); + handle->audioIoHandle->getAudioInfo().convertInputStreamType2AudioType(type, &AudioType); handle->audioIoHandle->getAudioInfo().setAudioType(AudioType); if ((errorCode = sound_manager_get_index_from_stream_information (stream_info, &index)) != SOUND_MANAGER_ERROR_NONE) { @@ -625,8 +621,8 @@ int cpp_audio_in_read(audio_in_h input, void *buffer, unsigned int length) { int ret = 0; try { - if (handle == NULL) { - THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "Parameters are NULL input:%p", input); + if (handle == NULL || buffer == NULL) { + THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "Parameters are NULL input:%p, buffer:%p", input, buffer); } assert(handle->audioIoHandle); @@ -889,8 +885,8 @@ int cpp_audio_in_peek(audio_in_h input, const void **buffer, unsigned int *lengt audio_io_s* handle = static_cast(input); try { - if (handle == NULL) { - THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "Parameters are NULL input:%p", input); + if (handle == NULL || buffer == NULL) { + THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "Parameters are NULL input:%p, buffer:%p", input, buffer); } CAudioInput* inputHandle = dynamic_cast(handle->audioIoHandle); @@ -929,8 +925,8 @@ int cpp_audio_in_set_state_changed_cb(audio_in_h input, audio_in_state_changed_c audio_io_s* handle = static_cast(input); try { - if (handle == NULL) { - THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "Parameters are NULL output:%p, callback:%p", input, callback); + if (handle == NULL || callback == NULL) { + THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "Parameters are NULL input:%p, callback:%p", input, callback); } assert(handle->audioIoHandle); @@ -984,13 +980,17 @@ int cpp_audio_in_unset_state_changed_cb(audio_in_h input) { int cpp_audio_out_create(int sample_rate, audio_channel_e channel, audio_sample_type_e type, sound_type_e sound_type, audio_out_h *output) { audio_io_s* handle = NULL; try { + if (output == NULL) { + THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "Parameters are NULL output:%p", output); + } + + _check_audio_param(sample_rate, channel, type, sound_type); + handle = new audio_io_s; if (handle == NULL) { THROW_ERROR_MSG(CAudioError::ERROR_OUT_OF_MEMORY, "Failed allocation handle"); } - _check_audio_param(sample_rate, channel, type, sound_type); - CAudioInfo audioInfo = _generate_audio_output_info(sample_rate, channel, type, sound_type); handle->audioIoHandle = new CAudioOutput(audioInfo); @@ -1011,7 +1011,7 @@ int cpp_audio_out_create(int sample_rate, audio_channel_e channel, audio_sample_ VALID_POINTER_END VALID_POINTER_START(output) - *output = NULL; + *output = NULL; VALID_POINTER_END return _convert_CAudioError(e); @@ -1023,12 +1023,18 @@ int cpp_audio_out_create(int sample_rate, audio_channel_e channel, audio_sample_ int cpp_audio_out_create_new(int sample_rate, audio_channel_e channel, audio_sample_type_e type, audio_out_h *output) { audio_io_s* handle = NULL; try { + if (output == NULL) { + THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "Parameters are NULL output:%p", output); + } + + _check_audio_param(sample_rate, channel, type, SOUND_TYPE_SYSTEM /*default check */); + handle = new audio_io_s; if (handle == NULL) { THROW_ERROR_MSG(CAudioError::ERROR_OUT_OF_MEMORY, "Failed allocation handle"); } - CAudioInfo audioInfo = _generate_audio_output_info(sample_rate, channel, type, SOUND_TYPE_MEDIA /* default sound_tyoe */); + CAudioInfo audioInfo = _generate_audio_output_info(sample_rate, channel, type, SOUND_TYPE_MEDIA /* default sound_type */); handle->audioIoHandle = new CAudioOutput(audioInfo); if (handle == NULL) { @@ -1048,7 +1054,7 @@ int cpp_audio_out_create_new(int sample_rate, audio_channel_e channel, audio_sam VALID_POINTER_END VALID_POINTER_START(output) - *output = NULL; + *output = NULL; VALID_POINTER_END return _convert_CAudioError(e); @@ -1096,7 +1102,7 @@ int cpp_audio_out_set_stream_info(audio_out_h output, sound_stream_info_h stream if ((errorCode = sound_manager_get_type_from_stream_information (stream_info, &type)) != SOUND_MANAGER_ERROR_NONE) { THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "Parameter stream_info->stream_type is invalid [ret:%d]", errorCode); } - handle->audioIoHandle->getAudioInfo().convertStreamType2AudioType(type, &AudioType); + handle->audioIoHandle->getAudioInfo().convertOutputStreamType2AudioType(type, &AudioType); handle->audioIoHandle->getAudioInfo().setAudioType(AudioType); if ((errorCode = sound_manager_get_index_from_stream_information (stream_info, &index)) != SOUND_MANAGER_ERROR_NONE) { @@ -1230,8 +1236,8 @@ int cpp_audio_out_write(audio_out_h output, void *buffer, unsigned int length) { int ret = 0; try { - if (handle == NULL) { - THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "Parameter is NULL output:%p", output); + if (handle == NULL || buffer == NULL) { + THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "Parameter is NULL output:%p, buffer:%p", output, buffer); } assert(handle->audioIoHandle); @@ -1436,7 +1442,7 @@ int cpp_audio_out_set_stream_cb(audio_out_h output, audio_out_stream_cb callback audio_io_s* handle = static_cast(output); try { - if (handle == NULL) { + if (handle == NULL || callback == NULL) { THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "Parameters are NULL output:%p, callback:%p", output, callback); } @@ -1488,7 +1494,7 @@ int cpp_audio_out_set_state_changed_cb(audio_out_h output, audio_in_state_change audio_io_s* handle = static_cast(output); try { - if (handle == NULL) { + if (handle == NULL || callback == NULL) { THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INVALID_ARGUMENT, "Parameters are NULL output:%p, callback:%p", output, callback); }