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:
Wim Taymans 2017-03-01 14:07:02 +01:00
parent 282995d0d0
commit 710a1a41e6
13 changed files with 131 additions and 81 deletions

View file

@ -74,8 +74,7 @@ spa_alsa_sink_node_get_props (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
b.data = this->props_buffer;
b.size = sizeof (this->props_buffer);
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
PROP_ID_DEVICE, SPA_POD_TYPE_STRING,
@ -329,7 +328,7 @@ spa_alsa_sink_node_port_enum_formats (SpaNode *node,
SpaResult res;
SpaFormat *fmt;
uint8_t buffer[1024];
SpaPODBuilder b = { buffer, sizeof (buffer), };
SpaPODBuilder b = { NULL, };
if (node == NULL || format == NULL)
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))
return SPA_RESULT_INVALID_PORT;
switch (index) {
next:
spa_pod_builder_init (&b, buffer, sizeof (buffer));
switch (index++) {
case 0:
fmt = SPA_MEMBER (buffer, spa_pod_builder_format (&b,
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;
}
b.data = this->format_buffer;
b.size = sizeof (this->format_buffer);
b.offset = 0;
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
return res;
goto next;
*format = SPA_MEMBER (b.data, 0, SpaFormat);

View file

@ -74,8 +74,7 @@ spa_alsa_source_node_get_props (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
b.data = this->props_buffer;
b.size = sizeof (this->props_buffer);
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
PROP_ID_DEVICE, SPA_POD_TYPE_STRING,
@ -363,8 +362,8 @@ spa_alsa_source_node_port_enum_formats (SpaNode *node,
SpaALSASource *this;
SpaResult res;
SpaFormat *fmt;
uint8_t buffer[256];
SpaPODBuilder b = { buffer, sizeof (buffer), };
uint8_t buffer[1024];
SpaPODBuilder b = { NULL, };
if (node == NULL || format == NULL)
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))
return SPA_RESULT_INVALID_PORT;
switch (index) {
next:
spa_pod_builder_init (&b, buffer, sizeof (buffer));
switch (index++) {
case 0:
fmt = SPA_MEMBER (buffer, spa_pod_builder_format (&b,
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;
}
b.data = this->format_buffer;
b.size = sizeof (this->format_buffer);
b.offset = 0;
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
return res;
goto next;
*format = SPA_MEMBER (this->format_buffer, 0, SpaFormat);

View file

@ -143,8 +143,7 @@ spa_audiotestsrc_node_get_props (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
b.data = this->props_buffer;
b.size = sizeof (this->props_buffer);
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
PROP_ID_LIVE, SPA_POD_TYPE_BOOL,
@ -462,7 +461,7 @@ spa_audiotestsrc_node_port_enum_formats (SpaNode *node,
SpaResult res;
SpaFormat *fmt;
uint8_t buffer[256];
SpaPODBuilder b = { buffer, sizeof (buffer), };
SpaPODBuilder b = { NULL, };
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
@ -472,9 +471,11 @@ spa_audiotestsrc_node_port_enum_formats (SpaNode *node,
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
switch (index) {
next:
spa_pod_builder_init (&b, buffer, sizeof (buffer));
switch (index++) {
case 0:
{
fmt = SPA_MEMBER (buffer, spa_pod_builder_format (&b,
SPA_MEDIA_TYPE_AUDIO, SPA_MEDIA_SUBTYPE_RAW,
SPA_PROP_ID_AUDIO_FORMAT, SPA_POD_TYPE_INT,
@ -495,17 +496,14 @@ spa_audiotestsrc_node_port_enum_formats (SpaNode *node,
1, INT32_MAX,
0), SpaFormat);
break;
}
default:
return SPA_RESULT_ENUM_END;
}
b.data = this->format_buffer;
b.size = sizeof (this->format_buffer);
b.offset = 0;
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
return res;
goto next;
*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);
this->n_buffers = 0;
spa_list_init (&this->empty);
this->started = false;
set_timer (this, false);
}
return SPA_RESULT_OK;
}
@ -599,8 +599,7 @@ spa_audiotestsrc_node_port_get_format (SpaNode *node,
if (!this->have_format)
return SPA_RESULT_NO_FORMAT;
b.data = this->format_buffer;
b.size = sizeof (this->format_buffer);
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
*format = SPA_MEMBER (b.data, spa_pod_builder_format (&b,
SPA_MEDIA_TYPE_AUDIO, SPA_MEDIA_SUBTYPE_RAW,

View file

@ -452,7 +452,7 @@ spa_v4l2_enum_format (SpaV4l2Source *this,
unsigned int index)
{
SpaV4l2State *state = &this->state[0];
int res;
int res, n_fractions;
const FormatInfo *info;
SpaPODFrame f[2];
SpaPODProp *prop;
@ -631,7 +631,7 @@ have_size:
SPA_POD_PROP_FLAG_UNSET |
SPA_POD_PROP_FLAG_READWRITE),
SpaPODProp);
spa_pod_builder_fraction (&b, 25, 1);
n_fractions = 0;
state->frmival.index = 0;
@ -694,12 +694,18 @@ have_framerate:
if (state->frmival.type == V4L2_FRMIVAL_TYPE_DISCRETE) {
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,
state->frmival.discrete.denominator,
state->frmival.discrete.numerator);
state->frmival.index++;
} else if (state->frmival.type == V4L2_FRMIVAL_TYPE_CONTINUOUS ||
state->frmival.type == V4L2_FRMIVAL_TYPE_STEPWISE) {
if (n_fractions == 0)
spa_pod_builder_fraction (&b, 25, 1);
spa_pod_builder_fraction (&b,
state->frmival.stepwise.min.denominator,
state->frmival.stepwise.min.numerator);
@ -717,6 +723,7 @@ have_framerate:
}
break;
}
n_fractions++;
}
spa_pod_builder_pop (&b, &f[1]);
spa_pod_builder_pop (&b, &f[0]);

View file

@ -71,8 +71,8 @@ struct _SpaVideoTestSrc {
SpaLog *log;
SpaLoop *data_loop;
uint8_t props_buffer[512];
SpaVideoTestSrcProps props;
uint8_t props_buffer[256];
SpaNodeEventCallback event_cb;
void *user_data;
@ -135,8 +135,7 @@ spa_videotestsrc_node_get_props (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
b.data = this->props_buffer;
b.size = sizeof (this->props_buffer);
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
PROP_ID_LIVE, SPA_POD_TYPE_BOOL,
@ -431,7 +430,7 @@ spa_videotestsrc_node_port_enum_formats (SpaNode *node,
SpaResult res;
SpaFormat *fmt;
uint8_t buffer[1024];
SpaPODBuilder b = { buffer, sizeof (buffer), };
SpaPODBuilder b = { NULL, };
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
@ -441,7 +440,10 @@ spa_videotestsrc_node_port_enum_formats (SpaNode *node,
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
switch (index) {
next:
spa_pod_builder_init (&b, buffer, sizeof (buffer));
switch (index++) {
case 0:
fmt = SPA_MEMBER (buffer, spa_pod_builder_format (&b,
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;
}
b.data = this->format_buffer;
b.size = sizeof (this->format_buffer);
b.offset = 0;
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
return res;
goto next;
*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);
this->n_buffers = 0;
spa_list_init (&this->empty);
this->started = false;
set_timer (this, false);
}
return SPA_RESULT_OK;
}
@ -579,8 +581,7 @@ spa_videotestsrc_node_port_get_format (SpaNode *node,
if (!this->have_format)
return SPA_RESULT_NO_FORMAT;
b.data = this->format_buffer;
b.size = sizeof (this->format_buffer);
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
*format = SPA_MEMBER (b.data, spa_pod_builder_format (&b,
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,
0), SpaFormat);
return SPA_RESULT_OK;
}

View file

@ -125,8 +125,7 @@ spa_volume_node_get_props (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaVolume, node);
b.data = this->props_buffer;
b.size = sizeof (this->props_buffer);
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
PROP_ID_VOLUME, SPA_POD_TYPE_DOUBLE,
@ -293,7 +292,7 @@ spa_volume_node_port_enum_formats (SpaNode *node,
SpaResult res;
SpaFormat *fmt;
uint8_t buffer[1024];
SpaPODBuilder b = { buffer, sizeof (buffer), };
SpaPODBuilder b = { NULL, };
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
@ -303,7 +302,10 @@ spa_volume_node_port_enum_formats (SpaNode *node,
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
switch (index) {
next:
spa_pod_builder_init (&b, buffer, sizeof (buffer));
switch (index++) {
case 0:
fmt = SPA_MEMBER (buffer, spa_pod_builder_format (&b,
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;
}
b.data = this->format_buffer;
b.size = sizeof (this->format_buffer);
b.offset = 0;
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
return res;
goto next;
*format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat);

View file

@ -126,8 +126,7 @@ spa_xv_sink_node_get_props (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaXvSink, node);
b.data = this->props_buffer;
b.size = sizeof (this->props_buffer);
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,