mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-12 13:30:15 -05:00
Debug: remove logger
Make a default logger and mapper in a .h file to be used by examples Remove logger and mapper from libs Make method to set the default mapper for the debug methods
This commit is contained in:
parent
4433203d5f
commit
b4fdcbd322
40 changed files with 508 additions and 494 deletions
81
spa/include/spa/log-impl.h
Normal file
81
spa/include/spa/log-impl.h
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/* Simple Plugin API
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SPA_LOG_IMPL_H__
|
||||
#define __SPA_LOG_IMPL_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <spa/log.h>
|
||||
|
||||
static inline void spa_log_impl_logv(struct spa_log *log,
|
||||
enum spa_log_level level,
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *fmt,
|
||||
va_list args)
|
||||
{
|
||||
char text[512], location[1024];
|
||||
static const char *levels[] = { "-", "E", "W", "I", "D", "T" };
|
||||
|
||||
vsnprintf(text, sizeof(text), fmt, args);
|
||||
snprintf(location, sizeof(location), "[%s][%s:%i %s()] %s\n",
|
||||
levels[level], strrchr(file, '/') + 1, line, func, text);
|
||||
fputs(location, stderr);
|
||||
}
|
||||
static inline void spa_log_impl_log(struct spa_log *log,
|
||||
enum spa_log_level level,
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
spa_log_impl_logv(log, level, file, line, func, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static inline void spa_log_impl_set_loop(struct spa_log *log, struct spa_loop *loop)
|
||||
{
|
||||
}
|
||||
|
||||
#define SPA_LOG_IMPL_DEFINE(name) \
|
||||
struct { \
|
||||
struct spa_log log; \
|
||||
} name
|
||||
|
||||
#define SPA_LOG_IMPL_INIT \
|
||||
{ { sizeof(struct spa_log), \
|
||||
NULL, \
|
||||
SPA_LOG_LEVEL_INFO, \
|
||||
spa_log_impl_log, \
|
||||
spa_log_impl_logv, \
|
||||
spa_log_impl_set_loop,} }
|
||||
|
||||
#define SPA_LOG_IMPL(name) \
|
||||
SPA_LOG_IMPL_DEFINE(name) = SPA_LOG_IMPL_INIT
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
#endif /* __SPA_LOG_IMPL_H__ */
|
||||
|
|
@ -31,6 +31,7 @@ extern "C" {
|
|||
|
||||
#include <spa/defs.h>
|
||||
#include <spa/plugin.h>
|
||||
#include <spa/loop.h>
|
||||
|
||||
enum spa_log_level {
|
||||
SPA_LOG_LEVEL_NONE = 0,
|
||||
|
|
@ -102,8 +103,21 @@ struct spa_log {
|
|||
const char *func,
|
||||
const char *fmt,
|
||||
va_list args) SPA_PRINTF_FUNC(6, 0);
|
||||
/**
|
||||
* Set the loop for trace logging
|
||||
* \param log the logger
|
||||
* \param loop the loop for trace logging
|
||||
*
|
||||
* Trace logging will be done to a ringbuffer and written to
|
||||
* the console/device from \a loop to ensure no blocking operations
|
||||
* are done from the realtime thread.
|
||||
*/
|
||||
void (*set_loop) (struct spa_log *log,
|
||||
struct spa_loop *loop);
|
||||
};
|
||||
|
||||
#define spa_log_set_loop(l,...) (l)->set_loop((l),__VA_ARGS__)
|
||||
|
||||
#define spa_log_level_enabled(l,lev) ((l) && (l)->level >= (lev))
|
||||
|
||||
#if __STDC_VERSION__ >= 199901L
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ struct spa_port_info {
|
|||
|
||||
|
||||
struct spa_node_callbacks {
|
||||
/**
|
||||
/**
|
||||
* struct spa_node_callbacks::event:
|
||||
* @node: a #struct spa_node
|
||||
* @event: the event that was emited
|
||||
|
|
@ -132,6 +132,8 @@ struct spa_node_callbacks {
|
|||
void (*reuse_buffer) (struct spa_node *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id, void *user_data);
|
||||
|
||||
void (*done) (struct spa_node *node, int seq, int res, void *user_data);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
81
spa/include/spa/type-map-impl.h
Normal file
81
spa/include/spa/type-map-impl.h
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/* Simple Plugin API
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SPA_TYPE_MAP_IMPL_H__
|
||||
#define __SPA_TYPE_MAP_IMPL_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <spa/type-map.h>
|
||||
|
||||
static inline uint32_t
|
||||
spa_type_map_impl_get_id (struct spa_type_map *map, const char *type)
|
||||
{
|
||||
struct { struct spa_type_map map; uint32_t n_types; char *types[1]; } *impl = (void*) map;
|
||||
uint32_t i = 0;
|
||||
|
||||
for (i = 1; i <= impl->n_types; i++) {
|
||||
if (strcmp(impl->types[i], type) == 0)
|
||||
return i;
|
||||
}
|
||||
impl->types[i] = (char *) type;
|
||||
impl->n_types++;
|
||||
return i;
|
||||
}
|
||||
|
||||
static inline const char *
|
||||
spa_type_map_impl_get_type (const struct spa_type_map *map, uint32_t id)
|
||||
{
|
||||
struct { struct spa_type_map map; uint32_t n_types; char *types[1]; } *impl = (void*) map;
|
||||
if (id <= impl->n_types)
|
||||
return impl->types[id];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline size_t spa_type_map_impl_get_size (const struct spa_type_map *map)
|
||||
{
|
||||
struct { struct spa_type_map map; uint32_t n_types; char *types[1]; } *impl = (void*) map;
|
||||
return impl->n_types;
|
||||
}
|
||||
|
||||
#define SPA_TYPE_MAP_IMPL_DEFINE(name,maxtypes) \
|
||||
struct { \
|
||||
struct spa_type_map map; \
|
||||
unsigned int n_types; \
|
||||
char *types[maxtypes]; \
|
||||
} name
|
||||
|
||||
#define SPA_TYPE_MAP_IMPL_INIT \
|
||||
{ { sizeof(struct spa_type_map), \
|
||||
NULL, \
|
||||
spa_type_map_impl_get_id, \
|
||||
spa_type_map_impl_get_type, \
|
||||
spa_type_map_impl_get_size,}, \
|
||||
0, { NULL, } }
|
||||
|
||||
#define SPA_TYPE_MAP_IMPL(name,maxtypes) \
|
||||
SPA_TYPE_MAP_IMPL_DEFINE(name,maxtypes) = SPA_TYPE_MAP_IMPL_INIT
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __SPA_TYPE_MAP_IMPL_H__ */
|
||||
Loading…
Add table
Add a link
Reference in a new issue