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:
Wim Taymans 2017-06-06 13:30:34 +02:00
parent 4433203d5f
commit b4fdcbd322
40 changed files with 508 additions and 494 deletions

View file

@ -1,27 +1,22 @@
executable('test-mixer', 'test-mixer.c',
include_directories : [spa_inc, spa_libinc ],
include_directories : [spa_inc ],
dependencies : [dl_lib, pthread_lib],
link_with : spalib,
install : false)
executable('test-ringbuffer', 'test-ringbuffer.c',
include_directories : [spa_inc, spa_libinc ],
dependencies : [dl_lib, pthread_lib],
link_with : spalib,
install : false)
executable('test-graph', 'test-graph.c',
include_directories : [spa_inc, spa_libinc ],
include_directories : [spa_inc ],
dependencies : [dl_lib, pthread_lib],
link_with : spalib,
install : false)
executable('test-perf', 'test-perf.c',
include_directories : [spa_inc, spa_libinc ],
dependencies : [dl_lib, pthread_lib],
link_with : spalib,
install : false)
executable('stress-ringbuffer', 'stress-ringbuffer.c',
include_directories : [spa_inc, spa_libinc ],
dependencies : [dl_lib, pthread_lib],
link_with : spalib,
install : false)
executable('test-v4l2', 'test-v4l2.c',
include_directories : [spa_inc, spa_libinc ],

View file

@ -28,16 +28,17 @@
#include <spa/node.h>
#include <spa/log.h>
#include <spa/log-impl.h>
#include <spa/loop.h>
#include <spa/type-map.h>
#include <spa/type-map-impl.h>
#include <spa/audio/format-utils.h>
#include <spa/format-utils.h>
#include <spa/format-builder.h>
#include <spa/graph.h>
#include <lib/mapper.h>
#include <lib/debug.h>
#include <lib/props.h>
static SPA_TYPE_MAP_IMPL(default_map, 4096);
static SPA_LOG_IMPL(default_log);
struct type {
uint32_t node;
@ -174,8 +175,7 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
int res;
void *hnd;
spa_handle_factory_enum_func_t enum_func;
unsigned int i;
uint32_t state = 0;
uint32_t i;
if ((hnd = dlopen(lib, RTLD_NOW)) == NULL) {
printf("can't load %s: %s\n", lib, dlerror());
@ -190,7 +190,7 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
const struct spa_handle_factory *factory;
void *iface;
if ((res = enum_func(&factory, state++)) < 0) {
if ((res = enum_func(&factory, i)) < 0) {
if (res != SPA_RESULT_ENUM_END)
printf("can't enumerate factories: %d\n", res);
break;
@ -523,8 +523,8 @@ int main(int argc, char *argv[])
spa_graph_init(&data.graph);
data.map = spa_type_map_get_default();
data.log = spa_log_get_default();
data.map = &default_map.map;
data.log = &default_log.log;
data.data_loop.size = sizeof(struct spa_loop);
data.data_loop.add_source = do_add_source;
data.data_loop.update_source = do_update_source;

View file

@ -28,18 +28,20 @@
#include <spa/node.h>
#include <spa/log.h>
#include <spa/log-impl.h>
#include <spa/loop.h>
#include <spa/graph.h>
#include <spa/type-map.h>
#include <spa/type-map-impl.h>
#include <spa/audio/format-utils.h>
#include <spa/format-utils.h>
#include <spa/format-builder.h>
#include <lib/mapper.h>
#include <lib/debug.h>
#include <lib/props.h>
#undef USE_GRAPH
static SPA_TYPE_MAP_IMPL(default_map, 4096);
static SPA_LOG_IMPL(default_log);
struct type {
uint32_t node;
uint32_t props;
@ -184,8 +186,7 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
int res;
void *hnd;
spa_handle_factory_enum_func_t enum_func;
unsigned int i;
uint32_t state = 0;
uint32_t i;
if ((hnd = dlopen(lib, RTLD_NOW)) == NULL) {
printf("can't load %s: %s\n", lib, dlerror());
@ -200,7 +201,7 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
const struct spa_handle_factory *factory;
void *iface;
if ((res = enum_func(&factory, state++)) < 0) {
if ((res = enum_func(&factory, i)) < 0) {
if (res != SPA_RESULT_ENUM_END)
printf("can't enumerate factories: %d\n", res);
break;
@ -627,8 +628,8 @@ int main(int argc, char *argv[])
int res;
const char *str;
data.map = spa_type_map_get_default();
data.log = spa_log_get_default();
data.map = &default_map.map;
data.log = &default_log.log;
data.data_loop.size = sizeof(struct spa_loop);
data.data_loop.add_source = do_add_source;
data.data_loop.update_source = do_update_source;

View file

@ -27,18 +27,14 @@
#include <poll.h>
#include <spa/node.h>
#include <spa/log.h>
#include <spa/log-impl.h>
#include <spa/loop.h>
#include <spa/type-map.h>
#include <spa/type-map-impl.h>
#include <spa/audio/format-utils.h>
#include <spa/format-utils.h>
#include <spa/format-builder.h>
#include <spa/graph.h>
#include <lib/mapper.h>
#include <lib/debug.h>
#include <lib/props.h>
#define MODE_SYNC_PUSH (1<<0)
#define MODE_SYNC_PULL (1<<1)
#define MODE_ASYNC_PUSH (1<<2)
@ -46,6 +42,9 @@
#define MODE_ASYNC_BOTH (MODE_ASYNC_PUSH|MODE_ASYNC_PULL)
#define MODE_DIRECT (1<<4)
static SPA_TYPE_MAP_IMPL(default_map, 4096);
static SPA_LOG_IMPL(default_log);
struct type {
uint32_t node;
uint32_t props;
@ -174,8 +173,7 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
struct spa_handle *handle;
int res;
spa_handle_factory_enum_func_t enum_func;
unsigned int i;
uint32_t state = 0;
uint32_t i;
if (data->hnd == NULL) {
if ((data->hnd = dlopen(lib, RTLD_NOW)) == NULL) {
@ -192,7 +190,7 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
const struct spa_handle_factory *factory;
void *iface;
if ((res = enum_func(&factory, state++)) < 0) {
if ((res = enum_func(&factory, i)) < 0) {
if (res != SPA_RESULT_ENUM_END)
printf("can't enumerate factories: %d\n", res);
break;
@ -514,8 +512,8 @@ int main(int argc, char *argv[])
spa_graph_init(&data.graph);
data.map = spa_type_map_get_default();
data.log = spa_log_get_default();
data.map = &default_map.map;
data.log = &default_log.log;
data.data_loop.size = sizeof(struct spa_loop);
data.data_loop.add_source = do_add_source;
data.data_loop.update_source = do_update_source;

View file

@ -24,13 +24,14 @@
#include <errno.h>
#include <spa/type-map.h>
#include <spa/type-map-impl.h>
#include <spa/log.h>
#include <spa/node.h>
#include <spa/loop.h>
#include <spa/video/format-utils.h>
#include <spa/format-builder.h>
#include <lib/debug.h>
#include <lib/mapper.h>
#if 0
/* { video/raw,
@ -64,6 +65,8 @@ spa_build(SPA_MEDIA_TYPE_VIDEO, SPA_MEDIA_SUBTYPE_RAW,
SPA_POD_PROP_FLAG_UNSET | SPA_PROP_RANGE_MIN_MAX, 0, 1, INT32_MAX, 1, 0);
#endif
static SPA_TYPE_MAP_IMPL(default_map, 4096);
static struct {
uint32_t format;
struct spa_type_media_type media_type;
@ -142,8 +145,8 @@ static void do_static_struct(struct spa_type_map *map)
}
};
spa_debug_pod(&test_format.fmt.pod, map);
spa_debug_format(&test_format.fmt, map);
spa_debug_pod(&test_format.fmt.pod);
spa_debug_format(&test_format.fmt);
{
uint32_t format = 0, match;
@ -174,9 +177,10 @@ int main(int argc, char *argv[])
struct spa_pod_frame frame[4];
uint8_t buffer[1024];
struct spa_format *fmt;
struct spa_type_map *map = spa_type_map_get_default();
struct spa_type_map *map = &default_map.map;
type_init(map);
spa_debug_set_type_map(map);
spa_pod_builder_init(&b, buffer, sizeof(buffer));
@ -209,7 +213,7 @@ int main(int argc, char *argv[])
spa_pod_builder_pop(&b, &frame[0]);
spa_debug_pod(&fmt->pod, map);
spa_debug_pod(&fmt->pod);
spa_pod_builder_init(&b, buffer, sizeof(buffer));
@ -242,8 +246,8 @@ int main(int argc, char *argv[])
-SPA_POD_TYPE_PROP, &frame[1]);
fmt = SPA_MEMBER(buffer, frame[0].ref, struct spa_format);
spa_debug_pod(&fmt->pod, map);
spa_debug_format(fmt, map);
spa_debug_pod(&fmt->pod);
spa_debug_format(fmt);
spa_pod_builder_init(&b, buffer, sizeof(buffer));
@ -279,8 +283,8 @@ int main(int argc, char *argv[])
0);
fmt = SPA_MEMBER(buffer, frame[0].ref, struct spa_format);
spa_debug_pod(&fmt->pod, map);
spa_debug_format(fmt, map);
spa_debug_pod(&fmt->pod);
spa_debug_format(fmt);
do_static_struct(map);

View file

@ -28,11 +28,13 @@
#include <spa/pod-builder.h>
#include <spa/pod-iter.h>
#include <spa/type-map.h>
#include <spa/log.h>
#include <spa/type-map-impl.h>
#include <spa/log-impl.h>
#include <spa/video/format.h>
#include <lib/debug.h>
#include <lib/mapper.h>
static SPA_TYPE_MAP_IMPL(default_map, 4096);
int main(int argc, char *argv[])
{
@ -41,7 +43,9 @@ int main(int argc, char *argv[])
uint8_t buffer[1024];
struct spa_pod *obj;
struct spa_pod_iter i;
struct spa_type_map *map = spa_type_map_get_default();
struct spa_type_map *map = &default_map.map;
spa_debug_set_type_map(map);
b.data = buffer;
b.size = 1024;
@ -85,11 +89,11 @@ int main(int argc, char *argv[])
spa_pod_builder_pop(&b, &frame[0]);
obj = SPA_POD_BUILDER_DEREF(&b, frame[0].ref, struct spa_pod);
spa_debug_pod(obj, map);
spa_debug_pod(obj);
struct spa_pod_prop *p = spa_pod_object_find_prop((struct spa_pod_object *) obj, 4);
printf("%d %d\n", p->body.key, p->body.flags);
spa_debug_pod(&p->body.value, map);
spa_debug_pod(&p->body.value);
obj = SPA_POD_BUILDER_DEREF(&b, frame[2].ref, struct spa_pod);
@ -115,8 +119,5 @@ int main(int argc, char *argv[])
SPA_POD_ARRAY_BODY_FOREACH(&va->body, SPA_POD_BODY_SIZE(va), pi) {
printf("%d\n", *pi);
}
return 0;
}

View file

@ -27,16 +27,19 @@
#include <poll.h>
#include <spa/node.h>
#include <spa/log.h>
#include <spa/log-impl.h>
#include <spa/loop.h>
#include <spa/type-map.h>
#include <spa/type-map-impl.h>
#include <spa/audio/format-utils.h>
#include <spa/format-utils.h>
#include <spa/format-builder.h>
#include <lib/mapper.h>
#include <lib/debug.h>
#include <lib/props.h>
static SPA_TYPE_MAP_IMPL(default_map, 4096);
static SPA_LOG_IMPL(default_log);
struct type {
uint32_t node;
uint32_t props;
@ -162,8 +165,7 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
int res;
void *hnd;
spa_handle_factory_enum_func_t enum_func;
unsigned int i;
uint32_t state = 0;
uint32_t i;
if ((hnd = dlopen(lib, RTLD_NOW)) == NULL) {
printf("can't load %s: %s\n", lib, dlerror());
@ -178,7 +180,7 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
const struct spa_handle_factory *factory;
void *iface;
if ((res = enum_func(&factory, state++)) < 0) {
if ((res = enum_func(&factory, i)) < 0) {
if (res != SPA_RESULT_ENUM_END)
printf("can't enumerate factories: %d\n", res);
break;
@ -455,8 +457,8 @@ int main(int argc, char *argv[])
int res;
const char *str;
data.map = spa_type_map_get_default();
data.log = spa_log_get_default();
data.map = &default_map.map;
data.log = &default_log.log;
data.data_loop.size = sizeof(struct spa_loop);
data.data_loop.add_source = do_add_source;
data.data_loop.update_source = do_update_source;

View file

@ -28,15 +28,17 @@
#include <SDL2/SDL.h>
#include <spa/type-map.h>
#include <spa/log.h>
#include <spa/type-map-impl.h>
#include <spa/log-impl.h>
#include <spa/node.h>
#include <spa/loop.h>
#include <spa/video/format-utils.h>
#include <spa/format-builder.h>
#include <lib/debug.h>
#include <lib/props.h>
#include <lib/mapper.h>
static SPA_TYPE_MAP_IMPL(default_map, 4096);
static SPA_LOG_IMPL(default_log);
struct type {
uint32_t node;
@ -122,8 +124,7 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
int res;
void *hnd;
spa_handle_factory_enum_func_t enum_func;
unsigned int i;
uint32_t state = 0;
uint32_t i;
if ((hnd = dlopen(lib, RTLD_NOW)) == NULL) {
printf("can't load %s: %s\n", lib, dlerror());
@ -138,7 +139,7 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
const struct spa_handle_factory *factory;
void *iface;
if ((res = enum_func(&factory, state)) < 0) {
if ((res = enum_func(&factory, i)) < 0) {
if (res != SPA_RESULT_ENUM_END)
printf("can't enumerate factories: %d\n", res);
break;
@ -536,8 +537,8 @@ int main(int argc, char *argv[])
data.use_buffer = true;
data.map = spa_type_map_get_default();
data.log = spa_log_get_default();
data.map = &default_map.map;
data.log = &default_log.log;
if ((str = getenv("SPA_DEBUG")))
data.log->level = atoi(str);