Skip to content

Commit

Permalink
feat: add ten:builtin_extension_group
Browse files Browse the repository at this point in the history
  • Loading branch information
halajohn committed Sep 24, 2024
1 parent 25d35cc commit ef9ff1d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ TEN_RUNTIME_PRIVATE_API void ten_builtin_extension_group_addon_destroy_instance(
TEN_UNUSED ten_addon_t *addon, ten_env_t *ten_env, void *_extension_group,
void *context);

TEN_RUNTIME_PRIVATE_API void ten_register_builtin_extension_group(void);
TEN_RUNTIME_PRIVATE_API void ten_builtin_extension_group_addon_register(void);

TEN_RUNTIME_PRIVATE_API void ten_unregister_builtin_extension_group(void);
TEN_RUNTIME_PRIVATE_API void ten_builtin_extension_group_addon_unregister(void);
3 changes: 0 additions & 3 deletions core/src/ten_runtime/app/ten_env/on_xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ static void ten_app_on_configure_done_internal(ten_app_t *self) {
}

ten_addon_load_all(&err);
ten_register_builtin_extension_group();

if (!ten_app_get_predefined_graphs_from_property(self)) {
return;
Expand Down Expand Up @@ -223,6 +222,4 @@ void ten_app_on_deinit_done(ten_env_t *ten_env) {

ten_env_close(self->ten_env);
ten_runloop_stop(self->loop);

ten_unregister_builtin_extension_group();
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,28 @@ void ten_builtin_extension_group_addon_destroy_instance(
ten_env_on_destroy_instance_done(ten_env, context, NULL);
}

void ten_register_builtin_extension_group(void) {
// Register the test_extension_group addon.
ten_addon_t *builtin_extension_group_addon =
ten_addon_create(ten_builtin_extension_group_addon_on_init, NULL,
ten_builtin_extension_group_addon_create_instance,
ten_builtin_extension_group_addon_destroy_instance);

static ten_addon_t builtin_extension_group_addon = {
NULL,
TEN_ADDON_SIGNATURE,
ten_builtin_extension_group_addon_on_init,
NULL,
NULL,
NULL,
ten_builtin_extension_group_addon_create_instance,
ten_builtin_extension_group_addon_destroy_instance,
NULL,
NULL,
};

// Because the name registered by this `builtin_extension_group` is a special
// name (`ten:builtin_extension_group`), with a `:` in the middle, we can't use
// the convenient macro `TEN_REGISTER_ADDON_AS_EXTENSION_GROUP`. We have to use
// an inner register method instead. However, the meaning is exactly the same.
void ten_builtin_extension_group_addon_register(void) {
ten_addon_register_extension_group(TEN_STR_BUILTIN_EXTENSION_GROUP,
builtin_extension_group_addon);
&builtin_extension_group_addon);
}

void ten_unregister_builtin_extension_group(void) {
ten_addon_t *addon =
ten_addon_unregister_extension_group(TEN_STR_BUILTIN_EXTENSION_GROUP);
ten_addon_destroy(addon);
void ten_builtin_extension_group_addon_unregister(void) {
ten_addon_unregister_extension_group(TEN_STR_BUILTIN_EXTENSION_GROUP);
}
5 changes: 5 additions & 0 deletions core/src/ten_runtime/global/on_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Refer to the "LICENSE" file in the root directory for more information.
//
#include "include_internal/ten_runtime/common/log.h"
#include "include_internal/ten_runtime/extension_group/builtin/builtin_extension_group.h"
#include "include_internal/ten_runtime/global/global.h"
#include "include_internal/ten_runtime/global/signal.h"
#include "include_internal/ten_utils/backtrace/backtrace.h"
Expand Down Expand Up @@ -33,9 +34,13 @@ TEN_CONSTRUCTOR(ten_runtime_on_load) {
ten_global_setup_signal_stuff();
ten_log_global_init();
ten_log_global_set_output_level(DEFAULT_LOG_OUTPUT_LEVEL);

ten_builtin_extension_group_addon_register();
}

TEN_DESTRUCTOR(ten_runtime_on_unload) {
ten_builtin_extension_group_addon_unregister();

ten_global_deinit();
ten_log_global_deinit();
ten_backtrace_destroy_global();
Expand Down

0 comments on commit ef9ff1d

Please sign in to comment.