+
+void CAudioIO::setStreamInfo(sound_stream_info_h stream_info) throw(CAudioError) {
+ if (stream_info == NULL)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_ARGUMENT, "stream_info is NULL");
+
+ if (__mIsInit == false)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
+
+ try {
+ if (mState != CAudioInfo::EAudioIOState::AUDIO_IO_STATE_IDLE)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_STATE, "it is not permitted while started");
+
+ int errorCode = SOUND_MANAGER_ERROR_NONE;
+ CAudioInfo::EAudioType audioType = CAudioInfo::EAudioType::AUDIO_IN_TYPE_MEDIA;
+ char *type = NULL;
+ int index = -1;
+ bool avail = false;
+
+ 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);
+
+ if (!avail)
+ THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_SUPPORTED_TYPE, "Input stream is not supported");
+
+ 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 (mDirection == CAudioInfo::EAudioDirection::AUDIO_DIRECTION_IN)
+ getAudioInfo().convertInputStreamType2AudioType(type, &audioType);
+ else
+ getAudioInfo().convertOutputStreamType2AudioType(type, &audioType);
+ 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);
+
+ getAudioInfo().setAudioIndex(index);
+
+ AUDIO_IO_LOGD("stream info(%p) is set", stream_info);
+ } catch (CAudioError e) {
+ throw e;
+ }
+}
+
+void CAudioIO::setInternalStreamInfo() throw(CAudioError) {
+ if (__mIsInit == false)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
+
+ try {
+ if (mState != CAudioInfo::EAudioIOState::AUDIO_IO_STATE_IDLE)
+ THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_STATE, "it is not permitted while started");
+
+ if (mpAudioSessionHandler &&
+ mpAudioSessionHandler->getMultimediaSession() == MM_SESSION_TYPE_VOIP) {
+ sound_stream_info_h stream_info = NULL;
+ mpAudioSessionHandler->getInternalVoipStreamInfo(&stream_info);
+ AUDIO_IO_LOGD("get internal VOIP stream info(%p)", stream_info);
+ setStreamInfo(stream_info);
+ }
+ } catch (CAudioError e) {
+ throw e;
+ }
+}