mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
Work on node creation
Implements the basics of the PORT_UPDATE control message Add the ports to the proxy node with whe PORT_UPDATE control message. Let the proxy node check the events and create dbus objects based on added/removed ports.
This commit is contained in:
parent
ac5d22ec79
commit
de53315f6e
17 changed files with 350 additions and 215 deletions
|
|
@ -275,7 +275,7 @@ spa_audiomixer_node_add_port (SpaNode *node,
|
|||
this->ports[port_id].valid = true;
|
||||
this->port_count++;
|
||||
|
||||
this->ports[port_id].info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFER |
|
||||
this->ports[port_id].info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_REMOVABLE |
|
||||
SPA_PORT_INFO_FLAG_OPTIONAL |
|
||||
SPA_PORT_INFO_FLAG_IN_PLACE;
|
||||
|
|
@ -798,8 +798,8 @@ spa_audiomixer_init (const SpaHandleFactory *factory,
|
|||
reset_audiomixer_props (&this->props[1]);
|
||||
|
||||
this->ports[0].valid = true;
|
||||
this->ports[0].info.flags = SPA_PORT_INFO_FLAG_CAN_GIVE_BUFFER |
|
||||
SPA_PORT_INFO_FLAG_CAN_USE_BUFFER |
|
||||
this->ports[0].info.flags = SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_NO_REF;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -585,7 +585,7 @@ audiotestsrc_init (const SpaHandleFactory *factory,
|
|||
this->props[1].props.prop_info = prop_info;
|
||||
reset_audiotestsrc_props (&this->props[1]);
|
||||
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFER |
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_NO_REF;
|
||||
this->status.flags = SPA_PORT_STATUS_FLAG_HAVE_OUTPUT;
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ typedef struct {
|
|||
SpaFormat formats[2];
|
||||
unsigned int n_buffers;
|
||||
SpaBuffer **buffers;
|
||||
SpaBuffer *remote_buffers[128];
|
||||
} SpaProxyPort;
|
||||
|
||||
struct _SpaProxy {
|
||||
|
|
@ -334,6 +333,59 @@ spa_proxy_node_get_port_ids (SpaNode *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
do_init_port (SpaProxy *this,
|
||||
uint32_t port_id,
|
||||
SpaDirection direction)
|
||||
{
|
||||
SpaEvent event;
|
||||
SpaProxyPort *port;
|
||||
SpaEventPortAdded pa;
|
||||
|
||||
fprintf (stderr, "%p: adding port %d, %d\n", this, port_id, direction);
|
||||
port = &this->ports[port_id];
|
||||
port->direction = direction;
|
||||
port->valid = true;
|
||||
port->have_format = false;
|
||||
|
||||
if (direction == SPA_DIRECTION_INPUT)
|
||||
this->n_inputs++;
|
||||
else
|
||||
this->n_outputs++;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_PORT_ADDED;
|
||||
event.port_id = port_id;
|
||||
event.data = &pa;
|
||||
event.size = sizeof (pa);
|
||||
pa.direction = direction;
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
do_uninit_port (SpaProxy *this,
|
||||
uint32_t port_id)
|
||||
{
|
||||
SpaEvent event;
|
||||
SpaProxyPort *port;
|
||||
|
||||
fprintf (stderr, "%p: removing port %d\n", this, port_id);
|
||||
port = &this->ports[port_id];
|
||||
|
||||
if (port->direction == SPA_DIRECTION_INPUT)
|
||||
this->n_inputs--;
|
||||
else
|
||||
this->n_outputs--;
|
||||
|
||||
port->direction = SPA_DIRECTION_INVALID;
|
||||
port->valid = false;
|
||||
port->have_format = false;
|
||||
|
||||
event.type = SPA_EVENT_TYPE_PORT_REMOVED;
|
||||
event.port_id = port_id;
|
||||
event.data = NULL;
|
||||
event.size = 0;
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_proxy_node_add_port (SpaNode *node,
|
||||
|
|
@ -341,7 +393,6 @@ spa_proxy_node_add_port (SpaNode *node,
|
|||
uint32_t port_id)
|
||||
{
|
||||
SpaProxy *this;
|
||||
SpaProxyPort *port;
|
||||
|
||||
if (node == NULL || node->handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -351,12 +402,7 @@ spa_proxy_node_add_port (SpaNode *node,
|
|||
if (!CHECK_FREE_PORT_ID (this, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
fprintf (stderr, "%p: adding port %d, %d\n", node, port_id, direction);
|
||||
port = &this->ports[port_id];
|
||||
|
||||
port->direction = direction;
|
||||
port->valid = true;
|
||||
port->have_format = false;
|
||||
do_init_port (this, port_id, direction);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -366,7 +412,6 @@ spa_proxy_node_remove_port (SpaNode *node,
|
|||
uint32_t port_id)
|
||||
{
|
||||
SpaProxy *this;
|
||||
SpaProxyPort *port;
|
||||
|
||||
if (node == NULL || node->handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -376,8 +421,7 @@ spa_proxy_node_remove_port (SpaNode *node,
|
|||
if (!CHECK_PORT_ID (this, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
port = &this->ports[port_id];
|
||||
port->valid = false;
|
||||
do_uninit_port (this, port_id);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -868,11 +912,31 @@ parse_control (SpaProxy *this,
|
|||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_NODE_UPDATE:
|
||||
case SPA_CONTROL_CMD_PORT_UPDATE:
|
||||
case SPA_CONTROL_CMD_PORT_REMOVED:
|
||||
fprintf (stderr, "proxy %p: command not implemented %d\n", this, cmd);
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_PORT_UPDATE:
|
||||
{
|
||||
SpaControlCmdPortUpdate pu;
|
||||
SpaProxyPort *port;
|
||||
|
||||
fprintf (stderr, "proxy %p: got port update %d\n", this, cmd);
|
||||
if (spa_control_iter_parse_cmd (&it, &pu) < 0)
|
||||
break;
|
||||
|
||||
if (pu.port_id >= MAX_PORTS)
|
||||
break;
|
||||
|
||||
port = &this->ports[pu.port_id];
|
||||
if (!port->valid && pu.direction != SPA_DIRECTION_INVALID) {
|
||||
do_init_port (this, pu.port_id, pu.direction);
|
||||
} else {
|
||||
do_uninit_port (this, pu.port_id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SPA_CONTROL_CMD_STATE_CHANGE:
|
||||
{
|
||||
SpaControlCmdStateChange sc;
|
||||
|
|
|
|||
|
|
@ -398,7 +398,8 @@ spa_v4l2_set_format (SpaV4l2Source *this, V4l2Format *f, bool try_only)
|
|||
return 0;
|
||||
|
||||
state->fmt = fmt;
|
||||
state->info.flags = SPA_PORT_INFO_FLAG_CAN_GIVE_BUFFER;
|
||||
state->info.flags = SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
state->info.maxbuffering = -1;
|
||||
state->info.latency = -1;
|
||||
|
||||
|
|
|
|||
|
|
@ -695,10 +695,10 @@ volume_instantiate (const SpaHandleFactory *factory,
|
|||
this->props[1].props.prop_info = prop_info;
|
||||
reset_volume_props (&this->props[1]);
|
||||
|
||||
this->ports[0].info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFER |
|
||||
this->ports[0].info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_IN_PLACE;
|
||||
this->ports[1].info.flags = SPA_PORT_INFO_FLAG_CAN_GIVE_BUFFER |
|
||||
SPA_PORT_INFO_FLAG_CAN_USE_BUFFER |
|
||||
this->ports[1].info.flags = SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_NO_REF;
|
||||
|
||||
this->ports[0].status.flags = SPA_PORT_STATUS_FLAG_NEED_INPUT;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue