link: fix negotiation

Fix renegotiation of idle but not yet suspended nodes.
This commit is contained in:
Wim Taymans 2017-04-06 16:12:47 +02:00
parent 3adbaacec2
commit 4808f8f10e
5 changed files with 50 additions and 23 deletions

View file

@ -590,8 +590,13 @@ handle_id_prop (SpaPODProp *prop, const char *key, GstCaps *res)
const char * str;
uint32_t *id = SPA_POD_CONTENTS (SpaPODProp, prop);
uint32_t i, n_items = SPA_POD_PROP_N_VALUES (prop);
uint32_t flags;
switch (prop->body.flags & SPA_POD_PROP_RANGE_MASK) {
flags = prop->body.flags;
if (!(flags & SPA_POD_PROP_FLAG_UNSET))
flags &= ~SPA_POD_PROP_RANGE_MASK;
switch (flags) {
case SPA_POD_PROP_RANGE_NONE:
if (!(str = spa_type_map_get_type (type.map, id[0])))
return;
@ -624,8 +629,13 @@ handle_int_prop (SpaPODProp *prop, const char *key, GstCaps *res)
{
uint32_t *val = SPA_POD_CONTENTS (SpaPODProp, prop);
uint32_t i, n_items = SPA_POD_PROP_N_VALUES (prop);
uint32_t flags;
switch (prop->body.flags & SPA_POD_PROP_RANGE_MASK) {
flags = prop->body.flags;
if (!(flags & SPA_POD_PROP_FLAG_UNSET))
flags &= ~SPA_POD_PROP_RANGE_MASK;
switch (flags) {
case SPA_POD_PROP_RANGE_NONE:
gst_caps_set_simple (res, key, G_TYPE_INT, val[0], NULL);
break;
@ -661,8 +671,13 @@ handle_rect_prop (SpaPODProp *prop, const char *width, const char *height, GstCa
{
SpaRectangle *rect = SPA_POD_CONTENTS (SpaPODProp, prop);
uint32_t i, n_items = SPA_POD_PROP_N_VALUES (prop);
uint32_t flags;
switch (prop->body.flags & SPA_POD_PROP_RANGE_MASK) {
flags = prop->body.flags;
if (!(flags & SPA_POD_PROP_FLAG_UNSET))
flags &= ~SPA_POD_PROP_RANGE_MASK;
switch (flags) {
case SPA_POD_PROP_RANGE_NONE:
gst_caps_set_simple (res, width, G_TYPE_INT, rect[0].width,
height, G_TYPE_INT, rect[0].height, NULL);
@ -707,8 +722,13 @@ handle_fraction_prop (SpaPODProp *prop, const char *key, GstCaps *res)
{
SpaFraction *fract = SPA_POD_CONTENTS (SpaPODProp, prop);
uint32_t i, n_items = SPA_POD_PROP_N_VALUES (prop);
uint32_t flags;
switch (prop->body.flags & SPA_POD_PROP_RANGE_MASK) {
flags = prop->body.flags;
if (!(flags & SPA_POD_PROP_FLAG_UNSET))
flags &= ~SPA_POD_PROP_RANGE_MASK;
switch (flags) {
case SPA_POD_PROP_RANGE_NONE:
gst_caps_set_simple (res, key, GST_TYPE_FRACTION, fract[0].num, fract[0].denom, NULL);
break;

View file

@ -551,6 +551,11 @@ pinos_core_find_format (PinosCore *core,
out_state = output->node->node->state;
in_state = input->node->node->state;
if (out_state > SPA_NODE_STATE_CONFIGURE && output->node->state == PINOS_NODE_STATE_IDLE)
out_state = SPA_NODE_STATE_CONFIGURE;
if (in_state > SPA_NODE_STATE_CONFIGURE && input->node->state == PINOS_NODE_STATE_IDLE)
in_state = SPA_NODE_STATE_CONFIGURE;
if (in_state == SPA_NODE_STATE_CONFIGURE && out_state > SPA_NODE_STATE_CONFIGURE) {
/* only input needs format */
if ((res = spa_node_port_get_format (output->node->node,

View file

@ -79,7 +79,7 @@ static SpaResult
do_negotiate (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
{
PinosLinkImpl *impl = SPA_CONTAINER_OF (this, PinosLinkImpl, this);
SpaResult res = SPA_RESULT_ERROR;
SpaResult res = SPA_RESULT_ERROR, res2;
SpaFormat *format;
char *error = NULL;
@ -88,11 +88,6 @@ do_negotiate (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
pinos_link_update_state (this, PINOS_LINK_STATE_NEGOTIATING, NULL);
if (out_state > SPA_NODE_STATE_READY && this->output->node->state == PINOS_NODE_STATE_IDLE) {
pinos_node_set_state (this->output->node, PINOS_NODE_STATE_SUSPENDED);
out_state = SPA_NODE_STATE_CONFIGURE;
}
format = pinos_core_find_format (this->core,
this->output,
this->input,
@ -100,8 +95,16 @@ do_negotiate (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
0,
NULL,
&error);
if (format == NULL) {
if (format == NULL)
goto error;
if (out_state > SPA_NODE_STATE_CONFIGURE && this->output->node->state == PINOS_NODE_STATE_IDLE) {
pinos_node_set_state (this->output->node, PINOS_NODE_STATE_SUSPENDED);
out_state = SPA_NODE_STATE_CONFIGURE;
}
if (in_state > SPA_NODE_STATE_CONFIGURE && this->input->node->state == PINOS_NODE_STATE_IDLE) {
pinos_node_set_state (this->input->node, PINOS_NODE_STATE_SUSPENDED);
in_state = SPA_NODE_STATE_CONFIGURE;
}
pinos_log_debug ("link %p: doing set format", this);
@ -119,17 +122,19 @@ do_negotiate (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
goto error;
}
pinos_work_queue_add (impl->work, this->output->node, res, NULL, NULL);
} else if (in_state == SPA_NODE_STATE_CONFIGURE) {
}
if (in_state == SPA_NODE_STATE_CONFIGURE) {
pinos_log_debug ("link %p: doing set format on input", this);
if ((res = spa_node_port_set_format (this->input->node->node,
SPA_DIRECTION_INPUT,
this->input->port_id,
SPA_PORT_FORMAT_FLAG_NEAREST,
format)) < 0) {
asprintf (&error, "error set input format: %d", res);
if ((res2 = spa_node_port_set_format (this->input->node->node,
SPA_DIRECTION_INPUT,
this->input->port_id,
SPA_PORT_FORMAT_FLAG_NEAREST,
format)) < 0) {
asprintf (&error, "error set input format: %d", res2);
goto error;
}
pinos_work_queue_add (impl->work, this->input->node, res, NULL, NULL);
pinos_work_queue_add (impl->work, this->input->node, res2, NULL, NULL);
res = res2 != SPA_RESULT_OK ? res2 : res;
}
return res;

View file

@ -260,7 +260,6 @@ open_card (SpaALSAMonitor *this, struct udev_device *dev)
snprintf (this->card_name, 63, "hw:%s", str);
printf ("open card %s\n", this->card_name);
if ((err = snd_ctl_open (&this->ctl_hndl, this->card_name, 0)) < 0) {
spa_log_error (this->log, "can't open control for card %s: %s", this->card_name, snd_strerror (err));
return err;
@ -279,7 +278,6 @@ get_next_device (SpaALSAMonitor *this, struct udev_device *dev)
snd_ctl_card_info_t *card_info;
if (this->stream_idx == -1) {
printf ("next device %d\n", this->dev_idx);
if ((err = snd_ctl_pcm_next_device (this->ctl_hndl, &this->dev_idx)) < 0) {
spa_log_error (this->log, "error iterating devices: %s", snd_strerror (err));
return err;
@ -295,7 +293,6 @@ get_next_device (SpaALSAMonitor *this, struct udev_device *dev)
snd_pcm_info_set_subdevice (dev_info, 0);
again:
printf ("stream %d\n", this->stream_idx);
switch (this->stream_idx++) {
case 0:
snd_pcm_info_set_stream (dev_info, SND_PCM_STREAM_PLAYBACK);
@ -318,7 +315,6 @@ again:
goto again;
fill_item (this, card_info, dev_info, dev);
printf ("got item\n");
return 0;
}

View file

@ -325,6 +325,7 @@ static void
update_state (SpaVideoTestSrc *this, SpaNodeState state)
{
this->node.state = state;
spa_log_info (this->log, "videotestsrc %p: update state %d", this, state);
}
static SpaResult