From 82fb9a1ddddaf648935fdeea00913ced6663c081 Mon Sep 17 00:00:00 2001 From: KimJeongYeon Date: Tue, 15 Sep 2015 13:35:47 +0900 Subject: [PATCH] audio-io fixed reference of CAudioInfo, check supported stream info [Version] 0.3.17 [Profile] Common [Issue Type] Bug [Dependency module] NA [Dependency commit] NA [Comment] Signed-off-by: KimJeongYeon Change-Id: I30625eb98b6edf639c73280c1a43cd5628ad6133 --- include/CAudioIO.h | 2 +- include/CAudioInfo.h | 4 +-- include/CPulseStreamSpec.h | 2 +- packaging/capi-media-audio-io.spec | 2 +- src/cpp/CAudioIO.cpp | 2 +- src/cpp/CAudioInfo.cpp | 39 ++++++++++++----------------- src/cpp/CAudioInput.cpp | 2 +- src/cpp/CPulseStreamSpec.cpp | 2 +- src/cpp/cpp_audio_io.cpp | 50 ++++++++++++++++++++++++++------------ 9 files changed, 57 insertions(+), 48 deletions(-) diff --git a/include/CAudioIO.h b/include/CAudioIO.h index dc648a2..37054dd 100644 --- a/include/CAudioIO.h +++ b/include/CAudioIO.h @@ -84,7 +84,7 @@ namespace tizen_media_audio { virtual void onSignal(CAudioSessionHandler* pHandler, mm_sound_signal_name_t signal, int value); /* Methods */ - CAudioInfo getAudioInfo() throw (CAudioError); + CAudioInfo& getAudioInfo() throw (CAudioError); virtual void setStreamCallback(SStreamCallback callback) throw (CAudioError); SStreamCallback getStreamCallback() throw (CAudioError); diff --git a/include/CAudioInfo.h b/include/CAudioInfo.h index 86ba7d8..0a24381 100644 --- a/include/CAudioInfo.h +++ b/include/CAudioInfo.h @@ -97,9 +97,9 @@ namespace tizen_media_audio { EChannel getChannel(); ESampleType getSampleType(); EAudioType getAudioType(); - void setAudioType(EAudioType AudioType); + void setAudioType(EAudioType audioType); int getAudioIndex(); - void setAudioIndex(int AudioIndex); + void setAudioIndex(int audioIndex); void convertAudioType2StreamType (CAudioInfo::EAudioType audioType, char **streamType); void convertInputStreamType2AudioType (char *streamType, CAudioInfo::EAudioType *audioType); void convertOutputStreamType2AudioType (char *streamType, CAudioInfo::EAudioType *audioType); diff --git a/include/CPulseStreamSpec.h b/include/CPulseStreamSpec.h index 784524b..7d9ed96 100644 --- a/include/CPulseStreamSpec.h +++ b/include/CPulseStreamSpec.h @@ -54,7 +54,7 @@ namespace tizen_media_audio { /* Setter & Getter */ EStreamLatency getStreamLatency(); const char* getStreamLatencyToString(); - CAudioInfo getAudioInfo(); + CAudioInfo& getAudioInfo(); pa_sample_spec getSampleSpec(); pa_channel_map getChannelMap(); const char* getStreamName(); diff --git a/packaging/capi-media-audio-io.spec b/packaging/capi-media-audio-io.spec index ef5b9a5..fa1c419 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.16 +Version: 0.3.17 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/cpp/CAudioIO.cpp b/src/cpp/CAudioIO.cpp index 833fbe8..479608c 100644 --- a/src/cpp/CAudioIO.cpp +++ b/src/cpp/CAudioIO.cpp @@ -384,7 +384,7 @@ void CAudioIO::flush() throw (CAudioError) { } } -CAudioInfo CAudioIO::getAudioInfo() throw (CAudioError) { +CAudioInfo& CAudioIO::getAudioInfo() throw (CAudioError) { if (__mIsInit == false) { THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO"); } diff --git a/src/cpp/CAudioInfo.cpp b/src/cpp/CAudioInfo.cpp index e847f68..4cb002d 100644 --- a/src/cpp/CAudioInfo.cpp +++ b/src/cpp/CAudioInfo.cpp @@ -74,8 +74,8 @@ CAudioInfo::EAudioType CAudioInfo::getAudioType() { return __mAudioType; } -void CAudioInfo::setAudioType(CAudioInfo::EAudioType AudioType) { - __mAudioType = AudioType; +void CAudioInfo::setAudioType(CAudioInfo::EAudioType audioType) { + __mAudioType = audioType; return; } @@ -83,13 +83,12 @@ int CAudioInfo::getAudioIndex() { return __mAudioIndex; } -void CAudioInfo::setAudioIndex(int AudioIndex) { - __mAudioIndex = AudioIndex; +void CAudioInfo::setAudioIndex(int audioIndex) { + __mAudioIndex = audioIndex; return; } -void CAudioInfo::convertAudioType2StreamType (CAudioInfo::EAudioType audioType, char **streamType) -{ +void CAudioInfo::convertAudioType2StreamType (CAudioInfo::EAudioType audioType, char **streamType) { if (audioType < CAudioInfo::EAudioType::AUDIO_IN_TYPE_MEDIA || audioType >= CAudioInfo::EAudioType::AUDIO_TYPE_MAX) { THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_SUPPORTED_TYPE, "The audioType is not supported [audioType:%d]", audioType); } @@ -97,33 +96,25 @@ void CAudioInfo::convertAudioType2StreamType (CAudioInfo::EAudioType audioType, return; } -void CAudioInfo::convertInputStreamType2AudioType (char *streamType, CAudioInfo::EAudioType *audioType) -{ - unsigned int i; - for (i = (unsigned int)CAudioInfo::EAudioType::AUDIO_IN_TYPE_MEDIA ; i < (unsigned int)CAudioInfo::EAudioType::AUDIO_OUT_TYPE_MEDIA ; i++) { +void CAudioInfo::convertInputStreamType2AudioType (char *streamType, CAudioInfo::EAudioType *audioType) { + for (unsigned int i = (unsigned int)CAudioInfo::EAudioType::AUDIO_IN_TYPE_MEDIA ; i < (unsigned int)CAudioInfo::EAudioType::AUDIO_OUT_TYPE_MEDIA ; i++) { if (!strcmp((char *)__STREAM_TYPE_TABLE[i], streamType)) { - break; + *audioType = (CAudioInfo::EAudioType)i; + return; } } - if (i >= (unsigned int)CAudioInfo::EAudioType::AUDIO_OUT_TYPE_MEDIA) { - THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_SUPPORTED_TYPE, "The streamType is not supported [streamType:%s]", streamType); - } - *audioType = (CAudioInfo::EAudioType)i; + THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_SUPPORTED_TYPE, "The streamType of input is not supported [streamType:%s]", streamType); return; } -void CAudioInfo::convertOutputStreamType2AudioType (char *streamType, CAudioInfo::EAudioType *audioType) -{ - unsigned int i; - for (i = (unsigned int)CAudioInfo::EAudioType::AUDIO_OUT_TYPE_MEDIA ; i < (unsigned int)CAudioInfo::EAudioType::AUDIO_TYPE_MAX ; i++) { +void CAudioInfo::convertOutputStreamType2AudioType (char *streamType, CAudioInfo::EAudioType *audioType) { + for (unsigned int i = (unsigned int)CAudioInfo::EAudioType::AUDIO_OUT_TYPE_MEDIA ; i < (unsigned int)CAudioInfo::EAudioType::AUDIO_TYPE_MAX ; i++) { if (!strcmp((char *)__STREAM_TYPE_TABLE[i], streamType)) { - break; + *audioType = (CAudioInfo::EAudioType)i; + return; } } - if (i >= (unsigned int)CAudioInfo::EAudioType::AUDIO_TYPE_MAX) { - THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_SUPPORTED_TYPE, "The streamType is not supported [streamType:%s]", streamType); - } - *audioType = (CAudioInfo::EAudioType)i; + THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_SUPPORTED_TYPE, "The streamType of output is not supported [streamType:%s]", streamType); return; } diff --git a/src/cpp/CAudioInput.cpp b/src/cpp/CAudioInput.cpp index 1bec4a1..e137075 100644 --- a/src/cpp/CAudioInput.cpp +++ b/src/cpp/CAudioInput.cpp @@ -164,7 +164,7 @@ void CAudioInput::prepare() throw (CAudioError) { } // Init StreamSpec - AUDIO_IO_LOGD("Set Strem Spec : CPulseStreamSpec::STREAM_LATENCY_INPUT_MID"); + AUDIO_IO_LOGD("Set Stream Spec : CPulseStreamSpec::STREAM_LATENCY_INPUT_MID"); CPulseStreamSpec::EStreamLatency streamSpec = CPulseStreamSpec::EStreamLatency::STREAM_LATENCY_INPUT_MID; CPulseStreamSpec spec(streamSpec, mAudioInfo); diff --git a/src/cpp/CPulseStreamSpec.cpp b/src/cpp/CPulseStreamSpec.cpp index bbc1b65..b40771d 100644 --- a/src/cpp/CPulseStreamSpec.cpp +++ b/src/cpp/CPulseStreamSpec.cpp @@ -161,7 +161,7 @@ const char* CPulseStreamSpec::getStreamLatencyToString() { return latency; } -CAudioInfo CPulseStreamSpec::getAudioInfo() { +CAudioInfo& CPulseStreamSpec::getAudioInfo() { return __mAudioInfo; } diff --git a/src/cpp/cpp_audio_io.cpp b/src/cpp/cpp_audio_io.cpp index 59ecc1a..97355f1 100644 --- a/src/cpp/cpp_audio_io.cpp +++ b/src/cpp/cpp_audio_io.cpp @@ -478,20 +478,29 @@ int cpp_audio_in_set_stream_info(audio_in_h input, sound_stream_info_h stream_in assert(handle->audioIoHandle); int errorCode = SOUND_MANAGER_ERROR_NONE; - CAudioInfo::EAudioType AudioType = CAudioInfo::EAudioType::AUDIO_IN_TYPE_MEDIA; + CAudioInfo::EAudioType audioType = CAudioInfo::EAudioType::AUDIO_IN_TYPE_MEDIA; char *type = NULL; int index = -1; + bool avail = false; - if ((errorCode = sound_manager_get_type_from_stream_information (stream_info, &type)) != SOUND_MANAGER_ERROR_NONE) { - THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info->stream_type is invalid [ret:%d]", errorCode); + if ((errorCode = sound_manager_is_available_stream_information(stream_info, NATIVE_API_AUDIO_IO, &avail)) != SOUND_MANAGER_ERROR_NONE) { + THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info is invalid [ret:%d]", errorCode); } - 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) { - THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info->index is invalid [ret:%d]", errorCode); + if (avail) { + if ((errorCode = sound_manager_get_type_from_stream_information (stream_info, &type)) != SOUND_MANAGER_ERROR_NONE) { + THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info->stream_type is invalid [ret:%d]", errorCode); + } + 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) { + THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info->index is invalid [ret:%d]", errorCode); + } + handle->audioIoHandle->getAudioInfo().setAudioIndex(index); + } else { + THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_SUPPORTED_TYPE, "Input stream is not supported"); } - handle->audioIoHandle->getAudioInfo().setAudioIndex(index); } catch (CAudioError e) { AUDIO_IO_LOGE("%s", e.getErrorMsg()); return __convert_CAudioError(e); @@ -1096,20 +1105,29 @@ int cpp_audio_out_set_stream_info(audio_out_h output, sound_stream_info_h stream assert(handle->audioIoHandle); int errorCode = SOUND_MANAGER_ERROR_NONE; - CAudioInfo::EAudioType AudioType = CAudioInfo::EAudioType::AUDIO_OUT_TYPE_MEDIA; + CAudioInfo::EAudioType audioType = CAudioInfo::EAudioType::AUDIO_OUT_TYPE_MEDIA; char *type = NULL; int index = -1; + bool avail = false; - if ((errorCode = sound_manager_get_type_from_stream_information (stream_info, &type)) != SOUND_MANAGER_ERROR_NONE) { - THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info->stream_type is invalid [ret:%d]", errorCode); + if ((errorCode = sound_manager_is_available_stream_information(stream_info, NATIVE_API_AUDIO_IO, &avail)) != SOUND_MANAGER_ERROR_NONE) { + THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info is invalid [ret:%d]", errorCode); } - 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) { - THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info->index is invalid [ret:%d]", errorCode); + if (avail) { + if ((errorCode = sound_manager_get_type_from_stream_information (stream_info, &type)) != SOUND_MANAGER_ERROR_NONE) { + THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info->stream_type is invalid [ret:%d]", errorCode); + } + 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) { + THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info->index is invalid [ret:%d]", errorCode); + } + handle->audioIoHandle->getAudioInfo().setAudioIndex(index); + } else { + THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_SUPPORTED_TYPE, "Output stream is not supported"); } - handle->audioIoHandle->getAudioInfo().setAudioIndex(index); } catch (CAudioError e) { AUDIO_IO_LOGE("%s", e.getErrorMsg()); return __convert_CAudioError(e); -- 2.7.4