refactor: Move all hook and IO libraries to use btools log and thread api

Remove usages of AVS threads and logging functions from the bemanitools backend. Use the bemanitools 6 API instead
which propagates interfaces to call thread and log APIs.

Prior design decisions for using these were:
- have a single log stream through the AVS logging system for “neatness”, log output redirection options in launcher, and theoretically logging to an xrpc endpoint
- IIDX 19 to IIDX 24 crash the AVS logging engine in libavs due to IO hook code running in a non AVS thread (threads in ezusb library) causing a stackoverflow when trying to acquire a mutex (see dev journal 2018-02-10-logging-breakdown-avs.md for details)

With a flexible log sink architecture in the core of bemanitools, and a separate writer function that is hooked up as a log writer to AVS, log streams are still unified on a sink level. This takes care of having all log messaged sinked to the same targets no matter how many logging engines are using them.

This avoids going through the AVS logging engine with the IO related hooking code in iidx, which just uses the bemanitools logging engine instead.

Furthermore, this removes any needs to having to switch thread and logging implementations once AVS is booted which significantly simplifies the runtime orchestration during bootstrapping.

The log-server, which was specifically implemented for iidx to solve the threading issue, can also be removed now. Unfortunately, this also caused performance issues such as stuttering due to it’s rather simplistic implementation.
This commit is contained in:
icex2
2024-08-15 11:34:31 +02:00
parent 57e68f928a
commit e61dfb3977
48 changed files with 693 additions and 1055 deletions
-2
View File
@@ -6,8 +6,6 @@ libs_avs-ext := \
src_avs-ext := \
fs.c \
error.c \
log.c \
property-ext.c \
property-node.c \
property.c \
thread.c \
-27
View File
@@ -1,27 +0,0 @@
#include "api/core/log.h"
#include "avs-ext/log.h"
#include "iface-core/log.h"
#include "imports/avs.h"
static void _avs_ext_log_core_api_get(bt_core_log_api_t *api)
{
log_assert(api);
api->version = 1;
api->v1.misc = log_body_misc;
api->v1.info = log_body_info;
api->v1.warning = log_body_warning;
api->v1.fatal = log_body_fatal;
}
void avs_ext_log_core_api_set()
{
bt_core_log_api_t api;
_avs_ext_log_core_api_get(&api);
bt_core_log_api_set(&api);
}
-8
View File
@@ -1,8 +0,0 @@
#ifndef AVS_EXT_LOG_H
#define AVS_EXT_LOG_H
#include "api/core/log.h"
void avs_ext_log_core_api_set();
#endif
-56
View File
@@ -1,56 +0,0 @@
#include "api/core/thread.h"
#include "api/core/log.h"
#include "avs-ext/thread.h"
#include "iface-core/log.h"
#include "iface-core/thread.h"
#include "imports/avs.h"
static bt_core_thread_result_t _avs_ext_thread_create(
int (*proc)(void *),
void *ctx,
uint32_t stack_sz,
unsigned int priority,
bt_core_thread_id_t *thread_id)
{
*thread_id = avs_thread_create(proc, ctx, stack_sz, priority);
return BT_CORE_THREAD_RESULT_SUCCESS;
}
static bt_core_thread_result_t
_avs_ext_thread_join(bt_core_thread_id_t thread_id, int *result)
{
avs_thread_join(thread_id, result);
return BT_CORE_THREAD_RESULT_SUCCESS;
}
static bt_core_thread_result_t
_avs_ext_thread_destroy(bt_core_thread_id_t thread_id)
{
avs_thread_destroy(thread_id);
return BT_CORE_THREAD_RESULT_SUCCESS;
}
static void _avs_ext_thread_core_api_get(bt_core_thread_api_t *api)
{
log_assert(api);
api->version = 1;
api->v1.create = _avs_ext_thread_create;
api->v1.join = _avs_ext_thread_join;
api->v1.destroy = _avs_ext_thread_destroy;
}
void avs_ext_thread_core_api_set()
{
bt_core_thread_api_t api;
_avs_ext_thread_core_api_get(&api);
bt_core_thread_api_set(&api);
}
-8
View File
@@ -1,8 +0,0 @@
#ifndef AVS_EXT_THREAD_H
#define AVS_EXT_THREAD_H
#include "api/core/thread.h"
void avs_ext_thread_core_api_set();
#endif