mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-17 08:56:49 -05:00
parent
4b408e2978
commit
5e58e03da7
4 changed files with 86 additions and 28 deletions
|
|
@ -41,12 +41,13 @@ extern "C" {
|
||||||
#include <spa/param/format-utils.h>
|
#include <spa/param/format-utils.h>
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
spa_debug_format_value(const struct spa_type_info *info,
|
spa_debug_buffer_format_value(struct spa_debug_buffer *buffer, const struct spa_type_info *info,
|
||||||
uint32_t type, void *body, uint32_t size)
|
uint32_t type, void *body, uint32_t size)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SPA_TYPE_Bool:
|
case SPA_TYPE_Bool:
|
||||||
spa_debugn("%s", *(int32_t *) body ? "true" : "false");
|
spa_debug_buffer_append(buffer, "%s", *(int32_t *) body ? "true" : "false");
|
||||||
break;
|
break;
|
||||||
case SPA_TYPE_Id:
|
case SPA_TYPE_Id:
|
||||||
{
|
{
|
||||||
|
|
@ -56,41 +57,41 @@ spa_debug_format_value(const struct spa_type_info *info,
|
||||||
snprintf(tmp, sizeof(tmp), "%d", *(int32_t*)body);
|
snprintf(tmp, sizeof(tmp), "%d", *(int32_t*)body);
|
||||||
str = tmp;
|
str = tmp;
|
||||||
}
|
}
|
||||||
spa_debugn("%s", str);
|
spa_debug_buffer_append(buffer, "%s", str);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SPA_TYPE_Int:
|
case SPA_TYPE_Int:
|
||||||
spa_debugn("%d", *(int32_t *) body);
|
spa_debug_buffer_append(buffer, "%d", *(int32_t *) body);
|
||||||
break;
|
break;
|
||||||
case SPA_TYPE_Long:
|
case SPA_TYPE_Long:
|
||||||
spa_debugn("%" PRIi64, *(int64_t *) body);
|
spa_debug_buffer_append(buffer, "%" PRIi64, *(int64_t *) body);
|
||||||
break;
|
break;
|
||||||
case SPA_TYPE_Float:
|
case SPA_TYPE_Float:
|
||||||
spa_debugn("%f", *(float *) body);
|
spa_debug_buffer_append(buffer, "%f", *(float *) body);
|
||||||
break;
|
break;
|
||||||
case SPA_TYPE_Double:
|
case SPA_TYPE_Double:
|
||||||
spa_debugn("%f", *(double *) body);
|
spa_debug_buffer_append(buffer, "%f", *(double *) body);
|
||||||
break;
|
break;
|
||||||
case SPA_TYPE_String:
|
case SPA_TYPE_String:
|
||||||
spa_debugn("%s", (char *) body);
|
spa_debug_buffer_append(buffer, "%s", (char *) body);
|
||||||
break;
|
break;
|
||||||
case SPA_TYPE_Rectangle:
|
case SPA_TYPE_Rectangle:
|
||||||
{
|
{
|
||||||
struct spa_rectangle *r = (struct spa_rectangle *)body;
|
struct spa_rectangle *r = (struct spa_rectangle *)body;
|
||||||
spa_debugn("%" PRIu32 "x%" PRIu32, r->width, r->height);
|
spa_debug_buffer_append(buffer, "%" PRIu32 "x%" PRIu32, r->width, r->height);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SPA_TYPE_Fraction:
|
case SPA_TYPE_Fraction:
|
||||||
{
|
{
|
||||||
struct spa_fraction *f = (struct spa_fraction *)body;
|
struct spa_fraction *f = (struct spa_fraction *)body;
|
||||||
spa_debugn("%" PRIu32 "/%" PRIu32, f->num, f->denom);
|
spa_debug_buffer_append(buffer, "%" PRIu32 "/%" PRIu32, f->num, f->denom);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SPA_TYPE_Bitmap:
|
case SPA_TYPE_Bitmap:
|
||||||
spa_debugn("Bitmap");
|
spa_debug_buffer_append(buffer, "Bitmap");
|
||||||
break;
|
break;
|
||||||
case SPA_TYPE_Bytes:
|
case SPA_TYPE_Bytes:
|
||||||
spa_debugn("Bytes");
|
spa_debug_buffer_append(buffer, "Bytes");
|
||||||
break;
|
break;
|
||||||
case SPA_TYPE_Array:
|
case SPA_TYPE_Array:
|
||||||
{
|
{
|
||||||
|
|
@ -98,22 +99,34 @@ spa_debug_format_value(const struct spa_type_info *info,
|
||||||
struct spa_pod_array_body *b = (struct spa_pod_array_body *)body;
|
struct spa_pod_array_body *b = (struct spa_pod_array_body *)body;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
info = info && info->values ? info->values : info;
|
info = info && info->values ? info->values : info;
|
||||||
spa_debugn("< ");
|
spa_debug_buffer_append(buffer, "< ");
|
||||||
SPA_POD_ARRAY_BODY_FOREACH(b, size, p) {
|
SPA_POD_ARRAY_BODY_FOREACH(b, size, p) {
|
||||||
if (i++ > 0)
|
if (i++ > 0)
|
||||||
spa_debugn(", ");
|
spa_debug_buffer_append(buffer, ", ");
|
||||||
spa_debug_format_value(info, b->child.type, p, b->child.size);
|
spa_debug_buffer_format_value(buffer, info, b->child.type, p, b->child.size);
|
||||||
}
|
}
|
||||||
spa_debugn(" >");
|
spa_debug_buffer_append(buffer, " >");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
spa_debugn("INVALID type %d", type);
|
spa_debug_buffer_append(buffer, "INVALID type %d", type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
spa_debug_format_value(const struct spa_type_info *info,
|
||||||
|
uint32_t type, void *body, uint32_t size)
|
||||||
|
{
|
||||||
|
char buffer[1024];
|
||||||
|
struct spa_debug_buffer buf;
|
||||||
|
spa_debug_buffer_init(&buf, buffer, sizeof(buffer));
|
||||||
|
spa_debug_buffer_format_value(&buf, info, type, body, size);
|
||||||
|
spa_debugn("%s", buffer);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static inline int spa_debug_format(int indent,
|
static inline int spa_debug_format(int indent,
|
||||||
const struct spa_type_info *info, const struct spa_pod *format)
|
const struct spa_type_info *info, const struct spa_pod *format)
|
||||||
{
|
{
|
||||||
|
|
@ -144,6 +157,8 @@ static inline int spa_debug_format(int indent,
|
||||||
uint32_t i, type, size, n_vals, choice;
|
uint32_t i, type, size, n_vals, choice;
|
||||||
const struct spa_pod *val;
|
const struct spa_pod *val;
|
||||||
void *vals;
|
void *vals;
|
||||||
|
char buffer[1024];
|
||||||
|
struct spa_debug_buffer buf;
|
||||||
|
|
||||||
if (prop->key == SPA_FORMAT_mediaType ||
|
if (prop->key == SPA_FORMAT_mediaType ||
|
||||||
prop->key == SPA_FORMAT_mediaSubtype)
|
prop->key == SPA_FORMAT_mediaSubtype)
|
||||||
|
|
@ -161,12 +176,13 @@ static inline int spa_debug_format(int indent,
|
||||||
ti = spa_debug_type_find(info, prop->key);
|
ti = spa_debug_type_find(info, prop->key);
|
||||||
key = ti ? ti->name : NULL;
|
key = ti ? ti->name : NULL;
|
||||||
|
|
||||||
spa_debugn("%*s %16s : (%s) ", indent, "",
|
spa_debug_buffer_init(&buf, buffer, sizeof(buffer));
|
||||||
|
spa_debug_buffer_append(&buf, "%*s %16s : (%s) ", indent, "",
|
||||||
key ? spa_debug_type_short_name(key) : "unknown",
|
key ? spa_debug_type_short_name(key) : "unknown",
|
||||||
spa_debug_type_short_name(spa_types[type].name));
|
spa_debug_type_short_name(spa_types[type].name));
|
||||||
|
|
||||||
if (choice == SPA_CHOICE_None) {
|
if (choice == SPA_CHOICE_None) {
|
||||||
spa_debug_format_value(ti ? ti->values : NULL, type, vals, size);
|
spa_debug_buffer_format_value(&buf, ti ? ti->values : NULL, type, vals, size);
|
||||||
} else {
|
} else {
|
||||||
const char *ssep, *esep, *sep;
|
const char *ssep, *esep, *sep;
|
||||||
|
|
||||||
|
|
@ -186,17 +202,17 @@ static inline int spa_debug_format(int indent,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
spa_debugn("%s", ssep);
|
spa_debug_buffer_append(&buf, "%s", ssep);
|
||||||
|
|
||||||
for (i = 1; i < n_vals; i++) {
|
for (i = 1; i < n_vals; i++) {
|
||||||
vals = SPA_PTROFF(vals, size, void);
|
vals = SPA_PTROFF(vals, size, void);
|
||||||
if (i > 1)
|
if (i > 1)
|
||||||
spa_debugn("%s", sep);
|
spa_debug_buffer_append(&buf, "%s", sep);
|
||||||
spa_debug_format_value(ti ? ti->values : NULL, type, vals, size);
|
spa_debug_buffer_format_value(&buf, ti ? ti->values : NULL, type, vals, size);
|
||||||
}
|
}
|
||||||
spa_debugn("%s", esep);
|
spa_debug_buffer_append(&buf, "%s", esep);
|
||||||
}
|
}
|
||||||
spa_debugn("\n");
|
spa_debug("%s", buffer);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,9 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#include <spa/utils/defs.h>
|
||||||
/**
|
/**
|
||||||
* \addtogroup spa_debug
|
* \addtogroup spa_debug
|
||||||
* \{
|
* \{
|
||||||
|
|
@ -42,6 +45,33 @@ extern "C" {
|
||||||
#define spa_debugn(fmt,...) ({ printf((fmt), ## __VA_ARGS__); })
|
#define spa_debugn(fmt,...) ({ printf((fmt), ## __VA_ARGS__); })
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct spa_debug_buffer {
|
||||||
|
char *buffer;
|
||||||
|
size_t maxsize;
|
||||||
|
size_t pos;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline void spa_debug_buffer_init(struct spa_debug_buffer *buf, char *buffer, size_t maxsize)
|
||||||
|
{
|
||||||
|
buf->buffer = buffer;
|
||||||
|
buf->maxsize = maxsize;
|
||||||
|
buf->pos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPA_PRINTF_FUNC(2, 3)
|
||||||
|
static inline int spa_debug_buffer_append(struct spa_debug_buffer *buf, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
size_t remain = buf->maxsize - buf->pos;
|
||||||
|
ssize_t written;
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
written = vsnprintf(&buf->buffer[buf->pos], remain, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
if (written > 0)
|
||||||
|
buf->pos += SPA_MIN(remain, (size_t)written);
|
||||||
|
return written;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \}
|
* \}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -40,13 +40,18 @@
|
||||||
#include <spa/param/param.h>
|
#include <spa/param/param.h>
|
||||||
#include <spa/param/audio/format-utils.h>
|
#include <spa/param/audio/format-utils.h>
|
||||||
#include <spa/param/latency-utils.h>
|
#include <spa/param/latency-utils.h>
|
||||||
#include <spa/debug/format.h>
|
|
||||||
#include <spa/debug/pod.h>
|
|
||||||
|
|
||||||
#undef SPA_LOG_TOPIC_DEFAULT
|
#undef SPA_LOG_TOPIC_DEFAULT
|
||||||
#define SPA_LOG_TOPIC_DEFAULT log_topic
|
#define SPA_LOG_TOPIC_DEFAULT log_topic
|
||||||
static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.audioadapter");
|
static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.audioadapter");
|
||||||
|
|
||||||
|
static struct spa_log *global_log;
|
||||||
|
|
||||||
|
#undef spa_debug
|
||||||
|
#define spa_debug(...) spa_log_debug(global_log, __VA_ARGS__)
|
||||||
|
#include <spa/debug/format.h>
|
||||||
|
#include <spa/debug/pod.h>
|
||||||
|
|
||||||
#define DEFAULT_ALIGN 16
|
#define DEFAULT_ALIGN 16
|
||||||
|
|
||||||
#define MAX_PORTS (SPA_AUDIO_MAX_CHANNELS+1)
|
#define MAX_PORTS (SPA_AUDIO_MAX_CHANNELS+1)
|
||||||
|
|
@ -1639,6 +1644,7 @@ impl_init(const struct spa_handle_factory *factory,
|
||||||
|
|
||||||
this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
|
this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
|
||||||
spa_log_topic_init(this->log, log_topic);
|
spa_log_topic_init(this->log, log_topic);
|
||||||
|
global_log = this->log;
|
||||||
|
|
||||||
this->cpu = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_CPU);
|
this->cpu = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_CPU);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,13 +40,18 @@
|
||||||
#include <spa/param/param.h>
|
#include <spa/param/param.h>
|
||||||
#include <spa/param/video/format-utils.h>
|
#include <spa/param/video/format-utils.h>
|
||||||
#include <spa/param/latency-utils.h>
|
#include <spa/param/latency-utils.h>
|
||||||
#include <spa/debug/format.h>
|
|
||||||
#include <spa/debug/pod.h>
|
|
||||||
|
|
||||||
#undef SPA_LOG_TOPIC_DEFAULT
|
#undef SPA_LOG_TOPIC_DEFAULT
|
||||||
#define SPA_LOG_TOPIC_DEFAULT log_topic
|
#define SPA_LOG_TOPIC_DEFAULT log_topic
|
||||||
static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.videoadapter");
|
static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.videoadapter");
|
||||||
|
|
||||||
|
static struct spa_log *global_log;
|
||||||
|
|
||||||
|
#undef spa_debug
|
||||||
|
#define spa_debug(...) spa_log_debug(global_log, __VA_ARGS__)
|
||||||
|
#include <spa/debug/format.h>
|
||||||
|
#include <spa/debug/pod.h>
|
||||||
|
|
||||||
#define DEFAULT_ALIGN 16
|
#define DEFAULT_ALIGN 16
|
||||||
|
|
||||||
#define MAX_PORTS 1
|
#define MAX_PORTS 1
|
||||||
|
|
@ -1574,6 +1579,7 @@ impl_init(const struct spa_handle_factory *factory,
|
||||||
|
|
||||||
this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
|
this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
|
||||||
spa_log_topic_init(this->log, log_topic);
|
spa_log_topic_init(this->log, log_topic);
|
||||||
|
global_log = this->log;
|
||||||
|
|
||||||
this->cpu = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_CPU);
|
this->cpu = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_CPU);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue