mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-17 08:56:49 -05:00
Improve negotiation
Fix selection of the default property value by restricting it to something in the valid range of the property. Fix audio/videotestsrc reuse Fix format enum with filters. Fix module property configuration Fix connection refill
This commit is contained in:
parent
282995d0d0
commit
710a1a41e6
13 changed files with 131 additions and 81 deletions
|
|
@ -29,7 +29,7 @@
|
||||||
#include "serialize.h"
|
#include "serialize.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
#define MAX_BUFFER_SIZE 4096
|
#define MAX_BUFFER_SIZE 1024
|
||||||
#define MAX_FDS 28
|
#define MAX_FDS 28
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
@ -1005,9 +1005,6 @@ refill_buffer (PinosConnection *conn, ConnectionBuffer *buf)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len < 8)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
buf->buffer_size += len;
|
buf->buffer_size += len;
|
||||||
|
|
||||||
/* handle control messages */
|
/* handle control messages */
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ static SpaResult
|
||||||
setup_video_node (SpaNode *spa_node, PinosProperties *pinos_props) {
|
setup_video_node (SpaNode *spa_node, PinosProperties *pinos_props) {
|
||||||
SpaResult res;
|
SpaResult res;
|
||||||
SpaProps *props;
|
SpaProps *props;
|
||||||
// SpaPropValue value;
|
SpaPODProp *prop;
|
||||||
const char *pattern;
|
const char *pattern;
|
||||||
uint32_t pattern_int;
|
uint32_t pattern_int;
|
||||||
|
|
||||||
|
|
@ -49,15 +49,15 @@ setup_video_node (SpaNode *spa_node, PinosProperties *pinos_props) {
|
||||||
return SPA_RESULT_ERROR;
|
return SPA_RESULT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
//// value.value = &pattern_int;
|
|
||||||
// value.size = sizeof(uint32_t);
|
|
||||||
|
|
||||||
if ((res = spa_node_get_props (spa_node, &props)) != SPA_RESULT_OK) {
|
if ((res = spa_node_get_props (spa_node, &props)) != SPA_RESULT_OK) {
|
||||||
pinos_log_debug ("spa_node_get_props failed: %d", res);
|
pinos_log_debug ("spa_node_get_props failed: %d", res);
|
||||||
return SPA_RESULT_ERROR;
|
return SPA_RESULT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// spa_props_set_value (props, spa_props_index_for_name (props, "pattern"), &value);
|
if ((prop = spa_pod_object_find_prop (props, 2))) {
|
||||||
|
if (prop->body.value.type == SPA_POD_TYPE_INT)
|
||||||
|
((SpaPODInt*)&prop->body.value)->value = pattern_int;
|
||||||
|
}
|
||||||
|
|
||||||
if ((res = spa_node_set_props (spa_node, props)) != SPA_RESULT_OK) {
|
if ((res = spa_node_set_props (spa_node, props)) != SPA_RESULT_OK) {
|
||||||
pinos_log_debug ("spa_node_set_props failed: %d", res);
|
pinos_log_debug ("spa_node_set_props failed: %d", res);
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,6 @@ do_negotiate (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
||||||
NULL,
|
NULL,
|
||||||
&error);
|
&error);
|
||||||
if (format == NULL) {
|
if (format == NULL) {
|
||||||
asprintf (&error, "no common format found");
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,17 @@ typedef struct _SpaPODBuilder {
|
||||||
|
|
||||||
#define SPA_POD_BUILDER_DEREF(b,ref,type) SPA_MEMBER ((b)->data, (ref), type)
|
#define SPA_POD_BUILDER_DEREF(b,ref,type) SPA_MEMBER ((b)->data, (ref), type)
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
spa_pod_builder_init (SpaPODBuilder *builder,
|
||||||
|
void *data,
|
||||||
|
size_t size)
|
||||||
|
{
|
||||||
|
builder->data = data;
|
||||||
|
builder->size = size;
|
||||||
|
builder->offset = 0;
|
||||||
|
builder->stack = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
spa_pod_builder_in_array (SpaPODBuilder *builder)
|
spa_pod_builder_in_array (SpaPODBuilder *builder)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -318,8 +318,8 @@ struct pod_type_name {
|
||||||
} pod_type_names[] = {
|
} pod_type_names[] = {
|
||||||
{ "invalid", "*Invalid*" },
|
{ "invalid", "*Invalid*" },
|
||||||
{ "bool", "Bool" },
|
{ "bool", "Bool" },
|
||||||
{ "int", "Int" },
|
|
||||||
{ "uri", "URI" },
|
{ "uri", "URI" },
|
||||||
|
{ "int", "Int" },
|
||||||
{ "long", "Long" },
|
{ "long", "Long" },
|
||||||
{ "float", "Float" },
|
{ "float", "Float" },
|
||||||
{ "double", "Double" },
|
{ "double", "Double" },
|
||||||
|
|
@ -341,12 +341,12 @@ print_pod_value (uint32_t size, uint32_t type, void *body, int prefix)
|
||||||
case SPA_POD_TYPE_BOOL:
|
case SPA_POD_TYPE_BOOL:
|
||||||
printf ("%-*sBool %d\n", prefix, "", *(int32_t *) body);
|
printf ("%-*sBool %d\n", prefix, "", *(int32_t *) body);
|
||||||
break;
|
break;
|
||||||
case SPA_POD_TYPE_INT:
|
|
||||||
printf ("%-*sInt %d\n", prefix, "", *(int32_t *) body);
|
|
||||||
break;
|
|
||||||
case SPA_POD_TYPE_URI:
|
case SPA_POD_TYPE_URI:
|
||||||
printf ("%-*sURI %d\n", prefix, "", *(int32_t *) body);
|
printf ("%-*sURI %d\n", prefix, "", *(int32_t *) body);
|
||||||
break;
|
break;
|
||||||
|
case SPA_POD_TYPE_INT:
|
||||||
|
printf ("%-*sInt %d\n", prefix, "", *(int32_t *) body);
|
||||||
|
break;
|
||||||
case SPA_POD_TYPE_LONG:
|
case SPA_POD_TYPE_LONG:
|
||||||
printf ("%-*sLong %"PRIi64"\n", prefix, "", *(int64_t *) body);
|
printf ("%-*sLong %"PRIi64"\n", prefix, "", *(int64_t *) body);
|
||||||
break;
|
break;
|
||||||
|
|
@ -441,10 +441,10 @@ print_format_value (uint32_t size, uint32_t type, void *body)
|
||||||
case SPA_POD_TYPE_BOOL:
|
case SPA_POD_TYPE_BOOL:
|
||||||
fprintf (stderr, "%s", *(int32_t *) body ? "true" : "false");
|
fprintf (stderr, "%s", *(int32_t *) body ? "true" : "false");
|
||||||
break;
|
break;
|
||||||
case SPA_POD_TYPE_INT:
|
case SPA_POD_TYPE_URI:
|
||||||
fprintf (stderr, "%"PRIi32, *(int32_t *) body);
|
fprintf (stderr, "%"PRIi32, *(int32_t *) body);
|
||||||
break;
|
break;
|
||||||
case SPA_POD_TYPE_URI:
|
case SPA_POD_TYPE_INT:
|
||||||
fprintf (stderr, "%"PRIi32, *(int32_t *) body);
|
fprintf (stderr, "%"PRIi32, *(int32_t *) body);
|
||||||
break;
|
break;
|
||||||
case SPA_POD_TYPE_LONG:
|
case SPA_POD_TYPE_LONG:
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,52 @@ compare_value (SpaPODType type, const void *r1, const void *r2)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fix_default (SpaPODProp *prop)
|
||||||
|
{
|
||||||
|
void *val = SPA_MEMBER (prop, sizeof (SpaPODProp), void),
|
||||||
|
*alt = SPA_MEMBER (val, prop->body.value.size, void);
|
||||||
|
int i, nalt = SPA_POD_PROP_N_VALUES (prop) - 1;
|
||||||
|
|
||||||
|
switch (prop->body.flags & SPA_POD_PROP_RANGE_MASK) {
|
||||||
|
case SPA_POD_PROP_RANGE_NONE:
|
||||||
|
break;
|
||||||
|
case SPA_POD_PROP_RANGE_MIN_MAX:
|
||||||
|
case SPA_POD_PROP_RANGE_STEP:
|
||||||
|
if (compare_value (prop->body.value.type, val, alt) < 0)
|
||||||
|
memcpy (val, alt, prop->body.value.size);
|
||||||
|
alt = SPA_MEMBER (alt, prop->body.value.size, void);
|
||||||
|
if (compare_value (prop->body.value.type, val, alt) > 0)
|
||||||
|
memcpy (val, alt, prop->body.value.size);
|
||||||
|
break;
|
||||||
|
case SPA_POD_PROP_RANGE_ENUM:
|
||||||
|
{
|
||||||
|
void *best = NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < nalt; i++) {
|
||||||
|
if (compare_value (prop->body.value.type, val, alt) == 0) {
|
||||||
|
best = alt;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (best == NULL)
|
||||||
|
best = alt;
|
||||||
|
alt = SPA_MEMBER (alt, prop->body.value.size, void);
|
||||||
|
}
|
||||||
|
if (best)
|
||||||
|
memcpy (val, best, prop->body.value.size);
|
||||||
|
|
||||||
|
if (nalt == 1) {
|
||||||
|
prop->body.flags &= ~SPA_POD_PROP_FLAG_UNSET;
|
||||||
|
prop->body.flags &= ~SPA_POD_PROP_RANGE_MASK;
|
||||||
|
prop->body.flags |= SPA_POD_PROP_RANGE_NONE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SPA_POD_PROP_RANGE_FLAGS:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static inline SpaPODProp *
|
static inline SpaPODProp *
|
||||||
find_prop (const SpaPOD *pod, uint32_t size, uint32_t key)
|
find_prop (const SpaPOD *pod, uint32_t size, uint32_t key)
|
||||||
{
|
{
|
||||||
|
|
@ -244,9 +290,6 @@ spa_props_filter (SpaPODBuilder *b,
|
||||||
}
|
}
|
||||||
if (n_copied == 0)
|
if (n_copied == 0)
|
||||||
return SPA_RESULT_NO_FORMAT;
|
return SPA_RESULT_NO_FORMAT;
|
||||||
if (n_copied == 1)
|
|
||||||
np->body.flags |= SPA_POD_PROP_RANGE_NONE;
|
|
||||||
else
|
|
||||||
np->body.flags |= SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET;
|
np->body.flags |= SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -264,9 +307,6 @@ spa_props_filter (SpaPODBuilder *b,
|
||||||
}
|
}
|
||||||
if (n_copied == 0)
|
if (n_copied == 0)
|
||||||
return SPA_RESULT_NO_FORMAT;
|
return SPA_RESULT_NO_FORMAT;
|
||||||
if (n_copied == 1)
|
|
||||||
np->body.flags |= SPA_POD_PROP_RANGE_NONE;
|
|
||||||
else
|
|
||||||
np->body.flags |= SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET;
|
np->body.flags |= SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -289,9 +329,6 @@ spa_props_filter (SpaPODBuilder *b,
|
||||||
}
|
}
|
||||||
if (n_copied == 0)
|
if (n_copied == 0)
|
||||||
return SPA_RESULT_NO_FORMAT;
|
return SPA_RESULT_NO_FORMAT;
|
||||||
if (n_copied == 1)
|
|
||||||
np->body.flags |= SPA_POD_PROP_RANGE_NONE;
|
|
||||||
else
|
|
||||||
np->body.flags |= SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET;
|
np->body.flags |= SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -348,6 +385,7 @@ spa_props_filter (SpaPODBuilder *b,
|
||||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
spa_pod_builder_pop (b, &f);
|
spa_pod_builder_pop (b, &f);
|
||||||
|
fix_default (np);
|
||||||
}
|
}
|
||||||
return SPA_RESULT_OK;
|
return SPA_RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,8 +74,7 @@ spa_alsa_sink_node_get_props (SpaNode *node,
|
||||||
|
|
||||||
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
|
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
|
||||||
|
|
||||||
b.data = this->props_buffer;
|
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
|
||||||
b.size = sizeof (this->props_buffer);
|
|
||||||
|
|
||||||
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
|
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
|
||||||
PROP_ID_DEVICE, SPA_POD_TYPE_STRING,
|
PROP_ID_DEVICE, SPA_POD_TYPE_STRING,
|
||||||
|
|
@ -329,7 +328,7 @@ spa_alsa_sink_node_port_enum_formats (SpaNode *node,
|
||||||
SpaResult res;
|
SpaResult res;
|
||||||
SpaFormat *fmt;
|
SpaFormat *fmt;
|
||||||
uint8_t buffer[1024];
|
uint8_t buffer[1024];
|
||||||
SpaPODBuilder b = { buffer, sizeof (buffer), };
|
SpaPODBuilder b = { NULL, };
|
||||||
|
|
||||||
if (node == NULL || format == NULL)
|
if (node == NULL || format == NULL)
|
||||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||||
|
|
@ -339,7 +338,10 @@ spa_alsa_sink_node_port_enum_formats (SpaNode *node,
|
||||||
if (!CHECK_PORT (this, direction, port_id))
|
if (!CHECK_PORT (this, direction, port_id))
|
||||||
return SPA_RESULT_INVALID_PORT;
|
return SPA_RESULT_INVALID_PORT;
|
||||||
|
|
||||||
switch (index) {
|
next:
|
||||||
|
spa_pod_builder_init (&b, buffer, sizeof (buffer));
|
||||||
|
|
||||||
|
switch (index++) {
|
||||||
case 0:
|
case 0:
|
||||||
fmt = SPA_MEMBER (buffer, spa_pod_builder_format (&b,
|
fmt = SPA_MEMBER (buffer, spa_pod_builder_format (&b,
|
||||||
SPA_MEDIA_TYPE_AUDIO, SPA_MEDIA_SUBTYPE_RAW,
|
SPA_MEDIA_TYPE_AUDIO, SPA_MEDIA_SUBTYPE_RAW,
|
||||||
|
|
@ -370,12 +372,10 @@ spa_alsa_sink_node_port_enum_formats (SpaNode *node,
|
||||||
return SPA_RESULT_ENUM_END;
|
return SPA_RESULT_ENUM_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
b.data = this->format_buffer;
|
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
|
||||||
b.size = sizeof (this->format_buffer);
|
|
||||||
b.offset = 0;
|
|
||||||
|
|
||||||
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
|
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
|
||||||
return res;
|
goto next;
|
||||||
|
|
||||||
*format = SPA_MEMBER (b.data, 0, SpaFormat);
|
*format = SPA_MEMBER (b.data, 0, SpaFormat);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,8 +74,7 @@ spa_alsa_source_node_get_props (SpaNode *node,
|
||||||
|
|
||||||
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
|
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
|
||||||
|
|
||||||
b.data = this->props_buffer;
|
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
|
||||||
b.size = sizeof (this->props_buffer);
|
|
||||||
|
|
||||||
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
|
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
|
||||||
PROP_ID_DEVICE, SPA_POD_TYPE_STRING,
|
PROP_ID_DEVICE, SPA_POD_TYPE_STRING,
|
||||||
|
|
@ -363,8 +362,8 @@ spa_alsa_source_node_port_enum_formats (SpaNode *node,
|
||||||
SpaALSASource *this;
|
SpaALSASource *this;
|
||||||
SpaResult res;
|
SpaResult res;
|
||||||
SpaFormat *fmt;
|
SpaFormat *fmt;
|
||||||
uint8_t buffer[256];
|
uint8_t buffer[1024];
|
||||||
SpaPODBuilder b = { buffer, sizeof (buffer), };
|
SpaPODBuilder b = { NULL, };
|
||||||
|
|
||||||
if (node == NULL || format == NULL)
|
if (node == NULL || format == NULL)
|
||||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||||
|
|
@ -374,7 +373,10 @@ spa_alsa_source_node_port_enum_formats (SpaNode *node,
|
||||||
if (!CHECK_PORT (this, direction, port_id))
|
if (!CHECK_PORT (this, direction, port_id))
|
||||||
return SPA_RESULT_INVALID_PORT;
|
return SPA_RESULT_INVALID_PORT;
|
||||||
|
|
||||||
switch (index) {
|
next:
|
||||||
|
spa_pod_builder_init (&b, buffer, sizeof (buffer));
|
||||||
|
|
||||||
|
switch (index++) {
|
||||||
case 0:
|
case 0:
|
||||||
fmt = SPA_MEMBER (buffer, spa_pod_builder_format (&b,
|
fmt = SPA_MEMBER (buffer, spa_pod_builder_format (&b,
|
||||||
SPA_MEDIA_TYPE_AUDIO, SPA_MEDIA_SUBTYPE_RAW,
|
SPA_MEDIA_TYPE_AUDIO, SPA_MEDIA_SUBTYPE_RAW,
|
||||||
|
|
@ -404,12 +406,10 @@ spa_alsa_source_node_port_enum_formats (SpaNode *node,
|
||||||
return SPA_RESULT_ENUM_END;
|
return SPA_RESULT_ENUM_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
b.data = this->format_buffer;
|
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
|
||||||
b.size = sizeof (this->format_buffer);
|
|
||||||
b.offset = 0;
|
|
||||||
|
|
||||||
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
|
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
|
||||||
return res;
|
goto next;
|
||||||
|
|
||||||
*format = SPA_MEMBER (this->format_buffer, 0, SpaFormat);
|
*format = SPA_MEMBER (this->format_buffer, 0, SpaFormat);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -143,8 +143,7 @@ spa_audiotestsrc_node_get_props (SpaNode *node,
|
||||||
|
|
||||||
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
|
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
|
||||||
|
|
||||||
b.data = this->props_buffer;
|
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
|
||||||
b.size = sizeof (this->props_buffer);
|
|
||||||
|
|
||||||
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
|
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
|
||||||
PROP_ID_LIVE, SPA_POD_TYPE_BOOL,
|
PROP_ID_LIVE, SPA_POD_TYPE_BOOL,
|
||||||
|
|
@ -462,7 +461,7 @@ spa_audiotestsrc_node_port_enum_formats (SpaNode *node,
|
||||||
SpaResult res;
|
SpaResult res;
|
||||||
SpaFormat *fmt;
|
SpaFormat *fmt;
|
||||||
uint8_t buffer[256];
|
uint8_t buffer[256];
|
||||||
SpaPODBuilder b = { buffer, sizeof (buffer), };
|
SpaPODBuilder b = { NULL, };
|
||||||
|
|
||||||
if (node == NULL || format == NULL)
|
if (node == NULL || format == NULL)
|
||||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||||
|
|
@ -472,9 +471,11 @@ spa_audiotestsrc_node_port_enum_formats (SpaNode *node,
|
||||||
if (!CHECK_PORT (this, direction, port_id))
|
if (!CHECK_PORT (this, direction, port_id))
|
||||||
return SPA_RESULT_INVALID_PORT;
|
return SPA_RESULT_INVALID_PORT;
|
||||||
|
|
||||||
switch (index) {
|
next:
|
||||||
|
spa_pod_builder_init (&b, buffer, sizeof (buffer));
|
||||||
|
|
||||||
|
switch (index++) {
|
||||||
case 0:
|
case 0:
|
||||||
{
|
|
||||||
fmt = SPA_MEMBER (buffer, spa_pod_builder_format (&b,
|
fmt = SPA_MEMBER (buffer, spa_pod_builder_format (&b,
|
||||||
SPA_MEDIA_TYPE_AUDIO, SPA_MEDIA_SUBTYPE_RAW,
|
SPA_MEDIA_TYPE_AUDIO, SPA_MEDIA_SUBTYPE_RAW,
|
||||||
SPA_PROP_ID_AUDIO_FORMAT, SPA_POD_TYPE_INT,
|
SPA_PROP_ID_AUDIO_FORMAT, SPA_POD_TYPE_INT,
|
||||||
|
|
@ -495,17 +496,14 @@ spa_audiotestsrc_node_port_enum_formats (SpaNode *node,
|
||||||
1, INT32_MAX,
|
1, INT32_MAX,
|
||||||
0), SpaFormat);
|
0), SpaFormat);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return SPA_RESULT_ENUM_END;
|
return SPA_RESULT_ENUM_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
b.data = this->format_buffer;
|
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
|
||||||
b.size = sizeof (this->format_buffer);
|
|
||||||
b.offset = 0;
|
|
||||||
|
|
||||||
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
|
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
|
||||||
return res;
|
goto next;
|
||||||
|
|
||||||
*format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat);
|
*format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat);
|
||||||
|
|
||||||
|
|
@ -519,6 +517,8 @@ clear_buffers (SpaAudioTestSrc *this)
|
||||||
spa_log_info (this->log, "audiotestsrc %p: clear buffers", this);
|
spa_log_info (this->log, "audiotestsrc %p: clear buffers", this);
|
||||||
this->n_buffers = 0;
|
this->n_buffers = 0;
|
||||||
spa_list_init (&this->empty);
|
spa_list_init (&this->empty);
|
||||||
|
this->started = false;
|
||||||
|
set_timer (this, false);
|
||||||
}
|
}
|
||||||
return SPA_RESULT_OK;
|
return SPA_RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -599,8 +599,7 @@ spa_audiotestsrc_node_port_get_format (SpaNode *node,
|
||||||
if (!this->have_format)
|
if (!this->have_format)
|
||||||
return SPA_RESULT_NO_FORMAT;
|
return SPA_RESULT_NO_FORMAT;
|
||||||
|
|
||||||
b.data = this->format_buffer;
|
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
|
||||||
b.size = sizeof (this->format_buffer);
|
|
||||||
|
|
||||||
*format = SPA_MEMBER (b.data, spa_pod_builder_format (&b,
|
*format = SPA_MEMBER (b.data, spa_pod_builder_format (&b,
|
||||||
SPA_MEDIA_TYPE_AUDIO, SPA_MEDIA_SUBTYPE_RAW,
|
SPA_MEDIA_TYPE_AUDIO, SPA_MEDIA_SUBTYPE_RAW,
|
||||||
|
|
|
||||||
|
|
@ -452,7 +452,7 @@ spa_v4l2_enum_format (SpaV4l2Source *this,
|
||||||
unsigned int index)
|
unsigned int index)
|
||||||
{
|
{
|
||||||
SpaV4l2State *state = &this->state[0];
|
SpaV4l2State *state = &this->state[0];
|
||||||
int res;
|
int res, n_fractions;
|
||||||
const FormatInfo *info;
|
const FormatInfo *info;
|
||||||
SpaPODFrame f[2];
|
SpaPODFrame f[2];
|
||||||
SpaPODProp *prop;
|
SpaPODProp *prop;
|
||||||
|
|
@ -631,7 +631,7 @@ have_size:
|
||||||
SPA_POD_PROP_FLAG_UNSET |
|
SPA_POD_PROP_FLAG_UNSET |
|
||||||
SPA_POD_PROP_FLAG_READWRITE),
|
SPA_POD_PROP_FLAG_READWRITE),
|
||||||
SpaPODProp);
|
SpaPODProp);
|
||||||
spa_pod_builder_fraction (&b, 25, 1);
|
n_fractions = 0;
|
||||||
|
|
||||||
state->frmival.index = 0;
|
state->frmival.index = 0;
|
||||||
|
|
||||||
|
|
@ -694,12 +694,18 @@ have_framerate:
|
||||||
|
|
||||||
if (state->frmival.type == V4L2_FRMIVAL_TYPE_DISCRETE) {
|
if (state->frmival.type == V4L2_FRMIVAL_TYPE_DISCRETE) {
|
||||||
prop->body.flags |= SPA_POD_PROP_RANGE_ENUM;
|
prop->body.flags |= SPA_POD_PROP_RANGE_ENUM;
|
||||||
|
if (n_fractions == 0)
|
||||||
|
spa_pod_builder_fraction (&b,
|
||||||
|
state->frmival.discrete.denominator,
|
||||||
|
state->frmival.discrete.numerator);
|
||||||
spa_pod_builder_fraction (&b,
|
spa_pod_builder_fraction (&b,
|
||||||
state->frmival.discrete.denominator,
|
state->frmival.discrete.denominator,
|
||||||
state->frmival.discrete.numerator);
|
state->frmival.discrete.numerator);
|
||||||
state->frmival.index++;
|
state->frmival.index++;
|
||||||
} else if (state->frmival.type == V4L2_FRMIVAL_TYPE_CONTINUOUS ||
|
} else if (state->frmival.type == V4L2_FRMIVAL_TYPE_CONTINUOUS ||
|
||||||
state->frmival.type == V4L2_FRMIVAL_TYPE_STEPWISE) {
|
state->frmival.type == V4L2_FRMIVAL_TYPE_STEPWISE) {
|
||||||
|
if (n_fractions == 0)
|
||||||
|
spa_pod_builder_fraction (&b, 25, 1);
|
||||||
spa_pod_builder_fraction (&b,
|
spa_pod_builder_fraction (&b,
|
||||||
state->frmival.stepwise.min.denominator,
|
state->frmival.stepwise.min.denominator,
|
||||||
state->frmival.stepwise.min.numerator);
|
state->frmival.stepwise.min.numerator);
|
||||||
|
|
@ -717,6 +723,7 @@ have_framerate:
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
n_fractions++;
|
||||||
}
|
}
|
||||||
spa_pod_builder_pop (&b, &f[1]);
|
spa_pod_builder_pop (&b, &f[1]);
|
||||||
spa_pod_builder_pop (&b, &f[0]);
|
spa_pod_builder_pop (&b, &f[0]);
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,8 @@ struct _SpaVideoTestSrc {
|
||||||
SpaLog *log;
|
SpaLog *log;
|
||||||
SpaLoop *data_loop;
|
SpaLoop *data_loop;
|
||||||
|
|
||||||
|
uint8_t props_buffer[512];
|
||||||
SpaVideoTestSrcProps props;
|
SpaVideoTestSrcProps props;
|
||||||
uint8_t props_buffer[256];
|
|
||||||
|
|
||||||
SpaNodeEventCallback event_cb;
|
SpaNodeEventCallback event_cb;
|
||||||
void *user_data;
|
void *user_data;
|
||||||
|
|
@ -135,8 +135,7 @@ spa_videotestsrc_node_get_props (SpaNode *node,
|
||||||
|
|
||||||
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
|
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
|
||||||
|
|
||||||
b.data = this->props_buffer;
|
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
|
||||||
b.size = sizeof (this->props_buffer);
|
|
||||||
|
|
||||||
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
|
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
|
||||||
PROP_ID_LIVE, SPA_POD_TYPE_BOOL,
|
PROP_ID_LIVE, SPA_POD_TYPE_BOOL,
|
||||||
|
|
@ -431,7 +430,7 @@ spa_videotestsrc_node_port_enum_formats (SpaNode *node,
|
||||||
SpaResult res;
|
SpaResult res;
|
||||||
SpaFormat *fmt;
|
SpaFormat *fmt;
|
||||||
uint8_t buffer[1024];
|
uint8_t buffer[1024];
|
||||||
SpaPODBuilder b = { buffer, sizeof (buffer), };
|
SpaPODBuilder b = { NULL, };
|
||||||
|
|
||||||
if (node == NULL || format == NULL)
|
if (node == NULL || format == NULL)
|
||||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||||
|
|
@ -441,7 +440,10 @@ spa_videotestsrc_node_port_enum_formats (SpaNode *node,
|
||||||
if (!CHECK_PORT (this, direction, port_id))
|
if (!CHECK_PORT (this, direction, port_id))
|
||||||
return SPA_RESULT_INVALID_PORT;
|
return SPA_RESULT_INVALID_PORT;
|
||||||
|
|
||||||
switch (index) {
|
next:
|
||||||
|
spa_pod_builder_init (&b, buffer, sizeof (buffer));
|
||||||
|
|
||||||
|
switch (index++) {
|
||||||
case 0:
|
case 0:
|
||||||
fmt = SPA_MEMBER (buffer, spa_pod_builder_format (&b,
|
fmt = SPA_MEMBER (buffer, spa_pod_builder_format (&b,
|
||||||
SPA_MEDIA_TYPE_VIDEO, SPA_MEDIA_SUBTYPE_RAW,
|
SPA_MEDIA_TYPE_VIDEO, SPA_MEDIA_SUBTYPE_RAW,
|
||||||
|
|
@ -468,12 +470,10 @@ spa_videotestsrc_node_port_enum_formats (SpaNode *node,
|
||||||
return SPA_RESULT_ENUM_END;
|
return SPA_RESULT_ENUM_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
b.data = this->format_buffer;
|
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
|
||||||
b.size = sizeof (this->format_buffer);
|
|
||||||
b.offset = 0;
|
|
||||||
|
|
||||||
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
|
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
|
||||||
return res;
|
goto next;
|
||||||
|
|
||||||
*format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat);
|
*format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat);
|
||||||
|
|
||||||
|
|
@ -487,6 +487,8 @@ clear_buffers (SpaVideoTestSrc *this)
|
||||||
spa_log_info (this->log, "videotestsrc %p: clear buffers", this);
|
spa_log_info (this->log, "videotestsrc %p: clear buffers", this);
|
||||||
this->n_buffers = 0;
|
this->n_buffers = 0;
|
||||||
spa_list_init (&this->empty);
|
spa_list_init (&this->empty);
|
||||||
|
this->started = false;
|
||||||
|
set_timer (this, false);
|
||||||
}
|
}
|
||||||
return SPA_RESULT_OK;
|
return SPA_RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -579,8 +581,7 @@ spa_videotestsrc_node_port_get_format (SpaNode *node,
|
||||||
if (!this->have_format)
|
if (!this->have_format)
|
||||||
return SPA_RESULT_NO_FORMAT;
|
return SPA_RESULT_NO_FORMAT;
|
||||||
|
|
||||||
b.data = this->format_buffer;
|
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
|
||||||
b.size = sizeof (this->format_buffer);
|
|
||||||
|
|
||||||
*format = SPA_MEMBER (b.data, spa_pod_builder_format (&b,
|
*format = SPA_MEMBER (b.data, spa_pod_builder_format (&b,
|
||||||
SPA_MEDIA_TYPE_VIDEO, SPA_MEDIA_SUBTYPE_RAW,
|
SPA_MEDIA_TYPE_VIDEO, SPA_MEDIA_SUBTYPE_RAW,
|
||||||
|
|
@ -597,7 +598,6 @@ spa_videotestsrc_node_port_get_format (SpaNode *node,
|
||||||
SPA_POD_PROP_FLAG_READWRITE,
|
SPA_POD_PROP_FLAG_READWRITE,
|
||||||
0), SpaFormat);
|
0), SpaFormat);
|
||||||
|
|
||||||
|
|
||||||
return SPA_RESULT_OK;
|
return SPA_RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,8 +125,7 @@ spa_volume_node_get_props (SpaNode *node,
|
||||||
|
|
||||||
this = SPA_CONTAINER_OF (node, SpaVolume, node);
|
this = SPA_CONTAINER_OF (node, SpaVolume, node);
|
||||||
|
|
||||||
b.data = this->props_buffer;
|
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
|
||||||
b.size = sizeof (this->props_buffer);
|
|
||||||
|
|
||||||
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
|
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
|
||||||
PROP_ID_VOLUME, SPA_POD_TYPE_DOUBLE,
|
PROP_ID_VOLUME, SPA_POD_TYPE_DOUBLE,
|
||||||
|
|
@ -293,7 +292,7 @@ spa_volume_node_port_enum_formats (SpaNode *node,
|
||||||
SpaResult res;
|
SpaResult res;
|
||||||
SpaFormat *fmt;
|
SpaFormat *fmt;
|
||||||
uint8_t buffer[1024];
|
uint8_t buffer[1024];
|
||||||
SpaPODBuilder b = { buffer, sizeof (buffer), };
|
SpaPODBuilder b = { NULL, };
|
||||||
|
|
||||||
if (node == NULL || format == NULL)
|
if (node == NULL || format == NULL)
|
||||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||||
|
|
@ -303,7 +302,10 @@ spa_volume_node_port_enum_formats (SpaNode *node,
|
||||||
if (!CHECK_PORT (this, direction, port_id))
|
if (!CHECK_PORT (this, direction, port_id))
|
||||||
return SPA_RESULT_INVALID_PORT;
|
return SPA_RESULT_INVALID_PORT;
|
||||||
|
|
||||||
switch (index) {
|
next:
|
||||||
|
spa_pod_builder_init (&b, buffer, sizeof (buffer));
|
||||||
|
|
||||||
|
switch (index++) {
|
||||||
case 0:
|
case 0:
|
||||||
fmt = SPA_MEMBER (buffer, spa_pod_builder_format (&b,
|
fmt = SPA_MEMBER (buffer, spa_pod_builder_format (&b,
|
||||||
SPA_MEDIA_TYPE_AUDIO, SPA_MEDIA_SUBTYPE_RAW,
|
SPA_MEDIA_TYPE_AUDIO, SPA_MEDIA_SUBTYPE_RAW,
|
||||||
|
|
@ -329,12 +331,10 @@ spa_volume_node_port_enum_formats (SpaNode *node,
|
||||||
return SPA_RESULT_ENUM_END;
|
return SPA_RESULT_ENUM_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
b.data = this->format_buffer;
|
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
|
||||||
b.size = sizeof (this->format_buffer);
|
|
||||||
b.offset = 0;
|
|
||||||
|
|
||||||
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
|
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
|
||||||
return res;
|
goto next;
|
||||||
|
|
||||||
*format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat);
|
*format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,8 +126,7 @@ spa_xv_sink_node_get_props (SpaNode *node,
|
||||||
|
|
||||||
this = SPA_CONTAINER_OF (node, SpaXvSink, node);
|
this = SPA_CONTAINER_OF (node, SpaXvSink, node);
|
||||||
|
|
||||||
b.data = this->props_buffer;
|
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
|
||||||
b.size = sizeof (this->props_buffer);
|
|
||||||
|
|
||||||
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
|
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue