remove spalib

This commit is contained in:
Wim Taymans 2018-08-14 12:33:53 +02:00
parent f532fd8681
commit a6ad8f747f
69 changed files with 612 additions and 1250 deletions

View file

@ -0,0 +1,91 @@
/* Simple Plugin API
* Copyright (C) 2018 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_DEBUG_BUFFER_H__
#define __SPA_DEBUG_BUFFER_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/support/type-map.h>
#include <spa/debug/debug-mem.h>
#ifndef spa_debug
#define spa_debug(...) ({ fprintf(stderr, __VA_ARGS__);fputc('\n', stderr); })
#endif
static inline int spa_debug_buffer(int indent,
struct spa_type_map *map, const struct spa_buffer *buffer)
{
int i;
spa_debug("%*s" "struct spa_buffer %p:", indent, "", buffer);
spa_debug("%*s" " id: %08X", indent, "", buffer->id);
spa_debug("%*s" " n_metas: %u (at %p)", indent, "", buffer->n_metas, buffer->metas);
for (i = 0; i < buffer->n_metas; i++) {
struct spa_meta *m = &buffer->metas[i];
const char *type_name;
type_name = spa_type_map_get_type(map, m->type);
spa_debug("%*s" " meta %d: type %d (%s), data %p, size %d:", indent, "", i, m->type,
type_name, m->data, m->size);
if (!strcmp(type_name, SPA_TYPE_META__Header)) {
struct spa_meta_header *h = m->data;
spa_debug("%*s" " struct spa_meta_header:", indent, "");
spa_debug("%*s" " flags: %08x", indent, "", h->flags);
spa_debug("%*s" " seq: %u", indent, "", h->seq);
spa_debug("%*s" " pts: %" PRIi64, indent, "", h->pts);
spa_debug("%*s" " dts_offset: %" PRIi64, indent, "", h->dts_offset);
} else if (!strcmp(type_name, SPA_TYPE_META__VideoCrop)) {
struct spa_meta_video_crop *h = m->data;
spa_debug("%*s" " struct spa_meta_video_crop:", indent, "");
spa_debug("%*s" " x: %d", indent, "", h->x);
spa_debug("%*s" " y: %d", indent, "", h->y);
spa_debug("%*s" " width: %d", indent, "", h->width);
spa_debug("%*s" " height: %d", indent, "", h->height);
} else {
spa_debug("%*s" " Unknown:", indent, "");
spa_debug_mem(5, m->data, m->size);
}
}
spa_debug("%*s" " n_datas: \t%u (at %p)", indent, "", buffer->n_datas, buffer->datas);
for (i = 0; i < buffer->n_datas; i++) {
struct spa_data *d = &buffer->datas[i];
spa_debug("%*s" " type: %d (%s)", indent, "", d->type,
spa_type_map_get_type(map, d->type));
spa_debug("%*s" " flags: %d", indent, "", d->flags);
spa_debug("%*s" " data: %p", indent, "", d->data);
spa_debug("%*s" " fd: %d", indent, "", d->fd);
spa_debug("%*s" " offset: %d", indent, "", d->mapoffset);
spa_debug("%*s" " maxsize: %u", indent, "", d->maxsize);
spa_debug("%*s" " chunk: %p", indent, "", d->chunk);
spa_debug("%*s" " offset: %d", indent, "", d->chunk->offset);
spa_debug("%*s" " size: %u", indent, "", d->chunk->size);
spa_debug("%*s" " stride: %d", indent, "", d->chunk->stride);
}
return 0;
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_DEBUG_BUFFER_H__ */

View file

@ -0,0 +1,46 @@
/* Simple Plugin API
* Copyright (C) 2018 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_DEBUG_DICT_H__
#define __SPA_DEBUG_DICT_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/dict.h>
#ifndef spa_debug
#define spa_debug(...) ({ fprintf(stderr, __VA_ARGS__);fputc('\n', stderr); })
#endif
static inline int spa_debug_dict(int indent, const struct spa_dict *dict)
{
const struct spa_dict_item *item;
spa_dict_for_each(item, dict) {
spa_debug("%*s%s = \"%s\"", indent, "", item->key, item->value);
}
return 0;
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_DEBUG_DICT_H__ */

View file

@ -0,0 +1,48 @@
/* Simple Plugin API
* Copyright (C) 2018 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_DEBUG_FORMAT_H__
#define __SPA_DEBUG_FORMAT_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/support/type-map.h>
#include <spa/debug/mem.h>
#include <spa/debug/pod.h>
#ifndef spa_debug
#define spa_debug(...) ({ fprintf(stderr, __VA_ARGS__);fputc('\n', stderr); })
#endif
static inline int spa_debug_format(int indent,
struct spa_type_map *map, const struct spa_pod *pod)
{
return spa_debug_pod_value(indent, map,
SPA_POD_TYPE(pod),
SPA_POD_BODY(pod),
SPA_POD_BODY_SIZE(pod));
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_DEBUG_FORMAT_H__ */

View file

@ -0,0 +1,54 @@
/* Simple Plugin API
* Copyright (C) 2018 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_DEBUG_MEM_H__
#define __SPA_DEBUG_MEM_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/dict.h>
#ifndef spa_debug
#define spa_debug(...) ({ fprintf(stderr, __VA_ARGS__);fputc('\n', stderr); })
#endif
static inline int spa_debug_mem(int indent, const void *data, size_t size)
{
const uint8_t *t = data;
char buffer[512];
int i, pos = 0;
for (i = 0; i < size; i++) {
if (i % 16 == 0)
pos = sprintf(buffer, "%p: ", &t[i]);
pos += sprintf(buffer + pos, "%02x ", t[i]);
if (i % 16 == 15 || i == size - 1) {
spa_debug("%*s" "%s", indent, "", buffer);
}
}
return 0;
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_DEBUG_MEM_H__ */

View file

@ -0,0 +1,52 @@
/* Simple Plugin API
* Copyright (C) 2018 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_DEBUG_NODE_H__
#define __SPA_DEBUG_NODE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/node/node.h>
#include <spa/debug/dict.h>
#ifndef spa_debug
#define spa_debug(...) ({ fprintf(stderr, __VA_ARGS__);fputc('\n', stderr); })
#endif
int spa_debug_port_info(int indent, const struct spa_port_info *info)
{
spa_debug("%*s" "struct spa_port_info %p:", indent, "", info);
spa_debug("%*s" " flags: \t%08x", indent, "", info->flags);
spa_debug("%*s" " rate: \t%u", indent, "", info->rate);
spa_debug("%*s" " props:", indent, "");
if (info->props)
spa_debug_dict(indent + 2, info->props);
else
spa_debug("%*s" " none", indent, "");
return 0;
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_DEBUG_NODE_H__ */

206
spa/include/spa/debug/pod.h Normal file
View file

@ -0,0 +1,206 @@
/* Simple Plugin API
* Copyright (C) 2018 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_DEBUG_POD_H__
#define __SPA_DEBUG_POD_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/support/type-map.h>
#include <spa/debug/mem.h>
#include <spa/pod/pod.h>
#include <spa/pod/iter.h>
#ifndef spa_debug
#define spa_debug(...) ({ fprintf(stderr, __VA_ARGS__);fputc('\n', stderr); })
#endif
static inline int
spa_debug_pod_value(int indent, struct spa_type_map *map,
uint32_t type, void *body, uint32_t size)
{
switch (type) {
case SPA_POD_TYPE_BOOL:
spa_debug("%*s" "Bool %d", indent, "", *(int32_t *) body);
break;
case SPA_POD_TYPE_ID:
spa_debug("%*s" "Id %d %s", indent, "", *(int32_t *) body,
spa_type_map_get_type(map, *(int32_t *) body));
break;
case SPA_POD_TYPE_INT:
spa_debug("%*s" "Int %d", indent, "", *(int32_t *) body);
break;
case SPA_POD_TYPE_LONG:
spa_debug("%*s" "Long %" PRIi64 "", indent, "", *(int64_t *) body);
break;
case SPA_POD_TYPE_FLOAT:
spa_debug("%*s" "Float %f", indent, "", *(float *) body);
break;
case SPA_POD_TYPE_DOUBLE:
spa_debug("%*s" "Double %f", indent, "", *(double *) body);
break;
case SPA_POD_TYPE_STRING:
spa_debug("%*s" "String \"%s\"", indent, "", (char *) body);
break;
case SPA_POD_TYPE_FD:
spa_debug("%*s" "Fd %d", indent, "", *(int *) body);
break;
case SPA_POD_TYPE_POINTER:
{
struct spa_pod_pointer_body *b = body;
spa_debug("%*s" "Pointer %s %p", indent, "",
map ? spa_type_map_get_type(map, b->type) : "*no map*", b->value);
break;
}
case SPA_POD_TYPE_RECTANGLE:
{
struct spa_rectangle *r = body;
spa_debug("%*s" "Rectangle %dx%d", indent, "", r->width, r->height);
break;
}
case SPA_POD_TYPE_FRACTION:
{
struct spa_fraction *f = body;
spa_debug("%*s" "Fraction %d/%d", indent, "", f->num, f->denom);
break;
}
case SPA_POD_TYPE_BITMAP:
spa_debug("%*s" "Bitmap", indent, "");
break;
case SPA_POD_TYPE_ARRAY:
{
struct spa_pod_array_body *b = body;
void *p;
spa_debug("%*s" "Array: child.size %d, child.type %d", indent, "",
b->child.size, b->child.type);
SPA_POD_ARRAY_BODY_FOREACH(b, size, p)
spa_debug_pod_value(indent + 2, map, b->child.type, p, b->child.size);
break;
}
case SPA_POD_TYPE_STRUCT:
{
struct spa_pod *b = body, *p;
spa_debug("%*s" "Struct: size %d", indent, "", size);
SPA_POD_FOREACH(b, size, p)
spa_debug_pod_value(indent + 2, map, p->type, SPA_POD_BODY(p), p->size);
break;
}
case SPA_POD_TYPE_OBJECT:
{
struct spa_pod_object_body *b = body;
struct spa_pod *p;
spa_debug("%*s" "Object: size %d, id %s, type %s", indent, "", size,
map ? spa_type_map_get_type(map, b->id) : "*no map*",
map ? spa_type_map_get_type(map, b->type) : "*no map*");
SPA_POD_OBJECT_BODY_FOREACH(b, size, p)
spa_debug_pod_value(indent + 2, map, p->type, SPA_POD_BODY(p), p->size);
break;
}
case SPA_POD_TYPE_PROP:
{
struct spa_pod_prop_body *b = body;
void *alt;
int i;
spa_debug("%*s" "Prop: key %s, flags %d", indent, "",
map ? spa_type_map_get_type(map, b->key) : "*no map*", b->flags);
if (b->flags & SPA_POD_PROP_FLAG_UNSET)
spa_debug("%*s" "Unset (Default):", indent + 2, "");
else
spa_debug("%*s" "Value: size %u", indent + 2, "", b->value.size);
spa_debug_pod_value(indent + 4, map, b->value.type, SPA_POD_BODY(&b->value),
b->value.size);
i = 0;
switch (b->flags & SPA_POD_PROP_RANGE_MASK) {
case SPA_POD_PROP_RANGE_NONE:
break;
case SPA_POD_PROP_RANGE_MIN_MAX:
SPA_POD_PROP_ALTERNATIVE_FOREACH(b, size, alt) {
if (i == 0)
spa_debug("%*s" "Min: ", indent + 2, "");
else if (i == 1)
spa_debug("%*s" "Max: ", indent + 2, "");
else
break;
spa_debug_pod_value(indent + 4, map, b->value.type, alt, b->value.size);
i++;
}
break;
case SPA_POD_PROP_RANGE_STEP:
SPA_POD_PROP_ALTERNATIVE_FOREACH(b, size, alt) {
if (i == 0)
spa_debug("%*s" "Min: ", indent + 2, "");
else if (i == 1)
spa_debug("%*s" "Max: ", indent + 2, "");
else if (i == 2)
spa_debug("%*s" "Step: ", indent + 2, "");
else
break;
spa_debug_pod_value(indent + 4, map, b->value.type, alt, b->value.size);
i++;
}
break;
case SPA_POD_PROP_RANGE_ENUM:
SPA_POD_PROP_ALTERNATIVE_FOREACH(b, size, alt) {
if (i == 0) {
spa_debug("%*s" "Enum:", indent + 2, "");
}
spa_debug_pod_value(indent + 4, map, b->value.type, alt, b->value.size);
i++;
}
break;
case SPA_POD_PROP_RANGE_FLAGS:
break;
}
break;
}
case SPA_POD_TYPE_BYTES:
spa_debug("%*s" "Bytes", indent, "");
spa_debug_mem(indent + 2, body, size);
break;
case SPA_POD_TYPE_NONE:
spa_debug("%*s" "None", indent, "");
spa_debug_mem(indent + 2, body, size);
break;
default:
spa_debug("%*s" "unhandled POD type %d", indent, "", type);
break;
}
return 0;
}
static inline int spa_debug_pod(int indent,
struct spa_type_map *map, const struct spa_pod *pod)
{
return spa_debug_pod_value(indent, map,
SPA_POD_TYPE(pod),
SPA_POD_BODY(pod),
SPA_POD_BODY_SIZE(pod));
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_DEBUG_POD_H__ */

View file

@ -102,8 +102,10 @@ struct spa_log {
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
#define spa_log_log(l,lev,...) \
({ \
if (SPA_UNLIKELY (spa_log_level_enabled (l, lev))) \
(l)->log((l),lev,__VA_ARGS__)
(l)->log((l),lev,__VA_ARGS__); \
})
#define spa_log_error(l,...) spa_log_log(l,SPA_LOG_LEVEL_ERROR,__FILE__,__LINE__,__func__,__VA_ARGS__)
#define spa_log_warn(l,...) spa_log_log(l,SPA_LOG_LEVEL_WARN,__FILE__,__LINE__,__func__,__VA_ARGS__)