Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: downgrade the log level for sending failure due to unconnected #423

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions core/include/ten_runtime/binding/cpp/detail/ten_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ class ten_env_t {
// the ownership of the data message to the TEN runtime.
auto *cpp_data_ptr = data.release();
delete cpp_data_ptr;
} else {
TEN_LOGE("Failed to send_data: %s.", data->get_name());
}

return rc;
Expand Down Expand Up @@ -154,8 +152,6 @@ class ten_env_t {
// the ownership of the message to the TEN runtime.
auto *cpp_frame_ptr = frame.release();
delete cpp_frame_ptr;
} else {
TEN_LOGE("Failed to send_video_frame %s.", frame->get_name());
}

return rc;
Expand Down Expand Up @@ -194,8 +190,6 @@ class ten_env_t {
// the ownership of the message to the TEN runtime.
auto *cpp_frame_ptr = frame.release();
delete cpp_frame_ptr;
} else {
TEN_LOGE("Failed to send_audio_frame %s.", frame->get_name());
}

return rc;
Expand Down Expand Up @@ -233,8 +227,6 @@ class ten_env_t {
// the C msg from the 'cmd'.
auto *cpp_cmd_ptr = cmd.release();
delete cpp_cmd_ptr;
} else {
TEN_LOGE("Failed to return_result_directly.");
}

return rc;
Expand Down Expand Up @@ -284,8 +276,6 @@ class ten_env_t {

auto *cpp_cmd_ptr = cmd.release();
delete cpp_cmd_ptr;
} else {
TEN_LOGE("Failed to return_result for cmd: %s", target_cmd->get_name());
}

return rc;
Expand Down
3 changes: 3 additions & 0 deletions core/include/ten_runtime/common/errno.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ typedef enum TEN_ERRNO {

// The TEN world is closed.
TEN_ERRNO_TEN_IS_CLOSED = 6,

// The msg is not connected in the graph.
TEN_ERRNO_MSG_NOT_CONNECTED = 7,
} TEN_ERRNO;

static_assert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "ten_runtime/ten_env_proxy/ten_env_proxy.h"
#include "ten_utils/lib/alloc.h"
#include "ten_utils/lib/error.h"
#include "ten_utils/log/log.h"
#include "ten_utils/macro/check.h"

typedef struct ten_env_notify_return_result_info_t {
Expand Down Expand Up @@ -116,15 +115,6 @@ static void ten_env_proxy_notify_return_result(ten_env_t *ten_env,
&err);
TEN_ASSERT(rc, "Should not happen.");
}

if (!rc) {
// The error cannot be handled by the developer, all we can do is to log
// the error.
TEN_LOGE(
"Failed to return result to Go, but no error handler is provided. "
"errno: %d, errmsg: %s",
ten_error_errno(&err), ten_error_errmsg(&err));
}
} else {
ten_go_callback_info_t *callback_info =
ten_go_callback_info_create(info->handler_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,6 @@ static void ten_env_proxy_notify_send_audio_frame(ten_env_t *ten_env,
if (notify_info->callback_handle == TEN_GO_NO_RESPONSE_HANDLER) {
res = ten_env_send_audio_frame(ten_env, notify_info->c_audio_frame, NULL,
NULL, &err);
if (!res) {
// The error cannot be handled by the developer, all we can do is to log
// the error.
TEN_LOGE(
"Failed to send audio frame, but no error handler is provided."
"errno: %d, errmsg: %s",
ten_error_errno(&err), ten_error_errmsg(&err));
}
} else {
ten_go_callback_info_t *info =
ten_go_callback_info_create(notify_info->callback_handle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "ten_utils/lib/alloc.h"
#include "ten_utils/lib/error.h"
#include "ten_utils/lib/smart_ptr.h"
#include "ten_utils/log/log.h"
#include "ten_utils/macro/check.h"
#include "ten_utils/macro/mark.h"

Expand Down Expand Up @@ -99,14 +98,6 @@ static void ten_env_proxy_notify_send_data(ten_env_t *ten_env,

if (notify_info->callback_handle == TEN_GO_NO_RESPONSE_HANDLER) {
res = ten_env_send_data(ten_env, notify_info->c_data, NULL, NULL, &err);
if (!res) {
// The error cannot be handled by the developer, all we can do is to log
// the error.
TEN_LOGE(
"Failed to send data, but no error handler is provided. errno: %d, "
"errmsg: %s",
ten_error_errno(&err), ten_error_errmsg(&err));
}
} else {
ten_go_callback_info_t *info =
ten_go_callback_info_create(notify_info->callback_handle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,6 @@ static void ten_env_proxy_notify_send_video_frame(ten_env_t *ten_env,
if (notify_info->callback_handle == TEN_GO_NO_RESPONSE_HANDLER) {
res = ten_env_send_video_frame(ten_env, notify_info->c_video_frame, NULL,
NULL, &err);
if (!res) {
// The error cannot be handled by the developer, all we can do is to log
// the error.
TEN_LOGE(
"Failed to send video frame, but no error handler is provided. "
"errno: %d, errmsg: %s",
ten_error_errno(&err), ten_error_errmsg(&err));
}
} else {
ten_go_callback_info_t *info =
ten_go_callback_info_create(notify_info->callback_handle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "include_internal/ten_runtime/binding/python/ten_env/ten_env.h"
#include "ten_runtime/msg/cmd_result/cmd_result.h"
#include "ten_utils/lib/error.h"
#include "ten_utils/log/log.h"
#include "ten_utils/macro/memory.h"

typedef struct ten_env_notify_return_result_info_t {
Expand Down Expand Up @@ -124,13 +123,6 @@ static void ten_env_proxy_notify_return_result(ten_env_t *ten_env,
rc = ten_env_return_result_directly(ten_env, info->c_cmd, NULL, NULL,
&err);
}

if (!rc) {
TEN_LOGE(
"Failed to return result, but no callback function is provided. "
"errno: %s, err_msg: %s",
ten_error_errno(&err), ten_error_errmsg(&err));
}
} else {
if (info->c_target_cmd) {
rc = ten_env_return_result(ten_env, info->c_cmd, info->c_target_cmd,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@ static void ten_env_proxy_notify_send_audio_frame(ten_env_t *ten_env,
if (notify_info->py_cb_func == NULL) {
res = ten_env_send_audio_frame(ten_env, notify_info->c_audio_frame, NULL,
NULL, &err);
if (!res) {
TEN_LOGE(
"Failed to send audio_frame, but no callback function is provided. "
"errno: "
"%s, err_msg: %s",
ten_error_errno(&err), ten_error_errmsg(&err));
}
} else {
res = ten_env_send_audio_frame(ten_env, notify_info->c_audio_frame,
proxy_send_audio_frame_callback,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "ten_runtime/msg/cmd_result/cmd_result.h"
#include "ten_runtime/ten_env_proxy/ten_env_proxy.h"
#include "ten_utils/lib/error.h"
#include "ten_utils/log/log.h"
#include "ten_utils/macro/check.h"
#include "ten_utils/macro/memory.h"

Expand Down Expand Up @@ -136,12 +135,6 @@ static void ten_env_proxy_notify_send_cmd(ten_env_t *ten_env, void *user_data) {
bool res = false;
if (notify_info->py_cb_func == NULL) {
res = send_cmd_func(ten_env, notify_info->c_cmd, NULL, NULL, &err);
if (!res) {
TEN_LOGE(
"Failed to send cmd, but no callback function is provided. errno: "
"%s, err_msg: %s",
ten_error_errno(&err), ten_error_errmsg(&err));
}
} else {
res = send_cmd_func(ten_env, notify_info->c_cmd, proxy_send_xxx_callback,
notify_info->py_cb_func, &err);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,6 @@ static void ten_env_proxy_notify_send_data(ten_env_t *ten_env,
bool res = false;
if (notify_info->py_cb_func == NULL) {
res = ten_env_send_data(ten_env, notify_info->c_data, NULL, NULL, &err);
if (!res) {
TEN_LOGE(
"Failed to send data, but no callback function is provided. errno: "
"%s, err_msg: %s",
ten_error_errno(&err), ten_error_errmsg(&err));
}
} else {
res = ten_env_send_data(ten_env, notify_info->c_data,
proxy_send_data_callback, notify_info->py_cb_func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,6 @@ static void ten_env_proxy_notify_send_video_frame(ten_env_t *ten_env,
if (notify_info->py_cb_func == NULL) {
res = ten_env_send_video_frame(ten_env, notify_info->c_video_frame, NULL,
NULL, &err);
if (!res) {
TEN_LOGE(
"Failed to send video_frame, but no callback function is provided. "
"errno: %d, err_msg: %s",
ten_error_errno(&err), ten_error_errmsg(&err));
}
} else {
res = ten_env_send_video_frame(ten_env, notify_info->c_video_frame,
proxy_send_video_frame_callback,
Expand Down
10 changes: 6 additions & 4 deletions core/src/ten_runtime/extension/extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,15 +495,17 @@ static bool ten_extension_determine_out_msg_dest_from_graph(

// Graph doesn't specify how to route the messages.

TEN_MSG_TYPE msg_type = ten_msg_get_type(msg);
const char *msg_name = ten_msg_get_name(msg);

if (err) {
ten_error_set(err, TEN_ERRNO_INVALID_GRAPH,
"Failed to find destination of a message (%s) from graph.",
msg_name);
ten_error_set(
err, TEN_ERRNO_MSG_NOT_CONNECTED,
"Failed to find destination of a '%s' message '%s' from graph.",
ten_msg_type_to_string(msg_type), msg_name);
} else {
if (ten_msg_is_cmd_and_result(msg)) {
TEN_LOGE("Failed to find destination of a command (%s) from graph.",
TEN_LOGD("Failed to find destination of a command '%s' from graph.",
msg_name);
} else {
// The amount of the data-like messages might be huge, so we don't
Expand Down
9 changes: 9 additions & 0 deletions core/src/ten_runtime/ten_env/internal/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "ten_runtime/msg/msg.h"
#include "ten_runtime/ten_env/ten_env.h"
#include "ten_utils/lib/error.h"
#include "ten_utils/log/log.h"
#include "ten_utils/macro/check.h"
#include "ten_utils/macro/memory.h"

Expand Down Expand Up @@ -113,6 +114,14 @@ static bool ten_send_msg_internal(
}

done:
if (!result) {
if (ten_error_errno(err) == TEN_ERRNO_MSG_NOT_CONNECTED) {
TEN_LOGD("Failed to send message: %s", ten_error_errmsg(err));
} else {
TEN_LOGE("Failed to send message: %s", ten_error_errmsg(err));
}
}

if (err_new_created) {
ten_error_destroy(err);
}
Expand Down
Loading