2020-05-11 15:45:09 +03:00
|
|
|
/* WirePlumber
|
|
|
|
|
*
|
|
|
|
|
* Copyright © 2020 Collabora Ltd.
|
|
|
|
|
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "wp.h"
|
|
|
|
|
#include <pipewire/pipewire.h>
|
2022-05-10 15:10:52 +03:00
|
|
|
#include <libintl.h>
|
2020-05-11 15:45:09 +03:00
|
|
|
|
log: implement a log topics system, like pipewire
The intention is to make checks for enabled log topics faster.
Every topic has its own structure that is statically defined in the file
where the logs are printed from. The structure is initialized transparently
when it is first used and it contains all the log level flags for the levels
that this topic should print messages. It is then checked on the wp_log()
macro before printing the message.
Topics from SPA/PipeWire are also handled natively, so messages are printed
directly without checking if the topic is enabled, since the PipeWire and SPA
macros do the checking themselves.
Messages coming from GLib are checked inside the handler.
An internal WpLogFields object is used to manage the state of each log
message, populating all the fields appropriately from the place they
are coming from (wp_log, spa_log, glib log), formatting the message and
then printing it. For printing to the journald, we still use the glib
message handler, converting all the needed fields to GLogField on demand.
That message handler does not do any checks for the topic or the level, so
we can just call it to send the message.
2023-05-16 11:51:29 +03:00
|
|
|
WP_DEFINE_LOCAL_LOG_TOPIC ("wp")
|
|
|
|
|
|
2021-05-13 17:54:58 +03:00
|
|
|
/*!
|
2021-05-21 18:40:43 +03:00
|
|
|
* \defgroup wp Library Initialization
|
|
|
|
|
* \{
|
2020-05-11 15:45:09 +03:00
|
|
|
*/
|
|
|
|
|
|
2021-05-13 17:54:58 +03:00
|
|
|
/*!
|
2021-06-01 19:39:13 -04:00
|
|
|
* \brief Initializes WirePlumber and PipeWire underneath.
|
2020-05-11 15:45:09 +03:00
|
|
|
*
|
2021-05-21 18:40:43 +03:00
|
|
|
* \em flags can modify which parts are initialized, in cases where you want
|
|
|
|
|
* to handle part of this initialization externally.
|
2021-06-01 19:39:13 -04:00
|
|
|
*
|
|
|
|
|
* \param flags initialization flags
|
2020-05-11 15:45:09 +03:00
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
wp_init (WpInitFlags flags)
|
|
|
|
|
{
|
2021-04-21 13:03:47 +03:00
|
|
|
/* Initialize the logging system */
|
2023-05-17 23:54:49 +03:00
|
|
|
wp_log_init (flags);
|
2020-05-11 17:24:40 +03:00
|
|
|
|
2023-05-17 23:54:49 +03:00
|
|
|
wp_info ("WirePlumber " WIREPLUMBER_VERSION " initializing");
|
2020-05-11 15:45:09 +03:00
|
|
|
|
|
|
|
|
if (flags & WP_INIT_PIPEWIRE)
|
|
|
|
|
pw_init (NULL, NULL);
|
|
|
|
|
|
2021-01-05 08:43:03 -05:00
|
|
|
if (flags & WP_INIT_SPA_TYPES)
|
2021-01-13 20:11:41 +02:00
|
|
|
wp_spa_dynamic_type_init ();
|
2020-05-11 15:45:09 +03:00
|
|
|
|
2022-05-10 15:10:52 +03:00
|
|
|
bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
|
|
|
|
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
|
|
|
|
|
2020-05-11 15:45:09 +03:00
|
|
|
/* ensure WpProxy subclasses are loaded, which is needed to be able
|
|
|
|
|
to autodetect the GType of proxies created through wp_proxy_new_global() */
|
|
|
|
|
g_type_ensure (WP_TYPE_CLIENT);
|
|
|
|
|
g_type_ensure (WP_TYPE_DEVICE);
|
|
|
|
|
g_type_ensure (WP_TYPE_LINK);
|
2020-07-29 19:27:40 +05:30
|
|
|
g_type_ensure (WP_TYPE_METADATA);
|
2020-05-11 15:45:09 +03:00
|
|
|
g_type_ensure (WP_TYPE_NODE);
|
|
|
|
|
g_type_ensure (WP_TYPE_PORT);
|
2021-09-29 17:13:01 +05:30
|
|
|
g_type_ensure (WP_TYPE_FACTORY);
|
2020-05-11 15:45:09 +03:00
|
|
|
}
|
2021-02-01 12:07:39 +02:00
|
|
|
|
2022-07-26 16:02:02 -04:00
|
|
|
/*!
|
|
|
|
|
* \brief Gets the WirePlumber library version
|
|
|
|
|
* \returns WirePlumber library version
|
2023-08-30 11:20:06 +02:00
|
|
|
*
|
|
|
|
|
* \since 0.4.12
|
2022-07-26 16:02:02 -04:00
|
|
|
*/
|
|
|
|
|
const char *
|
|
|
|
|
wp_get_library_version (void)
|
|
|
|
|
{
|
|
|
|
|
return WIREPLUMBER_VERSION;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Gets the WirePlumber library API version
|
|
|
|
|
* \returns WirePlumber library API version
|
2023-08-30 11:20:06 +02:00
|
|
|
*
|
|
|
|
|
* \since 0.4.12
|
2022-07-26 16:02:02 -04:00
|
|
|
*/
|
|
|
|
|
const char *
|
|
|
|
|
wp_get_library_api_version (void)
|
|
|
|
|
{
|
|
|
|
|
return WIREPLUMBER_API_VERSION;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-16 17:03:32 +03:00
|
|
|
/*! \} */
|