*name = (char*)info->name;
return MA_ERROR_NONE;
}
+
+int ma_get_recording_audio_source_type(char** type) {
+ if (0 != __ma_get_feature_enabled()) {
+ return MA_ERROR_NOT_SUPPORTED;
+ }
+
+ if (0 != __ma_check_privilege()) {
+ return MA_ERROR_PERMISSION_DENIED;
+ }
+
+ if (NULL == type) {
+ SLOG(LOG_ERROR, TAG_MAC, "[ERROR] Invalid parameter");
+ return MA_ERROR_INVALID_PARAMETER;
+ }
+
+ ma_state_e state;
+ if (0 != ma_client_get_client_state(g_ma, &state)) {
+ SLOG(LOG_ERROR, TAG_MAC, "[ERROR] A handle is not available"); //LCOV_EXCL_LINE
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ /* check state */
+ if (state != MA_STATE_READY) {
+ SLOG(LOG_ERROR, TAG_MAC, "[ERROR] Invalid State: Current state is not 'READY'"); //LCOV_EXCL_LINE
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ SLOG(LOG_DEBUG, TAG_MAC, "[Client DEBUG] Get recording audio source type");
+
+ int count = 0;
+ int ret = -1;
+ int pid = getpid();
+ do {
+ ret = ma_dbus_get_recording_audio_source_type(pid, type);
+ if (0 != ret) {
+ if (MA_ERROR_TIMED_OUT != ret) {
+ SLOG(LOG_ERROR, TAG_MAC, "[ERROR] Fail to get audio source type");
+ break;
+ } else {
+ SLOG(LOG_WARN, TAG_MAC, "[WARNING] Retry to get audio source type");
+ usleep(10000);
+ count++;
+ if (MA_RETRY_COUNT == count) {
+ SLOG(LOG_ERROR, TAG_MAC, "[ERROR] Fail to get audio source type");
+ break;
+ }
+ }
+ }
+ } while (0 != ret);
+
+ return ret;
+}
\ No newline at end of file
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INVALID);
-
DBusError err;
dbus_error_init(&err);
return result;
}
+int ma_dbus_get_recording_audio_source_type(int pid, char** type)
+{
+ if (0 != __dbus_check()) {
+ return MA_ERROR_OPERATION_FAILED;
+ }
+
+ DBusMessage* msg;
+
+ msg = dbus_message_new_method_call(
+ MA_SERVER_SERVICE_NAME,
+ MA_SERVER_SERVICE_OBJECT_PATH,
+ MA_SERVER_SERVICE_INTERFACE,
+ MA_METHOD_GET_RECORDING_AUDIO_SOURCE_TYPE);
+
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_MAC, "@@ Request multi-assistant recording audio source type : Fail to make message"); //LCOV_EXCL_LINE
+ return MA_ERROR_OPERATION_FAILED;
+ } else {
+ SLOG(LOG_DEBUG, TAG_MAC, "[DEBUG] multi-assistant recording audio source type");
+ }
+
+ dbus_message_append_args(msg,
+ DBUS_TYPE_INT32, &pid,
+ DBUS_TYPE_INVALID);
+
+ DBusError err;
+ dbus_error_init(&err);
+
+ DBusMessage* result_msg = NULL;
+ int result = MA_ERROR_OPERATION_FAILED;
+
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
+ dbus_message_unref(msg);
+
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_DEBUG, TAG_MAC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE
+ dbus_error_free(&err);
+ }
+
+ char* tmp_type = NULL;
+
+ if (NULL != result_msg) {
+ dbus_message_get_args(result_msg, &err,
+ DBUS_TYPE_INT32, &result,
+ DBUS_TYPE_STRING, &tmp_type,
+ DBUS_TYPE_INVALID);
+
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_MAC, "@@ Get arguments error (%s)", err.message);
+ dbus_error_free(&err);
+ result = MA_ERROR_OPERATION_FAILED;
+ }
+ dbus_message_unref(result_msg);
+
+ if (0 == result && NULL != type) {
+ *type = strdup(tmp_type);
+ SLOG(LOG_DEBUG, TAG_MAC, "@@ multi-assistant get recording audio source type : result = %d, type = %s", result, *type);
+ } else {
+ SLOG(LOG_ERROR, TAG_MAC, "@@ multi-assistant get recording audio source type : result = %d, type(%p)", result, type);
+ }
+ } else {
+ SLOG(LOG_ERROR, TAG_MAC, "@@ Result message is NULL");
+ ma_dbus_reconnect();
+ result = MA_ERROR_TIMED_OUT;
+ }
+
+ return result;
+}
+
int ma_dbus_send_asr_result(int pid, ma_asr_result_event_e event, const char* asr_result)
{
if (0 != __dbus_check()) {
int ma_dbus_send_assistant_specific_command(int pid, const char* command);
+int ma_dbus_get_recording_audio_source_type(int pid, char** type);
+
#ifdef __cplusplus
}
#endif
#define MA_METHOD_INITIALIZE "ma_method_initialize"
#define MA_METHOD_DEINITIALIZE "ma_method_deinitialize"
#define MA_METHOD_GET_RECORDING_AUDIO_FORMAT "ma_method_get_recording_audio_format"
+#define MA_METHOD_GET_RECORDING_AUDIO_SOURCE_TYPE "ma_method_get_recording_audio_source_type"
#define MA_METHOD_SEND_ASR_RESULT "ma_method_send_asr_result"
#define MA_METHOD_SEND_RESULT "ma_method_send_result"
#define MA_METHOD_SEND_RECOGNITION_RESULT "ma_method_send_recognition_result"
* @retval #MA_ERROR_INVALID_PARAMETER Invalid parameter
*/
int ma_assistant_info_get_name(ma_assistant_info_h handle, char** name);
+
+/**
+ * @brief Gets the type information of recording audio source.
+ * @since_tizen 5.5
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @remarks You must release @a type using free().
+ * @param[out] type The audio source type
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MA_ERROR_NONE Successful
+ * @retval #MA_ERROR_NOT_SUPPORTED Not supported
+ * @retval #MA_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #MA_ERROR_INVALID_STATE Invalid state
+ * @retval #MA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MA_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @pre The state should be #MA_STATE_READY.
+ */
+int ma_get_recording_audio_source_type(char** type);
+
#ifdef __cplusplus
}
#endif