void CreateHMINotification(const hmi_apis::FunctionID::eType& function_id,
const NsSmart::SmartObject& msg_params) const;
+ /**
+ * @brief Converts HMI result code to Mobile result code
+ *
+ * @param hmi_code HMI result code
+ * @return Mobile result code
+ */
+ mobile_apis::Result::eType GetMobileResultCode(
+ const hmi_apis::Common_Result::eType& hmi_code) const;
+
protected:
unsigned int default_timeout_;
RequestState current_state_;
}
}
+mobile_apis::Result::eType CommandRequestImpl::GetMobileResultCode(
+ const hmi_apis::Common_Result::eType& hmi_code) const {
+
+ mobile_apis::Result::eType mobile_result = mobile_apis::Result::GENERIC_ERROR;
+ switch (hmi_code) {
+ case hmi_apis::Common_Result::SUCCESS: {
+ mobile_result = mobile_apis::Result::SUCCESS;
+ break;
+ }
+ case hmi_apis::Common_Result::UNSUPPORTED_REQUEST: {
+ mobile_result = mobile_apis::Result::UNSUPPORTED_REQUEST;
+ break;
+ }
+ case hmi_apis::Common_Result::UNSUPPORTED_RESOURCE: {
+ mobile_result = mobile_apis::Result::UNSUPPORTED_RESOURCE;
+ break;
+ }
+ case hmi_apis::Common_Result::DISALLOWED: {
+ mobile_result = mobile_apis::Result::DISALLOWED;
+ break;
+ }
+ case hmi_apis::Common_Result::REJECTED: {
+ mobile_result = mobile_apis::Result::REJECTED;
+ break;
+ }
+ case hmi_apis::Common_Result::ABORTED: {
+ mobile_result = mobile_apis::Result::ABORTED;
+ break;
+ }
+ case hmi_apis::Common_Result::IGNORED: {
+ mobile_result = mobile_apis::Result::IGNORED;
+ break;
+ }
+ case hmi_apis::Common_Result::RETRY: {
+ mobile_result = mobile_apis::Result::RETRY;
+ break;
+ }
+ case hmi_apis::Common_Result::IN_USE: {
+ mobile_result = mobile_apis::Result::IN_USE;
+ break;
+ }
+ case hmi_apis::Common_Result::DATA_NOT_AVAILABLE: {
+ mobile_result = mobile_apis::Result::VEHICLE_DATA_NOT_AVAILABLE;
+ break;
+ }
+ case hmi_apis::Common_Result::TIMED_OUT: {
+ mobile_result = mobile_apis::Result::TIMED_OUT;
+ break;
+ }
+ case hmi_apis::Common_Result::INVALID_DATA: {
+ mobile_result = mobile_apis::Result::INVALID_DATA;
+ break;
+ }
+ case hmi_apis::Common_Result::CHAR_LIMIT_EXCEEDED: {
+ mobile_result = mobile_apis::Result::CHAR_LIMIT_EXCEEDED;
+ break;
+ }
+ case hmi_apis::Common_Result::INVALID_ID: {
+ mobile_result = mobile_apis::Result::INVALID_ID;
+ break;
+ }
+ case hmi_apis::Common_Result::DUPLICATE_NAME: {
+ mobile_result = mobile_apis::Result::DUPLICATE_NAME;
+ break;
+ }
+ case hmi_apis::Common_Result::APPLICATION_NOT_REGISTERED: {
+ mobile_result = mobile_apis::Result::APPLICATION_NOT_REGISTERED;
+ break;
+ }
+ case hmi_apis::Common_Result::WRONG_LANGUAGE: {
+ mobile_result = mobile_apis::Result::WRONG_LANGUAGE;
+ break;
+ }
+ case hmi_apis::Common_Result::OUT_OF_MEMORY: {
+ mobile_result = mobile_apis::Result::OUT_OF_MEMORY;
+ break;
+ }
+ case hmi_apis::Common_Result::TOO_MANY_PENDING_REQUESTS: {
+ mobile_result = mobile_apis::Result::TOO_MANY_PENDING_REQUESTS;
+ break;
+ }
+ case hmi_apis::Common_Result::NO_APPS_REGISTERED: {
+ mobile_result = mobile_apis::Result::APPLICATION_NOT_REGISTERED;
+ break;
+ }
+ case hmi_apis::Common_Result::NO_DEVICES_CONNECTED: {
+ mobile_result = mobile_apis::Result::APPLICATION_NOT_REGISTERED;
+ break;
+ }
+ case hmi_apis::Common_Result::WARNINGS: {
+ mobile_result = mobile_apis::Result::WARNINGS;
+ break;
+ }
+ case hmi_apis::Common_Result::GENERIC_ERROR: {
+ mobile_result = mobile_apis::Result::GENERIC_ERROR;
+ break;
+ }
+ case hmi_apis::Common_Result::USER_DISALLOWED: {
+ mobile_result = mobile_apis::Result::USER_DISALLOWED;
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Unknown HMI result code " << hmi_code);
+ break;
+ }
+ }
+
+ return mobile_result;
+}
+
} // namespace commands
} // namespace application_manager
void EndAudioPassThruRequest::Run() {
LOG4CXX_INFO(logger_, "EndAudioPassThruRequest::Run");
- bool ended_successfully = ApplicationManagerImpl::instance()->end_audio_pass_thru();
+ bool ended_successfully =
+ ApplicationManagerImpl::instance()->end_audio_pass_thru();
if (ended_successfully) {
SendHMIRequest(hmi_apis::FunctionID::UI_EndAudioPassThru, NULL, true);
- int32_t session_key =
- (*message_)[strings::params][strings::connection_key].asInt();
- ApplicationManagerImpl::instance()->StopAudioPassThru(session_key);
+ ApplicationManagerImpl::instance()->StopAudioPassThru(connection_key());
} else {
SendResponse(false, mobile_apis::Result::REJECTED,
"No PerformAudioPassThru is now active");
switch (event.id()) {
case hmi_apis::FunctionID::UI_PerformAudioPassThru: {
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
- message[strings::params][hmi_response::code].asInt());
- bool result = mobile_apis::Result::SUCCESS == result_code ||
- mobile_apis::Result::RETRY == result_code;
+ std::string return_info;
+ mobile_apis::Result::eType mobile_code =
+ GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt()));
- if (ApplicationManagerImpl::instance()->end_audio_pass_thru()) {
- int32_t session_key =
- (*message_)[strings::params][strings::connection_key].asUInt();
- ApplicationManagerImpl::instance()->StopAudioPassThru(session_key);
+ if (mobile_apis::Result::UNSUPPORTED_RESOURCE == mobile_code) {
+ mobile_code = mobile_apis::Result::WARNINGS;
+ return_info = "Unsupported phoneme type sent in a prompt";
}
- const char* return_info = NULL;
-
- if (result) {
- if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE ==
- static_cast<hmi_apis::Common_Result::eType>(result_code)) {
- result_code = mobile_apis::Result::WARNINGS;
- return_info = std::string("Unsupported phoneme type sent in a prompt").c_str();
- }
+ if (ApplicationManagerImpl::instance()->end_audio_pass_thru()) {
+ ApplicationManagerImpl::instance()->StopAudioPassThru(connection_key());
}
- SendResponse(result, result_code, return_info, &(message[strings::msg_params]));
+ bool result = mobile_apis::Result::SUCCESS == mobile_code ||
+ mobile_apis::Result::RETRY == mobile_code;
+
+ SendResponse(result, mobile_code, return_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
case hmi_apis::FunctionID::TTS_Stopped:{
SendRecordStartNotification();
StartMicrophoneRecording();
+ ApplicationManagerImpl::instance()->
+ updateRequestTimeout(connection_key(),
+ correlation_id(),
+ default_timeout());
break;
}
default: {
uint32_t session_key_;
const std::string fileName_;
int32_t offset_;
- bool shouldBeStoped_;
+ volatile bool shouldBeStoped_;
sync_primitives::Lock shouldBeStoped_lock_;
static const int32_t kAudioPassThruTimeout;
offset_ = 0;
- setShouldBeStopped(false);
-
while (true) {
if (getShouldBeStopped()) {
break;
}
- sendAudioChunkToMobile();
+ usleep(kAudioPassThruTimeout * 1000000);
if (getShouldBeStopped()) {
break;
}
+
+ sendAudioChunkToMobile();
}
+
+ LOG4CXX_TRACE_EXIT(logger_);
}
void AudioStreamSenderThread::sendAudioChunkToMobile() {
std::vector<uint8_t>::iterator from;
std::vector<uint8_t>::iterator to;
- usleep(kAudioPassThruTimeout * 1000000);
-
if (!file_system::ReadBinaryFile(fileName_, binaryData)) {
LOG4CXX_ERROR_EXT(logger_, "Unable to read file." << fileName_);
bool AudioStreamSenderThread::getShouldBeStopped() {
AutoLock auto_lock(shouldBeStoped_lock_);
+
return shouldBeStoped_;
}