mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-15 07:00:05 -05:00
work on port-update control message
Serialize format and properties. Simplify the properties by moving the unset-mask inside the property structure. We can then also just use the index of the property as the bit in the mask. Work on stopping on disconnect
This commit is contained in:
parent
de53315f6e
commit
0d2f5a1386
24 changed files with 318 additions and 238 deletions
|
|
@ -290,7 +290,7 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
|
|||
|
||||
target = pinos_daemon_find_port (pinos_node_get_daemon (pnode),
|
||||
pinos_direction_reverse (pa->direction),
|
||||
"/org/pinos/node_8",
|
||||
"/org/pinos/node_1",
|
||||
NULL,
|
||||
NULL,
|
||||
&error);
|
||||
|
|
|
|||
|
|
@ -182,6 +182,18 @@ no_node:
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_port_added (PinosNode *node, PinosPort *port, PinosClient *client)
|
||||
{
|
||||
pinos_client_add_object (client, G_OBJECT (port));
|
||||
}
|
||||
|
||||
static void
|
||||
on_port_removed (PinosNode *node, PinosPort *port, PinosClient *client)
|
||||
{
|
||||
pinos_client_remove_object (client, G_OBJECT (port));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_create_client_node (PinosDaemon1 *interface,
|
||||
GDBusMethodInvocation *invocation,
|
||||
|
|
@ -216,6 +228,9 @@ handle_create_client_node (PinosDaemon1 *interface,
|
|||
client = sender_get_client (daemon, sender);
|
||||
pinos_client_add_object (client, G_OBJECT (node));
|
||||
|
||||
g_signal_connect (node, "port-added", (GCallback) on_port_added, client);
|
||||
g_signal_connect (node, "port-removed", (GCallback) on_port_removed, client);
|
||||
|
||||
object_path = pinos_node_get_object_path (PINOS_NODE (node));
|
||||
g_debug ("daemon %p: add client-node %p, %s", daemon, node, object_path);
|
||||
|
||||
|
|
|
|||
|
|
@ -174,13 +174,13 @@ pinos_link_set_property (GObject *_object,
|
|||
break;
|
||||
|
||||
case PROP_OUTPUT:
|
||||
priv->output = g_value_dup_object (value);
|
||||
priv->output = g_value_get_object (value);
|
||||
priv->output_node = priv->output->node->node;
|
||||
priv->output_port = priv->output->id;
|
||||
break;
|
||||
|
||||
case PROP_INPUT:
|
||||
priv->input = g_value_dup_object (value);
|
||||
priv->input = g_value_get_object (value);
|
||||
priv->input_node = priv->input->node->node;
|
||||
priv->input_port = priv->input->id;
|
||||
break;
|
||||
|
|
@ -277,7 +277,7 @@ do_negotiate (PinosLink *this)
|
|||
value.type = SPA_PROP_TYPE_FRACTION;
|
||||
value.size = sizeof (SpaFraction);
|
||||
value.value = &frac;
|
||||
frac.num = 25;
|
||||
frac.num = 20;
|
||||
frac.denom = 1;
|
||||
if ((res = spa_props_set_prop (props, spa_props_index_for_id (props, SPA_PROP_ID_VIDEO_FRAMERATE), &value)) < 0)
|
||||
return res;
|
||||
|
|
@ -334,12 +334,12 @@ on_activate (PinosPort *port, gpointer user_data)
|
|||
|
||||
if (priv->active)
|
||||
return TRUE;
|
||||
priv->active = TRUE;
|
||||
|
||||
if (priv->input == port)
|
||||
pinos_port_activate (priv->output);
|
||||
else
|
||||
pinos_port_activate (priv->input);
|
||||
priv->active = TRUE;
|
||||
|
||||
if (!priv->negotiated)
|
||||
do_negotiate (this);
|
||||
|
|
@ -367,12 +367,12 @@ on_deactivate (PinosPort *port, gpointer user_data)
|
|||
|
||||
if (!priv->active)
|
||||
return TRUE;
|
||||
priv->active = FALSE;
|
||||
|
||||
if (priv->input == port)
|
||||
pinos_port_deactivate (priv->output);
|
||||
else
|
||||
pinos_port_deactivate (priv->input);
|
||||
priv->active = FALSE;
|
||||
|
||||
cmd.type = SPA_COMMAND_STOP;
|
||||
if ((res = spa_node_send_command (priv->input_node, &cmd)) < 0)
|
||||
|
|
|
|||
|
|
@ -69,6 +69,8 @@ enum
|
|||
enum
|
||||
{
|
||||
SIGNAL_REMOVE,
|
||||
SIGNAL_PORT_ADDED,
|
||||
SIGNAL_PORT_REMOVED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
|
@ -105,6 +107,7 @@ node_add_port (PinosNode *node,
|
|||
if (port) {
|
||||
g_hash_table_insert (priv->ports, GUINT_TO_POINTER (id), port);
|
||||
g_signal_connect (port, "remove", (GCallback) do_remove_port, node);
|
||||
g_signal_emit (node, signals[SIGNAL_PORT_ADDED], 0, port);
|
||||
}
|
||||
return port;
|
||||
}
|
||||
|
|
@ -114,8 +117,14 @@ node_remove_port (PinosNode *node,
|
|||
guint id)
|
||||
{
|
||||
PinosNodePrivate *priv = node->priv;
|
||||
PinosPort *port;
|
||||
|
||||
g_debug ("node %p: removed port %u", node, id);
|
||||
g_hash_table_remove (priv->ports, GUINT_TO_POINTER (id));
|
||||
port = g_hash_table_lookup (priv->ports, GUINT_TO_POINTER (id));
|
||||
if (port) {
|
||||
g_signal_emit (node, signals[SIGNAL_PORT_REMOVED], 0, port);
|
||||
g_hash_table_remove (priv->ports, GUINT_TO_POINTER (id));
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -497,6 +506,26 @@ pinos_node_class_init (PinosNodeClass * klass)
|
|||
G_TYPE_NONE,
|
||||
0,
|
||||
G_TYPE_NONE);
|
||||
signals[SIGNAL_PORT_ADDED] = g_signal_new ("port-added",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_generic,
|
||||
G_TYPE_NONE,
|
||||
0,
|
||||
PINOS_TYPE_PORT);
|
||||
signals[SIGNAL_PORT_REMOVED] = g_signal_new ("port-removed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_generic,
|
||||
G_TYPE_NONE,
|
||||
0,
|
||||
PINOS_TYPE_PORT);
|
||||
|
||||
node_class->set_state = node_set_state;
|
||||
node_class->add_port = node_add_port;
|
||||
|
|
@ -522,7 +551,10 @@ pinos_node_init (PinosNode * node)
|
|||
priv->state = PINOS_NODE_STATE_SUSPENDED;
|
||||
pinos_node1_set_state (priv->iface, PINOS_NODE_STATE_SUSPENDED);
|
||||
|
||||
priv->ports = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) g_object_unref);
|
||||
priv->ports = g_hash_table_new_full (g_direct_hash,
|
||||
g_direct_equal,
|
||||
NULL,
|
||||
(GDestroyNotify) g_object_unref);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -273,8 +273,11 @@ static void
|
|||
pinos_port_dispose (GObject * object)
|
||||
{
|
||||
PinosPort *port = PINOS_PORT (object);
|
||||
PinosPortPrivate *priv = port->priv;
|
||||
|
||||
g_debug ("port %p: dispose", port);
|
||||
g_debug ("port %p: dispose %d", port, priv->active_count);
|
||||
if (priv->active_count == 1)
|
||||
g_signal_emit (port, signals[SIGNAL_DEACTIVATE], 0, NULL);
|
||||
|
||||
G_OBJECT_CLASS (pinos_port_parent_class)->dispose (object);
|
||||
}
|
||||
|
|
@ -437,7 +440,7 @@ pinos_port_class_init (PinosPortClass * klass)
|
|||
static void
|
||||
pinos_port_init (PinosPort * port)
|
||||
{
|
||||
PinosPortPrivate *priv = port->priv = PINOS_PORT_GET_PRIVATE (port);
|
||||
port->priv = PINOS_PORT_GET_PRIVATE (port);
|
||||
|
||||
g_debug ("port %p: new", port);
|
||||
port->direction = PINOS_DIRECTION_INVALID;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue