mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04: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
|
|
@ -320,7 +320,7 @@ pw_connection_get_next(struct pw_connection *conn,
|
|||
|
||||
if (debug_messages) {
|
||||
printf("<<<<<<<<< in:\n");
|
||||
spa_debug_pod((struct spa_pod *)data, NULL);
|
||||
spa_debug_pod((struct spa_pod *)data);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -374,7 +374,7 @@ pw_connection_end_write(struct pw_connection *conn, uint32_t dest_id, uint8_t op
|
|||
|
||||
if (debug_messages) {
|
||||
printf(">>>>>>>>> out:\n");
|
||||
spa_debug_pod((struct spa_pod *)p, NULL);
|
||||
spa_debug_pod((struct spa_pod *)p);
|
||||
}
|
||||
|
||||
pw_signal_emit(&conn->need_flush, conn);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
#include "pipewire/client/connection.h"
|
||||
#include "pipewire/client/subscribe.h"
|
||||
|
||||
#include <spa/lib/debug.h>
|
||||
|
||||
/** \cond */
|
||||
struct context {
|
||||
struct pw_context this;
|
||||
|
|
@ -436,6 +438,7 @@ struct pw_context *pw_context_new(struct pw_loop *loop,
|
|||
this->properties = properties;
|
||||
|
||||
pw_type_init(&this->type);
|
||||
spa_debug_set_type_map(this->type.map);
|
||||
|
||||
this->loop = loop;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/eventfd.h>
|
||||
|
||||
#include <spa/ringbuffer.h>
|
||||
|
||||
|
|
@ -36,7 +37,8 @@ struct debug_log {
|
|||
struct spa_log log;
|
||||
struct spa_ringbuffer trace_rb;
|
||||
uint8_t trace_data[TRACE_BUFFER];
|
||||
struct spa_source *source;
|
||||
bool have_source;
|
||||
struct spa_source source;
|
||||
};
|
||||
/** \endcond */
|
||||
|
||||
|
|
@ -53,11 +55,11 @@ do_logv(struct spa_log *log,
|
|||
char text[1024], location[1024];
|
||||
static const char *levels[] = { "-", "E", "W", "I", "D", "T", "*T*" };
|
||||
int size;
|
||||
bool do_trace = (level == SPA_LOG_LEVEL_TRACE && l->source);
|
||||
bool do_trace;
|
||||
|
||||
vsnprintf(text, sizeof(text), fmt, args);
|
||||
|
||||
if ((do_trace = (level == SPA_LOG_LEVEL_TRACE && l->source)))
|
||||
if ((do_trace = (level == SPA_LOG_LEVEL_TRACE && l->have_source)))
|
||||
level++;
|
||||
|
||||
size = snprintf(location, sizeof(location), "[%s][%s:%i %s()] %s\n",
|
||||
|
|
@ -72,7 +74,7 @@ do_logv(struct spa_log *log,
|
|||
index & l->trace_rb.mask, location, size);
|
||||
spa_ringbuffer_write_update(&l->trace_rb, index + size);
|
||||
|
||||
write(l->source->fd, &count, sizeof(uint64_t));
|
||||
write(l->source.fd, &count, sizeof(uint64_t));
|
||||
} else
|
||||
fputs(location, stdout);
|
||||
}
|
||||
|
|
@ -91,12 +93,63 @@ do_log(struct spa_log *log,
|
|||
va_end(args);
|
||||
}
|
||||
|
||||
static void on_trace_event(struct spa_source *source)
|
||||
{
|
||||
struct debug_log *l = source->data;
|
||||
int32_t avail;
|
||||
uint32_t index;
|
||||
uint64_t count;
|
||||
|
||||
if (read(source->fd, &count, sizeof(uint64_t)) != sizeof(uint64_t))
|
||||
fprintf(stderr, "failed to read event fd: %s", strerror(errno));
|
||||
|
||||
while ((avail = spa_ringbuffer_get_read_index(&l->trace_rb, &index)) > 0) {
|
||||
uint32_t offset, first;
|
||||
|
||||
if (avail > l->trace_rb.size) {
|
||||
fprintf(stderr, "\n** trace overflow ** %d\n", avail);
|
||||
index += avail - l->trace_rb.size;
|
||||
avail = l->trace_rb.size;
|
||||
}
|
||||
offset = index & l->trace_rb.mask;
|
||||
first = SPA_MIN(avail, l->trace_rb.size - offset);
|
||||
|
||||
fwrite(l->trace_data + offset, first, 1, stderr);
|
||||
if (SPA_UNLIKELY(avail > first)) {
|
||||
fwrite(l->trace_data, avail - first, 1, stderr);
|
||||
}
|
||||
spa_ringbuffer_read_update(&l->trace_rb, index + avail);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
do_set_loop(struct spa_log *log, struct spa_loop *loop)
|
||||
{
|
||||
struct debug_log *l = SPA_CONTAINER_OF(log, struct debug_log, log);
|
||||
|
||||
if (l->have_source) {
|
||||
spa_loop_remove_source(l->source.loop, &l->source);
|
||||
close(l->source.fd);
|
||||
l->have_source = false;
|
||||
}
|
||||
if (loop) {
|
||||
l->source.func = on_trace_event;
|
||||
l->source.data = l;
|
||||
l->source.fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
|
||||
l->source.mask = SPA_IO_IN;
|
||||
l->source.rmask = 0;
|
||||
spa_loop_add_source(loop, &l->source);
|
||||
l->have_source = true;
|
||||
}
|
||||
}
|
||||
|
||||
static struct debug_log log = {
|
||||
{sizeof(struct spa_log),
|
||||
NULL,
|
||||
DEFAULT_LOG_LEVEL,
|
||||
do_log,
|
||||
do_logv,
|
||||
do_set_loop,
|
||||
},
|
||||
{0, 0, TRACE_BUFFER, TRACE_BUFFER - 1},
|
||||
};
|
||||
|
|
@ -120,47 +173,16 @@ void pw_log_set_level(enum spa_log_level level)
|
|||
log.log.level = level;
|
||||
}
|
||||
|
||||
static void on_trace_event(struct spa_source *source)
|
||||
{
|
||||
int32_t avail;
|
||||
uint32_t index;
|
||||
uint64_t count;
|
||||
|
||||
if (read(source->fd, &count, sizeof(uint64_t)) != sizeof(uint64_t))
|
||||
fprintf(stderr, "failed to read event fd: %s", strerror(errno));
|
||||
|
||||
while ((avail = spa_ringbuffer_get_read_index(&log.trace_rb, &index)) > 0) {
|
||||
uint32_t offset, first;
|
||||
|
||||
if (avail > log.trace_rb.size) {
|
||||
fprintf(stderr, "\n** trace overflow ** %d\n", avail);
|
||||
index += avail - log.trace_rb.size;
|
||||
avail = log.trace_rb.size;
|
||||
}
|
||||
offset = index & log.trace_rb.mask;
|
||||
first = SPA_MIN(avail, log.trace_rb.size - offset);
|
||||
|
||||
fwrite(log.trace_data + offset, first, 1, stderr);
|
||||
if (SPA_UNLIKELY(avail > first)) {
|
||||
fwrite(log.trace_data, avail - first, 1, stderr);
|
||||
}
|
||||
spa_ringbuffer_read_update(&log.trace_rb, index + avail);
|
||||
}
|
||||
}
|
||||
|
||||
/** Set the trace notify event
|
||||
* \param source the trace notify event
|
||||
/** Set the trace loop
|
||||
* \param loop the trace loop
|
||||
*
|
||||
* When the trace log has produced new logging in the ringbuffer, this event
|
||||
* will be triggered and will then write the trace log to stderr
|
||||
* Trace logging will be done in this loop.
|
||||
*
|
||||
* \memberof pw_log
|
||||
*/
|
||||
void pw_log_set_trace_event(struct spa_source *source)
|
||||
void pw_log_set_loop(struct spa_loop *loop)
|
||||
{
|
||||
log.source = source;
|
||||
log.source->func = on_trace_event;
|
||||
log.source->data = &log;
|
||||
do_set_loop(&log.log, loop);
|
||||
}
|
||||
|
||||
/** Log a message
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ void
|
|||
pw_log_set_level(enum spa_log_level level);
|
||||
|
||||
void
|
||||
pw_log_set_trace_event(struct spa_source *source);
|
||||
pw_log_set_loop(struct spa_loop *loop);
|
||||
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@
|
|||
#include <string.h>
|
||||
|
||||
#include <spa/type-map.h>
|
||||
#include <spa/lib/mapper.h>
|
||||
|
||||
#include <pipewire/client/map.h>
|
||||
|
||||
|
|
@ -94,6 +93,5 @@ static struct impl default_type_map = {
|
|||
*/
|
||||
struct spa_type_map *pw_type_map_get_default(void)
|
||||
{
|
||||
spa_type_map_set_default(&default_type_map.map);
|
||||
return &default_type_map.map;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,9 +69,9 @@ extern "C" {
|
|||
* The 'PIPEWIRE_DEBUG' environment variable can be used to enable
|
||||
* more debugging. The format is:
|
||||
*
|
||||
* <level>[:<category>,...]
|
||||
* <level>[:<category>,...]
|
||||
*
|
||||
* - <level>: specifies the log level:
|
||||
* - <level>: specifies the log level:
|
||||
* + `0`: no logging is enabled
|
||||
* + `1`: Error logging is enabled
|
||||
* + `2`: Warnings are enabled
|
||||
|
|
@ -80,7 +80,7 @@ extern "C" {
|
|||
* + `5`: Trace messages are enabled. These messages can be logged
|
||||
* from the realtime threads.
|
||||
*
|
||||
* - <category>: Specifies a string category to enable. Many categories
|
||||
* - <category>: Specifies a string category to enable. Many categories
|
||||
* can be separated by commas. Current categories are:
|
||||
* + `connection`: to log connection messages
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -41,13 +41,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
loop = pw_main_loop_new();
|
||||
#if 1
|
||||
{
|
||||
struct spa_source *source;
|
||||
source = pw_loop_add_event(loop->loop, NULL, NULL);
|
||||
pw_log_set_trace_event(source);
|
||||
}
|
||||
#endif
|
||||
pw_log_set_loop(loop->loop->loop);
|
||||
|
||||
core = pw_core_new(loop, NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ on_stream_format_changed(struct pw_listener *listener,
|
|||
return;
|
||||
}
|
||||
|
||||
spa_debug_format(format, data->context->type.map);
|
||||
spa_debug_format(format);
|
||||
|
||||
spa_format_video_raw_parse(format, &data->format, &data->type.format_video);
|
||||
|
||||
|
|
@ -348,7 +348,7 @@ static void on_state_changed(struct pw_listener *listener, struct pw_context *co
|
|||
formats[0] = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_format);
|
||||
|
||||
printf("supported formats:\n");
|
||||
spa_debug_format(formats[0], data->context->type.map);
|
||||
spa_debug_format(formats[0]);
|
||||
|
||||
pw_signal_add(&data->stream->state_changed,
|
||||
&data->on_stream_state_changed, on_stream_state_changed);
|
||||
|
|
@ -382,6 +382,8 @@ int main(int argc, char *argv[])
|
|||
|
||||
init_type(&data.type, data.context->type.map);
|
||||
|
||||
spa_debug_set_type_map(data.context->type.map);
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
printf("can't initialize SDL: %s\n", SDL_GetError());
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ enum
|
|||
};
|
||||
|
||||
static GstDevice *
|
||||
new_node (const struct pw_node_info *info)
|
||||
new_node (GstPipeWireDeviceProvider *self, const struct pw_node_info *info)
|
||||
{
|
||||
GstCaps *caps = NULL;
|
||||
GstStructure *props;
|
||||
|
|
@ -207,7 +207,7 @@ new_node (const struct pw_node_info *info)
|
|||
type = GST_PIPEWIRE_DEVICE_TYPE_SINK;
|
||||
|
||||
for (i = 0; i < info->n_input_formats; i++) {
|
||||
GstCaps *c1 = gst_caps_from_format (info->input_formats[i]);
|
||||
GstCaps *c1 = gst_caps_from_format (info->input_formats[i], self->context->type.map);
|
||||
if (c1)
|
||||
gst_caps_append (caps, c1);
|
||||
}
|
||||
|
|
@ -215,7 +215,7 @@ new_node (const struct pw_node_info *info)
|
|||
else if (info->max_output_ports > 0 && info->max_input_ports == 0) {
|
||||
type = GST_PIPEWIRE_DEVICE_TYPE_SOURCE;
|
||||
for (i = 0; i < info->n_output_formats; i++) {
|
||||
GstCaps *c1 = gst_caps_from_format (info->output_formats[i]);
|
||||
GstCaps *c1 = gst_caps_from_format (info->output_formats[i], self->context->type.map);
|
||||
if (c1)
|
||||
gst_caps_append (caps, c1);
|
||||
}
|
||||
|
|
@ -251,7 +251,7 @@ get_node_info_cb (struct pw_context *context,
|
|||
|
||||
if (info) {
|
||||
GstDevice *dev;
|
||||
dev = new_node (info);
|
||||
dev = new_node (self, info);
|
||||
if (dev)
|
||||
gst_device_provider_device_add (GST_DEVICE_PROVIDER (self), dev);
|
||||
}
|
||||
|
|
@ -310,6 +310,7 @@ on_context_subscription (struct pw_listener *listener,
|
|||
}
|
||||
|
||||
typedef struct {
|
||||
GstPipeWireDeviceProvider *self;
|
||||
gboolean end;
|
||||
GList **devices;
|
||||
} InfoData;
|
||||
|
|
@ -322,7 +323,7 @@ list_node_info_cb (struct pw_context *c,
|
|||
{
|
||||
InfoData *data = user_data;
|
||||
if (info) {
|
||||
*data->devices = g_list_prepend (*data->devices, gst_object_ref_sink (new_node (info)));
|
||||
*data->devices = g_list_prepend (*data->devices, gst_object_ref_sink (new_node (data->self, info)));
|
||||
} else {
|
||||
data->end = TRUE;
|
||||
}
|
||||
|
|
@ -398,6 +399,7 @@ gst_pipewire_device_provider_probe (GstDeviceProvider * provider)
|
|||
self);
|
||||
|
||||
|
||||
data.self = self;
|
||||
data.end = FALSE;
|
||||
data.devices = NULL;
|
||||
pw_context_list_node_info (c,
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
#include <gst/video/video.h>
|
||||
#include <gst/audio/audio.h>
|
||||
|
||||
#include <spa/lib/mapper.h>
|
||||
#include <spa/format-builder.h>
|
||||
#include <spa/video/format-utils.h>
|
||||
#include <spa/audio/format-utils.h>
|
||||
|
|
@ -51,9 +50,9 @@ static struct {
|
|||
} type = { NULL, };
|
||||
|
||||
static void
|
||||
ensure_types (void)
|
||||
ensure_types (struct spa_type_map *map)
|
||||
{
|
||||
struct spa_type_map *map = type.map = spa_type_map_get_default ();
|
||||
type.map = map;
|
||||
|
||||
type.format = spa_type_map_get_id (map, SPA_TYPE__Format);
|
||||
spa_type_media_type_map (map, &type.media_type);
|
||||
|
|
@ -573,7 +572,7 @@ convert_1 (GstCapsFeatures *cf, GstStructure *cs)
|
|||
}
|
||||
|
||||
struct spa_format *
|
||||
gst_caps_to_format (GstCaps *caps, guint index)
|
||||
gst_caps_to_format (GstCaps *caps, guint index, struct spa_type_map *map)
|
||||
{
|
||||
GstCapsFeatures *f;
|
||||
GstStructure *s;
|
||||
|
|
@ -582,7 +581,7 @@ gst_caps_to_format (GstCaps *caps, guint index)
|
|||
g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
|
||||
g_return_val_if_fail (gst_caps_is_fixed (caps), NULL);
|
||||
|
||||
ensure_types();
|
||||
ensure_types(map);
|
||||
|
||||
f = gst_caps_get_features (caps, index);
|
||||
s = gst_caps_get_structure (caps, index);
|
||||
|
|
@ -607,11 +606,11 @@ foreach_func (GstCapsFeatures *features,
|
|||
|
||||
|
||||
GPtrArray *
|
||||
gst_caps_to_format_all (GstCaps *caps)
|
||||
gst_caps_to_format_all (GstCaps *caps, struct spa_type_map *map)
|
||||
{
|
||||
GPtrArray *res;
|
||||
|
||||
ensure_types();
|
||||
ensure_types(map);
|
||||
|
||||
res = g_ptr_array_new_full (gst_caps_get_size (caps), (GDestroyNotify)g_free);
|
||||
gst_caps_foreach (caps, (GstCapsForeachFunc) foreach_func, res);
|
||||
|
|
@ -795,13 +794,13 @@ handle_fraction_prop (struct spa_pod_prop *prop, const char *key, GstCaps *res)
|
|||
}
|
||||
}
|
||||
GstCaps *
|
||||
gst_caps_from_format (const struct spa_format *format)
|
||||
gst_caps_from_format (const struct spa_format *format, struct spa_type_map *map)
|
||||
{
|
||||
GstCaps *res = NULL;
|
||||
uint32_t media_type, media_subtype;
|
||||
struct spa_pod_prop *prop;
|
||||
|
||||
ensure_types();
|
||||
ensure_types(map);
|
||||
|
||||
media_type = SPA_FORMAT_MEDIA_TYPE (format);
|
||||
media_subtype = SPA_FORMAT_MEDIA_SUBTYPE (format);
|
||||
|
|
|
|||
|
|
@ -22,14 +22,15 @@
|
|||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include <spa/include/spa/type-map.h>
|
||||
#include <spa/include/spa/format.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
struct spa_format * gst_caps_to_format (GstCaps *caps, guint index);
|
||||
GPtrArray * gst_caps_to_format_all (GstCaps *caps);
|
||||
struct spa_format * gst_caps_to_format (GstCaps *caps, guint index, struct spa_type_map *map);
|
||||
GPtrArray * gst_caps_to_format_all (GstCaps *caps, struct spa_type_map *map);
|
||||
|
||||
GstCaps * gst_caps_from_format (const struct spa_format *format);
|
||||
GstCaps * gst_caps_from_format (const struct spa_format *format, struct spa_type_map *map);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -623,7 +623,7 @@ gst_pipewire_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
|
|||
|
||||
pwsink = GST_PIPEWIRE_SINK (bsink);
|
||||
|
||||
possible = gst_caps_to_format_all (caps);
|
||||
possible = gst_caps_to_format_all (caps, pwsink->ctx->type.map);
|
||||
|
||||
pw_thread_loop_lock (pwsink->main_loop);
|
||||
state = pwsink->stream->state;
|
||||
|
|
|
|||
|
|
@ -684,7 +684,7 @@ gst_pipewire_src_negotiate (GstBaseSrc * basesrc)
|
|||
GST_DEBUG_OBJECT (basesrc, "have common caps: %" GST_PTR_FORMAT, caps);
|
||||
|
||||
/* open a connection with these caps */
|
||||
possible = gst_caps_to_format_all (caps);
|
||||
possible = gst_caps_to_format_all (caps, pwsrc->ctx->type.map);
|
||||
|
||||
/* first disconnect */
|
||||
pw_thread_loop_lock (pwsrc->main_loop);
|
||||
|
|
@ -794,7 +794,7 @@ on_format_changed (struct pw_listener *listener,
|
|||
return;
|
||||
}
|
||||
|
||||
caps = gst_caps_from_format (format);
|
||||
caps = gst_caps_from_format (format, pwsrc->ctx->type.map);
|
||||
GST_DEBUG_OBJECT (pwsrc, "we got format %" GST_PTR_FORMAT, caps);
|
||||
res = gst_base_src_set_caps (GST_BASE_SRC (pwsrc), caps);
|
||||
gst_caps_unref (caps);
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ struct pw_spa_node *pw_spa_node_load(struct pw_core *core,
|
|||
goto init_failed;
|
||||
}
|
||||
if ((res = spa_handle_get_interface(handle, core->type.spa_node, &iface)) < 0) {
|
||||
pw_log_error("can't get interface %d", res);
|
||||
pw_log_error("can't get node interface %d", res);
|
||||
goto interface_failed;
|
||||
}
|
||||
spa_node = iface;
|
||||
|
|
|
|||
|
|
@ -361,6 +361,8 @@ struct pw_core *pw_core_new(struct pw_main_loop *main_loop, struct pw_properties
|
|||
pw_type_init(&this->type);
|
||||
pw_map_init(&this->objects, 128, 32);
|
||||
|
||||
spa_debug_set_type_map(this->type.map);
|
||||
|
||||
impl->support[0].type = SPA_TYPE__TypeMap;
|
||||
impl->support[0].data = this->type.map;
|
||||
impl->support[1].type = SPA_TYPE__Log;
|
||||
|
|
@ -719,7 +721,7 @@ struct spa_format *pw_core_find_format(struct pw_core *core,
|
|||
}
|
||||
pw_log_debug("Try filter: %p", filter);
|
||||
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
||||
spa_debug_format(filter, core->type.map);
|
||||
spa_debug_format(filter);
|
||||
|
||||
if ((res = spa_node_port_enum_formats(output->node->node,
|
||||
SPA_DIRECTION_OUTPUT,
|
||||
|
|
@ -735,7 +737,7 @@ struct spa_format *pw_core_find_format(struct pw_core *core,
|
|||
}
|
||||
pw_log_debug("Got filtered:");
|
||||
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
||||
spa_debug_format(format, core->type.map);
|
||||
spa_debug_format(format);
|
||||
|
||||
spa_format_fixate(format);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ struct pw_global;
|
|||
*
|
||||
* \subpage page_core
|
||||
*
|
||||
* \subpage page_registry
|
||||
*
|
||||
* \subpage page_global
|
||||
*
|
||||
* \subpage page_client
|
||||
|
|
@ -56,7 +58,31 @@ struct pw_global;
|
|||
*
|
||||
* The core object is a singleton object that manages the state and
|
||||
* resources of the PipeWire server.
|
||||
*/
|
||||
/** \page page_registry Registry
|
||||
*
|
||||
* \section page_registry_overview Overview
|
||||
*
|
||||
* The registry object is a singleton object that keeps track of
|
||||
* global objects on the PipeWire server. See also \ref page_global.
|
||||
*
|
||||
* Global objects typically represent an actual object in the
|
||||
* server (for example, a module or node) or they are singleton
|
||||
* objects such as the core.
|
||||
*
|
||||
* When a client creates a registry object, the registry object
|
||||
* will emit a global event for each global currently in the
|
||||
* registry. Globals come and go as a result of device hotplugs or
|
||||
* reconfiguration or other events, and the registry will send out
|
||||
* global and global_remove events to keep the client up to date
|
||||
* with the changes. To mark the end of the initial burst of
|
||||
* events, the client can use the pw_core.sync methosd immediately
|
||||
* after calling pw_core.get_registry.
|
||||
*
|
||||
* A client can bind to a global object by using the bind
|
||||
* request. This creates a client-side proxy that lets the object
|
||||
* emit events to the client and lets the client invoke methods on
|
||||
* the object.
|
||||
*/
|
||||
typedef int (*pw_bind_func_t) (struct pw_global *global,
|
||||
struct pw_client *client, uint32_t version, uint32_t id);
|
||||
|
|
@ -65,7 +91,14 @@ typedef int (*pw_bind_func_t) (struct pw_global *global,
|
|||
*
|
||||
* Global objects represent resources that are available on the server and
|
||||
* accessible to clients.
|
||||
* Globals come and go when devices or other resources become available for
|
||||
* clients.
|
||||
*
|
||||
* The client receives a list of globals when it binds to the registry
|
||||
* object. See \ref page_registry.
|
||||
*
|
||||
* A client can bind to a global to send methods or receive events from
|
||||
* the global.
|
||||
*/
|
||||
/** \class pw_global
|
||||
*
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ static int do_negotiate(struct pw_link *this, uint32_t in_state, uint32_t out_st
|
|||
|
||||
pw_log_debug("link %p: doing set format", this);
|
||||
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
||||
spa_debug_format(format, this->core->type.map);
|
||||
spa_debug_format(format);
|
||||
|
||||
if (out_state == PW_PORT_STATE_CONFIGURE) {
|
||||
pw_log_debug("link %p: doing set format on output", this);
|
||||
|
|
@ -348,7 +348,7 @@ spa_node_param_filter(struct pw_link *this,
|
|||
break;
|
||||
|
||||
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
||||
spa_debug_param(iparam, this->core->type.map);
|
||||
spa_debug_param(iparam);
|
||||
|
||||
for (oidx = 0;; oidx++) {
|
||||
struct spa_pod_frame f;
|
||||
|
|
@ -359,7 +359,7 @@ spa_node_param_filter(struct pw_link *this,
|
|||
break;
|
||||
|
||||
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
||||
spa_debug_param(oparam, this->core->type.map);
|
||||
spa_debug_param(oparam);
|
||||
|
||||
if (iparam->object.body.type != oparam->object.body.type)
|
||||
continue;
|
||||
|
|
@ -454,8 +454,8 @@ static int do_allocation(struct pw_link *this, uint32_t in_state, uint32_t out_s
|
|||
}
|
||||
|
||||
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) {
|
||||
spa_debug_port_info(oinfo, this->core->type.map);
|
||||
spa_debug_port_info(iinfo, this->core->type.map);
|
||||
spa_debug_port_info(oinfo);
|
||||
spa_debug_port_info(iinfo);
|
||||
}
|
||||
|
||||
if (impl->buffers == NULL) {
|
||||
|
|
@ -476,7 +476,7 @@ static int do_allocation(struct pw_link *this, uint32_t in_state, uint32_t out_s
|
|||
for (i = 0, offset = 0; i < n_params; i++) {
|
||||
params[i] = SPA_MEMBER(buffer, offset, struct spa_param);
|
||||
spa_param_fixate(params[i]);
|
||||
spa_debug_param(params[i], this->core->type.map);
|
||||
spa_debug_param(params[i]);
|
||||
offset += SPA_ROUND_UP_N(SPA_POD_SIZE(params[i]), 8);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -107,12 +107,12 @@ dump_node_info(struct pw_context *c, int res, const struct pw_node_info *info, v
|
|||
printf("%c\tinput ports: %u/%u\n", MARK_CHANGE(1), info->n_input_ports, info->max_input_ports);
|
||||
printf("%c\tinput formats:\n", MARK_CHANGE(2));
|
||||
for (i = 0; i < info->n_input_formats; i++)
|
||||
spa_debug_format(info->input_formats[i], c->type.map);
|
||||
spa_debug_format(info->input_formats[i]);
|
||||
|
||||
printf("%c\toutput ports: %u/%u\n", MARK_CHANGE(3), info->n_output_ports, info->max_output_ports);
|
||||
printf("%c\toutput formats:\n", MARK_CHANGE(4));
|
||||
for (i = 0; i < info->n_output_formats; i++)
|
||||
spa_debug_format(info->output_formats[i], c->type.map);
|
||||
spa_debug_format(info->output_formats[i]);
|
||||
|
||||
printf("%c\tstate: \"%s\"", MARK_CHANGE(5), pw_node_state_as_string(info->state));
|
||||
if (info->state == PW_NODE_STATE_ERROR && info->error)
|
||||
|
|
@ -164,7 +164,7 @@ dump_link_info(struct pw_context *c, int res, const struct pw_link_info *info, v
|
|||
printf("%c\tinput-port-id: %u\n", MARK_CHANGE(3), info->input_port_id);
|
||||
printf("%c\tformat:\n", MARK_CHANGE(4));
|
||||
if (info->format)
|
||||
spa_debug_format(info->format, c->type.map);
|
||||
spa_debug_format(info->format);
|
||||
else
|
||||
printf("\t none\n");
|
||||
}
|
||||
|
|
|
|||
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__ */
|
||||
205
spa/lib/debug.c
205
spa/lib/debug.c
|
|
@ -20,13 +20,21 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/eventfd.h>
|
||||
|
||||
#include <lib/mapper.h>
|
||||
#include <spa/format-utils.h>
|
||||
#include <spa/loop.h>
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
int spa_debug_port_info(const struct spa_port_info *info, const struct spa_type_map *map)
|
||||
static const struct spa_type_map *map;
|
||||
|
||||
void spa_debug_set_type_map(const struct spa_type_map *m)
|
||||
{
|
||||
map = m;
|
||||
}
|
||||
|
||||
int spa_debug_port_info(const struct spa_port_info *info)
|
||||
{
|
||||
if (info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -37,7 +45,7 @@ int spa_debug_port_info(const struct spa_port_info *info, const struct spa_type_
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
int spa_debug_buffer(const struct spa_buffer *buffer, const struct spa_type_map *map)
|
||||
int spa_debug_buffer(const struct spa_buffer *buffer)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -130,45 +138,42 @@ int spa_debug_dump_mem(const void *mem, size_t size)
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
int spa_debug_props(const struct spa_props *props, const struct spa_type_map *map)
|
||||
int spa_debug_props(const struct spa_props *props)
|
||||
{
|
||||
spa_debug_pod(&props->object.pod, map);
|
||||
spa_debug_pod(&props->object.pod);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
int spa_debug_param(const struct spa_param *param, const struct spa_type_map *map)
|
||||
int spa_debug_param(const struct spa_param *param)
|
||||
{
|
||||
spa_debug_pod(¶m->object.pod, map);
|
||||
spa_debug_pod(¶m->object.pod);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
struct pod_type_name {
|
||||
const char *name;
|
||||
const char *CCName;
|
||||
} pod_type_names[] = {
|
||||
{ "invalid", "*Invalid*"},
|
||||
{ "none", "None"},
|
||||
{ "bool", "Bool"},
|
||||
{ "id", "Id"},
|
||||
{ "int", "Int"},
|
||||
{ "long", "Long"},
|
||||
{ "float", "Float"},
|
||||
{ "double", "Double"},
|
||||
{ "string", "String"},
|
||||
{ "bytes", "Bytes"},
|
||||
{ "pointer", "Pointer"},
|
||||
{ "rectangle", "Rectangle"},
|
||||
{ "fraction", "Fraction"},
|
||||
{ "bitmask", "Bitmask"},
|
||||
{ "array", "Array"},
|
||||
{ "struct", "Struct"},
|
||||
{ "object", "Object"},
|
||||
{ "prop", "Prop"},
|
||||
static const char *pod_type_names[] = {
|
||||
"invalid",
|
||||
"none",
|
||||
"bool",
|
||||
"id",
|
||||
"int",
|
||||
"long",
|
||||
"float",
|
||||
"double",
|
||||
"string",
|
||||
"bytes",
|
||||
"pointer",
|
||||
"rectangle",
|
||||
"fraction",
|
||||
"bitmask",
|
||||
"array",
|
||||
"struct",
|
||||
"object",
|
||||
"prop",
|
||||
"pod"
|
||||
};
|
||||
|
||||
static void
|
||||
print_pod_value(const struct spa_type_map *map, uint32_t size, uint32_t type, void *body,
|
||||
int prefix)
|
||||
print_pod_value(uint32_t size, uint32_t type, void *body, int prefix)
|
||||
{
|
||||
switch (type) {
|
||||
case SPA_POD_TYPE_BOOL:
|
||||
|
|
@ -223,7 +228,7 @@ print_pod_value(const struct spa_type_map *map, uint32_t size, uint32_t type, vo
|
|||
b->child.size, b->child.type);
|
||||
|
||||
SPA_POD_ARRAY_BODY_FOREACH(b, size, p)
|
||||
print_pod_value(map, b->child.size, b->child.type, p, prefix + 2);
|
||||
print_pod_value(b->child.size, b->child.type, p, prefix + 2);
|
||||
break;
|
||||
}
|
||||
case SPA_POD_TYPE_STRUCT:
|
||||
|
|
@ -231,7 +236,7 @@ print_pod_value(const struct spa_type_map *map, uint32_t size, uint32_t type, vo
|
|||
struct spa_pod *b = body, *p;
|
||||
printf("%-*sStruct: size %d\n", prefix, "", size);
|
||||
SPA_POD_FOREACH(b, size, p)
|
||||
print_pod_value(map, p->size, p->type, SPA_POD_BODY(p), prefix + 2);
|
||||
print_pod_value(p->size, p->type, SPA_POD_BODY(p), prefix + 2);
|
||||
break;
|
||||
}
|
||||
case SPA_POD_TYPE_OBJECT:
|
||||
|
|
@ -242,7 +247,7 @@ print_pod_value(const struct spa_type_map *map, uint32_t size, uint32_t type, vo
|
|||
printf("%-*sObject: size %d, id %d, type %s\n", prefix, "", size, b->id,
|
||||
spa_type_map_get_type(map, b->type));
|
||||
SPA_POD_OBJECT_BODY_FOREACH(b, size, p)
|
||||
print_pod_value(map, p->size, p->type, SPA_POD_BODY(p), prefix + 2);
|
||||
print_pod_value(p->size, p->type, SPA_POD_BODY(p), prefix + 2);
|
||||
break;
|
||||
}
|
||||
case SPA_POD_TYPE_PROP:
|
||||
|
|
@ -257,14 +262,14 @@ print_pod_value(const struct spa_type_map *map, uint32_t size, uint32_t type, vo
|
|||
printf("%-*sUnset (Default):\n", prefix + 2, "");
|
||||
else
|
||||
printf("%-*sValue: size %u\n", prefix + 2, "", b->value.size);
|
||||
print_pod_value(map, b->value.size, b->value.type, SPA_POD_BODY(&b->value),
|
||||
print_pod_value(b->value.size, b->value.type, SPA_POD_BODY(&b->value),
|
||||
prefix + 4);
|
||||
|
||||
i = 0;
|
||||
SPA_POD_PROP_ALTERNATIVE_FOREACH(b, size, alt) {
|
||||
if (i == 0)
|
||||
printf("%-*sAlternatives:\n", prefix + 2, "");
|
||||
print_pod_value(map, b->value.size, b->value.type, alt, prefix + 4);
|
||||
print_pod_value(b->value.size, b->value.type, alt, prefix + 4);
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
|
|
@ -283,15 +288,14 @@ print_pod_value(const struct spa_type_map *map, uint32_t size, uint32_t type, vo
|
|||
}
|
||||
}
|
||||
|
||||
int spa_debug_pod(const struct spa_pod *pod, const struct spa_type_map *map)
|
||||
int spa_debug_pod(const struct spa_pod *pod)
|
||||
{
|
||||
map = map ? map : spa_type_map_get_default();
|
||||
print_pod_value(map, pod->size, pod->type, SPA_POD_BODY(pod), 0);
|
||||
print_pod_value(pod->size, pod->type, SPA_POD_BODY(pod), 0);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
print_format_value(const struct spa_type_map *map, uint32_t size, uint32_t type, void *body)
|
||||
print_format_value(uint32_t size, uint32_t type, void *body)
|
||||
{
|
||||
switch (type) {
|
||||
case SPA_POD_TYPE_BOOL:
|
||||
|
|
@ -348,7 +352,7 @@ print_format_value(const struct spa_type_map *map, uint32_t size, uint32_t type,
|
|||
}
|
||||
}
|
||||
|
||||
int spa_debug_format(const struct spa_format *format, const struct spa_type_map *map)
|
||||
int spa_debug_format(const struct spa_format *format)
|
||||
{
|
||||
int i;
|
||||
const char *media_type;
|
||||
|
|
@ -359,8 +363,6 @@ int spa_debug_format(const struct spa_format *format, const struct spa_type_map
|
|||
if (format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
map = map ? map : spa_type_map_get_default();
|
||||
|
||||
mtype = format->body.media_type.value;
|
||||
mstype = format->body.media_subtype.value;
|
||||
|
||||
|
|
@ -380,10 +382,10 @@ int spa_debug_format(const struct spa_format *format, const struct spa_type_map
|
|||
key = spa_type_map_get_type(map, prop->body.key);
|
||||
|
||||
fprintf(stderr, " %20s : (%s) ", rindex(key, ':') + 1,
|
||||
pod_type_names[prop->body.value.type].name);
|
||||
pod_type_names[prop->body.value.type]);
|
||||
|
||||
if (!(prop->body.flags & SPA_POD_PROP_FLAG_UNSET)) {
|
||||
print_format_value(map, prop->body.value.size,
|
||||
print_format_value(prop->body.value.size,
|
||||
prop->body.value.type, SPA_POD_BODY(&prop->body.value));
|
||||
} else {
|
||||
const char *ssep, *esep, *sep;
|
||||
|
|
@ -411,7 +413,7 @@ int spa_debug_format(const struct spa_format *format, const struct spa_type_map
|
|||
SPA_POD_PROP_ALTERNATIVE_FOREACH(&prop->body, prop->pod.size, alt) {
|
||||
if (i > 0)
|
||||
fprintf(stderr, "%s", sep);
|
||||
print_format_value(map, prop->body.value.size,
|
||||
print_format_value(prop->body.value.size,
|
||||
prop->body.value.type, alt);
|
||||
i++;
|
||||
}
|
||||
|
|
@ -435,114 +437,3 @@ int spa_debug_dict(const struct spa_dict *dict)
|
|||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
||||
#define DEFAULT_LOG_LEVEL SPA_LOG_LEVEL_INFO
|
||||
|
||||
#define TRACE_BUFFER 4096
|
||||
|
||||
struct debug_log {
|
||||
struct spa_log log;
|
||||
struct spa_ringbuffer trace_rb;
|
||||
uint8_t trace_data[TRACE_BUFFER];
|
||||
struct spa_source *source;
|
||||
};
|
||||
|
||||
static void
|
||||
do_logv(struct spa_log *log,
|
||||
enum spa_log_level level,
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *fmt,
|
||||
va_list args)
|
||||
{
|
||||
struct debug_log *l = SPA_CONTAINER_OF(log, struct debug_log, log);
|
||||
char text[512], location[1024];
|
||||
static const char *levels[] = { "-", "E", "W", "I", "D", "T", "*T*" };
|
||||
int size;
|
||||
bool do_trace;
|
||||
|
||||
if ((do_trace = (level == SPA_LOG_LEVEL_TRACE && l->source)))
|
||||
level++;
|
||||
|
||||
vsnprintf(text, sizeof(text), fmt, args);
|
||||
size = snprintf(location, sizeof(location), "[%s][%s:%i %s()] %s\n",
|
||||
levels[level], strrchr(file, '/') + 1, line, func, text);
|
||||
|
||||
if (SPA_UNLIKELY(do_trace)) {
|
||||
uint32_t index;
|
||||
uint64_t count = 1;
|
||||
|
||||
spa_ringbuffer_get_write_index(&l->trace_rb, &index);
|
||||
spa_ringbuffer_write_data(&l->trace_rb, l->trace_data,
|
||||
index & l->trace_rb.mask, location, size);
|
||||
spa_ringbuffer_write_update(&l->trace_rb, index + size);
|
||||
|
||||
write(l->source->fd, &count, sizeof(uint64_t));
|
||||
} else
|
||||
fputs(location, stderr);
|
||||
}
|
||||
|
||||
static void
|
||||
do_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);
|
||||
do_logv(log, level, file, line, func, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static struct debug_log log = {
|
||||
{sizeof(struct spa_log),
|
||||
NULL,
|
||||
DEFAULT_LOG_LEVEL,
|
||||
do_log,
|
||||
do_logv,
|
||||
},
|
||||
{0, 0, TRACE_BUFFER, TRACE_BUFFER - 1},
|
||||
};
|
||||
|
||||
struct spa_log *spa_log_get_default(void)
|
||||
{
|
||||
return &log.log;
|
||||
}
|
||||
|
||||
static void on_trace_event(struct spa_source *source)
|
||||
{
|
||||
int32_t avail;
|
||||
uint32_t index;
|
||||
uint64_t count;
|
||||
|
||||
if (read(source->fd, &count, sizeof(uint64_t)) != sizeof(uint64_t))
|
||||
fprintf(stderr, "failed to read event fd: %s", strerror(errno));
|
||||
|
||||
while ((avail = spa_ringbuffer_get_read_index(&log.trace_rb, &index)) > 0) {
|
||||
uint32_t offset, first;
|
||||
|
||||
if (avail > log.trace_rb.size) {
|
||||
index += avail - log.trace_rb.size;
|
||||
avail = log.trace_rb.size;
|
||||
}
|
||||
offset = index & log.trace_rb.mask;
|
||||
first = SPA_MIN(avail, log.trace_rb.size - offset);
|
||||
|
||||
fwrite(log.trace_data + offset, first, 1, stderr);
|
||||
if (SPA_UNLIKELY(avail > first)) {
|
||||
fwrite(log.trace_data, avail - first, 1, stderr);
|
||||
}
|
||||
spa_ringbuffer_read_update(&log.trace_rb, index + avail);
|
||||
}
|
||||
}
|
||||
|
||||
void spa_log_default_set_trace_event(struct spa_source *source)
|
||||
{
|
||||
log.source = source;
|
||||
log.source->func = on_trace_event;
|
||||
log.source->data = &log;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,17 +33,17 @@ extern "C" {
|
|||
#include <spa/dict.h>
|
||||
#include <spa/log.h>
|
||||
|
||||
int spa_debug_port_info(const struct spa_port_info *info, const struct spa_type_map *map);
|
||||
int spa_debug_buffer(const struct spa_buffer *buffer, const struct spa_type_map *map);
|
||||
int spa_debug_props(const struct spa_props *props, const struct spa_type_map *map);
|
||||
int spa_debug_param(const struct spa_param *param, const struct spa_type_map *map);
|
||||
int spa_debug_pod(const struct spa_pod *pod, const struct spa_type_map *map);
|
||||
int spa_debug_format(const struct spa_format *format, const struct spa_type_map *map);
|
||||
void spa_debug_set_type_map(const struct spa_type_map *map);
|
||||
|
||||
int spa_debug_port_info(const struct spa_port_info *info);
|
||||
int spa_debug_buffer(const struct spa_buffer *buffer);
|
||||
int spa_debug_props(const struct spa_props *props);
|
||||
int spa_debug_param(const struct spa_param *param);
|
||||
int spa_debug_pod(const struct spa_pod *pod);
|
||||
int spa_debug_format(const struct spa_format *format);
|
||||
int spa_debug_dump_mem(const void *data, size_t size);
|
||||
int spa_debug_dict(const struct spa_dict *dict);
|
||||
|
||||
struct spa_log *spa_log_get_default(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@
|
|||
|
||||
#include <spa/format-builder.h>
|
||||
#include <spa/video/format-utils.h>
|
||||
|
||||
#include <lib/props.h>
|
||||
#include <lib/mapper.h>
|
||||
|
||||
int
|
||||
spa_format_filter(const struct spa_format *format,
|
||||
|
|
|
|||
|
|
@ -1,90 +0,0 @@
|
|||
/* 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.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <spa/type-map.h>
|
||||
|
||||
#include <lib/debug.h>
|
||||
|
||||
#define MAX_TYPES 4096
|
||||
|
||||
struct type_map {
|
||||
struct spa_type_map map;
|
||||
char *types[MAX_TYPES];
|
||||
unsigned int n_types;
|
||||
};
|
||||
|
||||
static uint32_t type_map_get_id(struct spa_type_map *map, const char *type)
|
||||
{
|
||||
struct type_map *this = SPA_CONTAINER_OF(map, struct type_map, map);
|
||||
unsigned int i = 0;
|
||||
|
||||
if (type != NULL) {
|
||||
for (i = 1; i <= this->n_types; i++) {
|
||||
if (strcmp(this->types[i], type) == 0)
|
||||
return i;
|
||||
}
|
||||
this->types[i] = (char *) type;
|
||||
this->n_types++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
static const char *type_map_get_type(const struct spa_type_map *map, uint32_t id)
|
||||
{
|
||||
struct type_map *this = SPA_CONTAINER_OF(map, struct type_map, map);
|
||||
|
||||
if (id <= this->n_types)
|
||||
return this->types[id];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static size_t type_map_get_size(const struct spa_type_map *map)
|
||||
{
|
||||
struct type_map *this = SPA_CONTAINER_OF(map, struct type_map, map);
|
||||
return this->n_types;
|
||||
}
|
||||
|
||||
static struct type_map default_type_map = {
|
||||
{sizeof(struct spa_type_map),
|
||||
NULL,
|
||||
type_map_get_id,
|
||||
type_map_get_type,
|
||||
type_map_get_size,
|
||||
},
|
||||
{NULL,},
|
||||
0
|
||||
};
|
||||
|
||||
static struct spa_type_map *default_map = &default_type_map.map;
|
||||
|
||||
struct spa_type_map *spa_type_map_get_default(void)
|
||||
{
|
||||
return default_map;
|
||||
}
|
||||
|
||||
void spa_type_map_set_default(struct spa_type_map *map)
|
||||
{
|
||||
default_map = map;
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
/* 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_LIBMAPPER_H__
|
||||
#define __SPA_LIBMAPPER_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <spa/type-map.h>
|
||||
|
||||
void spa_type_map_set_default(struct spa_type_map *map);
|
||||
struct spa_type_map *spa_type_map_get_default(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __SPA_LIBMAPPER_H__ */
|
||||
|
|
@ -1,13 +1,11 @@
|
|||
spalib_headers = [
|
||||
'debug.h',
|
||||
'mapper.h',
|
||||
'props.h',
|
||||
]
|
||||
|
||||
install_headers(spalib_headers, subdir : 'spa/lib')
|
||||
|
||||
spalib_sources = ['debug.c',
|
||||
'mapper.c',
|
||||
'props.c',
|
||||
'format.c']
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_INPUT && (p) == 0)
|
||||
|
||||
static const char default_device[] = "default";
|
||||
static const char default_device[] = "hw:0";
|
||||
static const uint32_t default_min_latency = 1024;
|
||||
|
||||
static void reset_props(struct props *props)
|
||||
|
|
|
|||
|
|
@ -59,9 +59,8 @@ struct impl {
|
|||
struct spa_ringbuffer trace_rb;
|
||||
uint8_t trace_data[TRACE_BUFFER];
|
||||
|
||||
struct spa_loop *main_loop;
|
||||
bool have_source;
|
||||
struct spa_source trace_source;
|
||||
struct spa_source source;
|
||||
};
|
||||
|
||||
static void
|
||||
|
|
@ -95,7 +94,7 @@ impl_log_logv(struct spa_log *log,
|
|||
index & impl->trace_rb.mask, location, size);
|
||||
spa_ringbuffer_write_update(&impl->trace_rb, index + size);
|
||||
|
||||
write(impl->trace_source.fd, &count, sizeof(uint64_t));
|
||||
write(impl->source.fd, &count, sizeof(uint64_t));
|
||||
} else
|
||||
fputs(location, stderr);
|
||||
}
|
||||
|
|
@ -115,14 +114,6 @@ impl_log_log(struct spa_log *log,
|
|||
va_end(args);
|
||||
}
|
||||
|
||||
static const struct spa_log impl_log = {
|
||||
sizeof(struct spa_log),
|
||||
NULL,
|
||||
DEFAULT_LOG_LEVEL,
|
||||
impl_log_log,
|
||||
impl_log_logv,
|
||||
};
|
||||
|
||||
static void on_trace_event(struct spa_source *source)
|
||||
{
|
||||
struct impl *impl = source->data;
|
||||
|
|
@ -151,6 +142,35 @@ static void on_trace_event(struct spa_source *source)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
impl_log_set_loop(struct spa_log *log, struct spa_loop *loop)
|
||||
{
|
||||
struct impl *impl = SPA_CONTAINER_OF(log, struct impl, log);
|
||||
if (impl->have_source) {
|
||||
spa_loop_remove_source(impl->source.loop, &impl->source);
|
||||
close(impl->source.fd);
|
||||
impl->have_source = false;
|
||||
}
|
||||
if (loop) {
|
||||
impl->source.func = on_trace_event;
|
||||
impl->source.data = impl;
|
||||
impl->source.fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
|
||||
impl->source.mask = SPA_IO_IN;
|
||||
impl->source.rmask = 0;
|
||||
spa_loop_add_source(loop, &impl->source);
|
||||
impl->have_source = true;
|
||||
}
|
||||
}
|
||||
|
||||
static const struct spa_log impl_log = {
|
||||
sizeof(struct spa_log),
|
||||
NULL,
|
||||
DEFAULT_LOG_LEVEL,
|
||||
impl_log_log,
|
||||
impl_log_logv,
|
||||
impl_log_set_loop,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface)
|
||||
{
|
||||
struct impl *this;
|
||||
|
|
@ -176,10 +196,7 @@ static int impl_clear(struct spa_handle *handle)
|
|||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
if (this->have_source) {
|
||||
spa_loop_remove_source(this->main_loop, &this->trace_source);
|
||||
close(this->trace_source.fd);
|
||||
}
|
||||
impl_log_set_loop(&this->log, NULL);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -207,8 +224,6 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
for (i = 0; i < n_support; i++) {
|
||||
if (strcmp(support[i].type, SPA_TYPE__TypeMap) == 0)
|
||||
this->map = support[i].data;
|
||||
else if (strcmp(support[i].type, SPA_TYPE_LOOP__MainLoop) == 0)
|
||||
this->main_loop = support[i].data;
|
||||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error(&this->log, "a type-map is needed");
|
||||
|
|
@ -218,16 +233,6 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
|
||||
spa_ringbuffer_init(&this->trace_rb, TRACE_BUFFER);
|
||||
|
||||
if (this->main_loop) {
|
||||
this->trace_source.func = on_trace_event;
|
||||
this->trace_source.data = this;
|
||||
this->trace_source.fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
|
||||
this->trace_source.mask = SPA_IO_IN;
|
||||
this->trace_source.rmask = 0;
|
||||
spa_loop_add_source(this->main_loop, &this->trace_source);
|
||||
this->have_source = true;
|
||||
}
|
||||
|
||||
spa_log_info(&this->log, NAME " %p: initialized", this);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
|
|||
|
|
@ -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 ],
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -23,13 +23,16 @@
|
|||
#include <unistd.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <spa/type-map.h>
|
||||
#include <spa/type-map-impl.h>
|
||||
#include <spa/clock.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/log-impl.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/loop.h>
|
||||
|
||||
#include <lib/debug.h>
|
||||
#include <lib/mapper.h>
|
||||
|
||||
static SPA_TYPE_MAP_IMPL(default_map, 4096);
|
||||
static SPA_LOG_IMPL(default_log);
|
||||
|
||||
struct type {
|
||||
uint32_t node;
|
||||
|
|
@ -63,7 +66,7 @@ inspect_port(struct data *data, struct spa_node *node, enum spa_direction direct
|
|||
break;
|
||||
}
|
||||
if (format)
|
||||
spa_debug_format(format, data->map);
|
||||
spa_debug_format(format);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -75,7 +78,7 @@ inspect_port(struct data *data, struct spa_node *node, enum spa_direction direct
|
|||
printf("port_enum_params error: %d\n", res);
|
||||
break;
|
||||
}
|
||||
spa_debug_param(param, data->map);
|
||||
spa_debug_param(param);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +92,7 @@ static void inspect_node(struct data *data, struct spa_node *node)
|
|||
if ((res = spa_node_get_props(node, &props)) < 0)
|
||||
printf("can't get properties: %d\n", res);
|
||||
else
|
||||
spa_debug_props(props, data->map);
|
||||
spa_debug_props(props);
|
||||
|
||||
if ((res = spa_node_get_n_ports(node, &n_input, &max_input, &n_output, &max_output)) < 0) {
|
||||
printf("can't get n_ports: %d\n", res);
|
||||
|
|
@ -194,13 +197,15 @@ int main(int argc, char *argv[])
|
|||
return -1;
|
||||
}
|
||||
|
||||
data.map = spa_type_map_get_default();
|
||||
data.log = NULL;
|
||||
data.map = &default_map.map;
|
||||
data.log = &default_log.log;
|
||||
data.loop.size = sizeof(struct spa_loop);
|
||||
data.loop.add_source = do_add_source;
|
||||
data.loop.update_source = do_update_source;
|
||||
data.loop.remove_source = do_remove_source;
|
||||
|
||||
spa_debug_set_type_map(data.map);
|
||||
|
||||
data.support[0].type = SPA_TYPE__TypeMap;
|
||||
data.support[0].data = data.map;
|
||||
data.support[1].type = SPA_TYPE__Log;
|
||||
|
|
|
|||
|
|
@ -25,12 +25,15 @@
|
|||
#include <errno.h>
|
||||
#include <poll.h>
|
||||
|
||||
#include <spa/log.h>
|
||||
#include <spa/type-map.h>
|
||||
#include <spa/log-impl.h>
|
||||
#include <spa/type-map-impl.h>
|
||||
#include <spa/monitor.h>
|
||||
#include <spa/loop.h>
|
||||
|
||||
#include <lib/debug.h>
|
||||
#include <lib/mapper.h>
|
||||
|
||||
static SPA_TYPE_MAP_IMPL(default_map, 4096);
|
||||
static SPA_LOG_IMPL(default_log);
|
||||
|
||||
struct type {
|
||||
struct spa_type_monitor monitor;
|
||||
|
|
@ -57,7 +60,7 @@ struct data {
|
|||
|
||||
static void inspect_item(struct data *data, struct spa_monitor_item *item)
|
||||
{
|
||||
spa_debug_pod(&item->object.pod, data->map);
|
||||
spa_debug_pod(&item->object.pod);
|
||||
}
|
||||
|
||||
static void on_monitor_event(struct spa_monitor *monitor, struct spa_event *event, void *user_data)
|
||||
|
|
@ -162,13 +165,15 @@ int main(int argc, char *argv[])
|
|||
spa_handle_factory_enum_func_t enum_func;
|
||||
uint32_t fidx;
|
||||
|
||||
data.map = spa_type_map_get_default();
|
||||
data.log = NULL;
|
||||
data.map = &default_map.map;
|
||||
data.log = &default_log.log;
|
||||
data.main_loop.size = sizeof(struct spa_loop);
|
||||
data.main_loop.add_source = do_add_source;
|
||||
data.main_loop.update_source = do_update_source;
|
||||
data.main_loop.remove_source = do_remove_source;
|
||||
|
||||
spa_debug_set_type_map(data.map);
|
||||
|
||||
data.support[0].type = SPA_TYPE__TypeMap;
|
||||
data.support[0].data = data.map;
|
||||
data.support[1].type = SPA_TYPE__Log;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue