log: add loop and mainloop topics

This commit is contained in:
Wim Taymans 2021-10-02 13:54:22 +02:00
parent e1b38e6dd4
commit 5522e9cb1c
3 changed files with 21 additions and 14 deletions

View file

@ -56,6 +56,8 @@ PW_LOG_TOPIC(log_metadata, "pw.metadata");
PW_LOG_TOPIC(log_node, "pw.node"); PW_LOG_TOPIC(log_node, "pw.node");
PW_LOG_TOPIC(log_port, "pw.port"); PW_LOG_TOPIC(log_port, "pw.port");
PW_LOG_TOPIC(log_link, "pw.link"); PW_LOG_TOPIC(log_link, "pw.link");
PW_LOG_TOPIC(log_loop, "pw.loop");
PW_LOG_TOPIC(log_main_loop, "pw.main-loop");
PW_LOG_TOPIC(log_core, "pw.core"); PW_LOG_TOPIC(log_core, "pw.core");
PW_LOG_TOPIC(log_proxy, "pw.proxy"); PW_LOG_TOPIC(log_proxy, "pw.proxy");
PW_LOG_TOPIC(log_global, "pw.global"); PW_LOG_TOPIC(log_global, "pw.global");
@ -430,6 +432,8 @@ pw_log_init(void)
PW_LOG_TOPIC_INIT(log_node); PW_LOG_TOPIC_INIT(log_node);
PW_LOG_TOPIC_INIT(log_port); PW_LOG_TOPIC_INIT(log_port);
PW_LOG_TOPIC_INIT(log_link); PW_LOG_TOPIC_INIT(log_link);
PW_LOG_TOPIC_INIT(log_loop);
PW_LOG_TOPIC_INIT(log_main_loop);
PW_LOG_TOPIC_INIT(log_core); PW_LOG_TOPIC_INIT(log_core);
PW_LOG_TOPIC_INIT(log_proxy); PW_LOG_TOPIC_INIT(log_proxy);
PW_LOG_TOPIC_INIT(log_global); PW_LOG_TOPIC_INIT(log_global);

View file

@ -35,7 +35,9 @@
#define DATAS_SIZE (4096 * 8) #define DATAS_SIZE (4096 * 8)
#define NAME "loop" PW_LOG_TOPIC_EXTERN(log_loop);
#define PW_LOG_TOPIC_DEFAULT log_loop
/** \cond */ /** \cond */
@ -81,14 +83,14 @@ struct pw_loop *pw_loop_new(const struct spa_dict *props)
props, n_support, support); props, n_support, support);
if (impl->system_handle == NULL) { if (impl->system_handle == NULL) {
res = -errno; res = -errno;
pw_log_error(NAME" %p: can't make "SPA_NAME_SUPPORT_SYSTEM" handle: %m", this); pw_log_error("%p: can't make "SPA_NAME_SUPPORT_SYSTEM" handle: %m", this);
goto error_free; goto error_free;
} }
if ((res = spa_handle_get_interface(impl->system_handle, if ((res = spa_handle_get_interface(impl->system_handle,
SPA_TYPE_INTERFACE_System, SPA_TYPE_INTERFACE_System,
&iface)) < 0) { &iface)) < 0) {
pw_log_error(NAME" %p: can't get System interface: %s", this, spa_strerror(res)); pw_log_error("%p: can't get System interface: %s", this, spa_strerror(res));
goto error_unload_system; goto error_unload_system;
} }
this->system = iface; this->system = iface;
@ -105,14 +107,14 @@ struct pw_loop *pw_loop_new(const struct spa_dict *props)
n_support, support); n_support, support);
if (impl->loop_handle == NULL) { if (impl->loop_handle == NULL) {
res = -errno; res = -errno;
pw_log_error(NAME" %p: can't make "SPA_NAME_SUPPORT_LOOP" handle: %m", this); pw_log_error("%p: can't make "SPA_NAME_SUPPORT_LOOP" handle: %m", this);
goto error_unload_system; goto error_unload_system;
} }
if ((res = spa_handle_get_interface(impl->loop_handle, if ((res = spa_handle_get_interface(impl->loop_handle,
SPA_TYPE_INTERFACE_Loop, SPA_TYPE_INTERFACE_Loop,
&iface)) < 0) { &iface)) < 0) {
pw_log_error(NAME" %p: can't get Loop interface: %s", pw_log_error("%p: can't get Loop interface: %s",
this, spa_strerror(res)); this, spa_strerror(res));
goto error_unload_loop; goto error_unload_loop;
} }
@ -121,7 +123,7 @@ struct pw_loop *pw_loop_new(const struct spa_dict *props)
if ((res = spa_handle_get_interface(impl->loop_handle, if ((res = spa_handle_get_interface(impl->loop_handle,
SPA_TYPE_INTERFACE_LoopControl, SPA_TYPE_INTERFACE_LoopControl,
&iface)) < 0) { &iface)) < 0) {
pw_log_error(NAME" %p: can't get LoopControl interface: %s", pw_log_error("%p: can't get LoopControl interface: %s",
this, spa_strerror(res)); this, spa_strerror(res));
goto error_unload_loop; goto error_unload_loop;
} }
@ -130,7 +132,7 @@ struct pw_loop *pw_loop_new(const struct spa_dict *props)
if ((res = spa_handle_get_interface(impl->loop_handle, if ((res = spa_handle_get_interface(impl->loop_handle,
SPA_TYPE_INTERFACE_LoopUtils, SPA_TYPE_INTERFACE_LoopUtils,
&iface)) < 0) { &iface)) < 0) {
pw_log_error(NAME" %p: can't get LoopUtils interface: %s", pw_log_error("%p: can't get LoopUtils interface: %s",
this, spa_strerror(res)); this, spa_strerror(res));
goto error_unload_loop; goto error_unload_loop;
} }

View file

@ -26,12 +26,13 @@
#include "pipewire/main-loop.h" #include "pipewire/main-loop.h"
#include "pipewire/private.h" #include "pipewire/private.h"
#define NAME "main-loop" PW_LOG_TOPIC_EXTERN(log_main_loop);
#define PW_LOG_TOPIC_DEFAULT log_main_loop
static void do_stop(void *data, uint64_t count) static void do_stop(void *data, uint64_t count)
{ {
struct pw_main_loop *this = data; struct pw_main_loop *this = data;
pw_log_debug(NAME" %p: do stop", this); pw_log_debug("%p: do stop", this);
this->running = false; this->running = false;
} }
@ -46,7 +47,7 @@ static struct pw_main_loop *loop_new(struct pw_loop *loop, const struct spa_dict
goto error_cleanup; goto error_cleanup;
} }
pw_log_debug(NAME" %p: new", this); pw_log_debug("%p: new", this);
if (loop == NULL) { if (loop == NULL) {
loop = pw_loop_new(props); loop = pw_loop_new(props);
@ -95,7 +96,7 @@ struct pw_main_loop *pw_main_loop_new(const struct spa_dict *props)
SPA_EXPORT SPA_EXPORT
void pw_main_loop_destroy(struct pw_main_loop *loop) void pw_main_loop_destroy(struct pw_main_loop *loop)
{ {
pw_log_debug(NAME" %p: destroy", loop); pw_log_debug("%p: destroy", loop);
pw_main_loop_emit_destroy(loop); pw_main_loop_emit_destroy(loop);
if (loop->created) if (loop->created)
@ -130,7 +131,7 @@ struct pw_loop * pw_main_loop_get_loop(struct pw_main_loop *loop)
SPA_EXPORT SPA_EXPORT
int pw_main_loop_quit(struct pw_main_loop *loop) int pw_main_loop_quit(struct pw_main_loop *loop)
{ {
pw_log_debug(NAME" %p: quit", loop); pw_log_debug("%p: quit", loop);
return pw_loop_signal_event(loop->loop, loop->event); return pw_loop_signal_event(loop->loop, loop->event);
} }
@ -146,7 +147,7 @@ int pw_main_loop_run(struct pw_main_loop *loop)
{ {
int res = 0; int res = 0;
pw_log_debug(NAME" %p: run", loop); pw_log_debug("%p: run", loop);
loop->running = true; loop->running = true;
pw_loop_enter(loop->loop); pw_loop_enter(loop->loop);
@ -154,7 +155,7 @@ int pw_main_loop_run(struct pw_main_loop *loop)
if ((res = pw_loop_iterate(loop->loop, -1)) < 0) { if ((res = pw_loop_iterate(loop->loop, -1)) < 0) {
if (res == -EINTR) if (res == -EINTR)
continue; continue;
pw_log_warn(NAME" %p: iterate error %d (%s)", pw_log_warn("%p: iterate error %d (%s)",
loop, res, spa_strerror(res)); loop, res, spa_strerror(res));
} }
} }