Skip to content

Commit

Permalink
remove spalib
Browse files Browse the repository at this point in the history
  • Loading branch information
wtay committed Aug 14, 2018
1 parent d3b9a52 commit 9d36b85
Show file tree
Hide file tree
Showing 49 changed files with 563 additions and 1,159 deletions.
3 changes: 0 additions & 3 deletions pkgconfig/libspa.pc.in
@@ -1,10 +1,7 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@/

Name: libspa
Description: Simple Plugin API
Version: @VERSION@
Libs: -L${libdir} -lspa-lib
Cflags: -I${includedir} -D_REENTRANT
91 changes: 91 additions & 0 deletions spa/include/spa/debug/buffer.h
@@ -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__ */
30 changes: 17 additions & 13 deletions spa/lib/pod.h → spa/include/spa/debug/dict.h
@@ -1,5 +1,5 @@
/* Simple Plugin API
* Copyright (C) 2017 Wim Taymans <wim.taymans@gmail.com>
* 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
Expand All @@ -17,26 +17,30 @@
* Boston, MA 02110-1301, USA.
*/

#ifndef __SPA_LIBPOD_H__
#define __SPA_LIBPOD_H__
#ifndef __SPA_DEBUG_DICT_H__
#define __SPA_DEBUG_DICT_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <spa/param/props.h>
#include <spa/pod/builder.h>
#include <spa/utils/dict.h>

int spa_pod_filter(struct spa_pod_builder *b,
struct spa_pod **result,
const struct spa_pod *pod,
const struct spa_pod *filter);
#ifndef spa_debug
#define spa_debug(...) ({ fprintf(stderr, __VA_ARGS__);fputc('\n', stderr); })
#endif

int spa_pod_compare(const struct spa_pod *pod1,
const struct spa_pod *pod2);
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" */
} /* extern "C" */
#endif

#endif /* __SPA_LIBPOD_H__ */
#endif /* __SPA_DEBUG_DICT_H__ */
34 changes: 20 additions & 14 deletions spa/lib/debug.h → spa/include/spa/debug/format.h
@@ -1,5 +1,5 @@
/* Simple Plugin API
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
* 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
Expand All @@ -17,26 +17,32 @@
* Boston, MA 02110-1301, USA.
*/

#ifndef __SPA_LIBDEBUG_H__
#define __SPA_LIBDEBUG_H__
#ifndef __SPA_DEBUG_FORMAT_H__
#define __SPA_DEBUG_FORMAT_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <spa/node/node.h>
#include <spa/pod/pod.h>
#include <spa/support/type-map.h>
#include <spa/debug/mem.h>
#include <spa/debug/pod.h>

void spa_debug_set_type_map(const struct spa_type_map *map);
#ifndef spa_debug
#define spa_debug(...) ({ fprintf(stderr, __VA_ARGS__);fputc('\n', stderr); })
#endif

int spa_debug_port_info(const struct spa_port_info *info);
int spa_debug_buffer(const struct spa_buffer *buffer);
#define SPA_DEBUG_FLAG_FORMAT (1 << 0)
int spa_debug_pod(const struct spa_pod *pod, uint32_t flags);
int spa_debug_dump_mem(const void *data, size_t size);
int spa_debug_dict(const struct spa_dict *dict);
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" */
} /* extern "C" */
#endif
#endif /* __SPA_LIBDEBUG_H__ */

#endif /* __SPA_DEBUG_FORMAT_H__ */
54 changes: 54 additions & 0 deletions spa/include/spa/debug/mem.h
@@ -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__ */
52 changes: 52 additions & 0 deletions spa/include/spa/debug/node.h
@@ -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__ */

0 comments on commit 9d36b85

Please sign in to comment.