diff --git a/pinos/client/context.c b/pinos/client/context.c index b3dd73058..c8e95e91d 100644 --- a/pinos/client/context.c +++ b/pinos/client/context.c @@ -148,9 +148,8 @@ pinos_context_finalize (GObject * object) pinos_properties_free (priv->properties); g_list_free (priv->nodes); - g_list_free (priv->ports); + g_list_free (priv->links); g_list_free (priv->clients); - g_list_free (priv->channels); g_clear_object (&priv->subscribe); g_clear_error (&priv->error); @@ -417,18 +416,11 @@ subscription_cb (PinosSubscribe *subscribe, priv->nodes = g_list_remove (priv->nodes, object); break; - case PINOS_SUBSCRIPTION_FLAG_PORT: + case PINOS_SUBSCRIPTION_FLAG_LINK: if (event == PINOS_SUBSCRIPTION_EVENT_NEW) - priv->ports = g_list_prepend (priv->ports, object); + priv->links = g_list_prepend (priv->links, object); else if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE) - priv->ports = g_list_remove (priv->ports, object); - break; - - case PINOS_SUBSCRIPTION_FLAG_CHANNEL: - if (event == PINOS_SUBSCRIPTION_EVENT_NEW) - priv->channels = g_list_prepend (priv->channels, object); - else if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE) - priv->channels = g_list_remove (priv->channels, object); + priv->links = g_list_remove (priv->links, object); break; } diff --git a/pinos/client/introspect.c b/pinos/client/introspect.c index dbf2b952e..91c601594 100644 --- a/pinos/client/introspect.c +++ b/pinos/client/introspect.c @@ -434,57 +434,44 @@ pinos_direction_as_string (PinosDirection direction) } static void -port_fill_info (PinosPortInfo *info, GDBusProxy *proxy) +link_fill_info (PinosLinkInfo *info, GDBusProxy *proxy) { GHashTable *changed = g_object_get_data (G_OBJECT (proxy), "pinos-changed-properties"); info->id = proxy; - info->port_path = g_dbus_proxy_get_object_path (proxy); - SET_UINT32 ("Direction", direction, 0, PINOS_DIRECTION_INVALID); - SET_STRING ("Node", node_path, 0); + info->link_path = g_dbus_proxy_get_object_path (proxy); info->change_mask = 0; - SET_STRING ("Name", name, 0); - SET_OBJV ("Peers", peers, 1); - SET_PROPERTIES ("Properties", properties, 2); - SET_BYTES ("PossibleFormats", possible_formats, 3); - SET_BYTES ("Format", format, 4); + SET_STRING ("SrcPort", source_port_path, 0); + SET_STRING ("DestPort", destination_port_path, 1); if (changed) g_hash_table_remove_all (changed); } static void -port_clear_info (PinosPortInfo *info) +link_clear_info (PinosLinkInfo *info) { - if (info->peers) - g_strfreev (info->peers); - if (info->properties) - pinos_properties_free (info->properties); - if (info->possible_formats) - g_bytes_unref (info->possible_formats); - if (info->format) - g_bytes_unref (info->format); } /** - * pinos_context_list_port_info: + * pinos_context_list_link_info: * @context: a connected #PinosContext - * @flags: extra #PinosPortInfoFlags - * @cb: a #PinosPortInfoCallback + * @flags: extra #PinosLinkInfoFlags + * @cb: a #PinosLinkInfoCallback * @cancelable: a #GCancellable * @callback: a #GAsyncReadyCallback to call when the operation is finished * @user_data: user data passed to @cb * - * Call @cb for each port. + * Call @cb for each link. */ void -pinos_context_list_port_info (PinosContext *context, - PinosPortInfoFlags flags, - PinosPortInfoCallback cb, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +pinos_context_list_link_info (PinosContext *context, + PinosLinkInfoFlags flags, + PinosLinkInfoCallback cb, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { PinosContextPrivate *priv; GList *walk; @@ -497,13 +484,13 @@ pinos_context_list_port_info (PinosContext *context, priv = context->priv; - for (walk = priv->ports; walk; walk = g_list_next (walk)) { + for (walk = priv->links; walk; walk = g_list_next (walk)) { GDBusProxy *proxy = walk->data; - PinosPortInfo info; + PinosLinkInfo info; - port_fill_info (&info, proxy); + link_fill_info (&info, proxy); cb (context, &info, user_data); - port_clear_info (&info); + link_clear_info (&info); } g_task_return_boolean (task, TRUE); @@ -511,27 +498,27 @@ pinos_context_list_port_info (PinosContext *context, } /** - * pinos_context_get_port_info_by_id: + * pinos_context_get_link_info_by_id: * @context: a connected #PinosContext - * @id: a port id - * @flags: extra #PinosPortInfoFlags - * @cb: a #PinosPortInfoCallback + * @id: a link id + * @flags: extra #PinosLinkInfoFlags + * @cb: a #PinosLinkInfoCallback * @cancelable: a #GCancellable * @callback: a #GAsyncReadyCallback to call when the operation is finished * @user_data: user data passed to @cb * - * Call @cb for the port with @id. + * Call @cb for the link with @id. */ void -pinos_context_get_port_info_by_id (PinosContext *context, +pinos_context_get_link_info_by_id (PinosContext *context, gpointer id, - PinosPortInfoFlags flags, - PinosPortInfoCallback cb, + PinosLinkInfoFlags flags, + PinosLinkInfoCallback cb, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { - PinosPortInfo info; + PinosLinkInfo info; GDBusProxy *proxy; GTask *task; @@ -543,270 +530,9 @@ pinos_context_get_port_info_by_id (PinosContext *context, proxy = G_DBUS_PROXY (id); - port_fill_info (&info, proxy); + link_fill_info (&info, proxy); cb (context, &info, user_data); - port_clear_info (&info); - - g_task_return_boolean (task, TRUE); - g_object_unref (task); -} - -/** - * pinos_port_state_as_string: - * @state: a #PinosPortState - * - * Return the string representation of @state. - * - * Returns: the string representation of @state. - */ -const gchar * -pinos_port_state_as_string (PinosPortState state) -{ - GEnumValue *val; - - val = g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (PINOS_TYPE_PORT_STATE)), - state); - - return val == NULL ? "invalid-state" : val->value_nick; -} - -/** - * pinos_channel_state_as_string: - * @state: a #PinosChannelState - * - * Return the string representation of @state. - * - * Returns: the string representation of @state. - */ -const gchar * -pinos_channel_state_as_string (PinosChannelState state) -{ - GEnumValue *val; - - val = g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (PINOS_TYPE_CHANNEL_STATE)), - state); - - return val == NULL ? "invalid-state" : val->value_nick; -} - -static void -channel_fill_info (PinosChannelInfo *info, GDBusProxy *proxy) -{ - GHashTable *changed = g_object_get_data (G_OBJECT (proxy), "pinos-changed-properties"); - - info->id = proxy; - info->channel_path = g_dbus_proxy_get_object_path (proxy); - SET_UINT32 ("Direction", direction, 2, PINOS_DIRECTION_INVALID); - SET_STRING ("Client", client_path, 0); - - info->change_mask = 0; - SET_STRING ("Port", port_path, 0); - SET_PROPERTIES ("Properties", properties, 1); - SET_UINT32 ("State", state, 2, PINOS_CHANNEL_STATE_ERROR); - SET_BYTES ("PossibleFormats", possible_formats, 3); - SET_BYTES ("Format", format, 4); - - if (changed) - g_hash_table_remove_all (changed); -} - -static void -channel_clear_info (PinosChannelInfo *info) -{ - if (info->possible_formats) - g_bytes_unref (info->possible_formats); - if (info->format) - g_bytes_unref (info->format); - if (info->properties) - pinos_properties_free (info->properties); -} - - -/** - * pinos_context_list_channel_info: - * @context: a connected #PinosContext - * @flags: extra #PinosChannelInfoFlags - * @cb: a #PinosChannelInfoCallback - * @cancelable: a #GCancellable - * @callback: a #GAsyncReadyCallback to call when the operation is finished - * @user_data: user data passed to @cb - * - * Call @cb for each channel. - */ -void -pinos_context_list_channel_info (PinosContext *context, - PinosChannelInfoFlags flags, - PinosChannelInfoCallback cb, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) -{ - PinosContextPrivate *priv; - GList *walk; - GTask *task; - - g_return_if_fail (PINOS_IS_CONTEXT (context)); - g_return_if_fail (cb != NULL); - - task = g_task_new (context, cancellable, callback, user_data); - - priv = context->priv; - - for (walk = priv->channels; walk; walk = g_list_next (walk)) { - GDBusProxy *proxy = walk->data; - PinosChannelInfo info; - - channel_fill_info (&info, proxy); - cb (context, &info, user_data); - channel_clear_info (&info); - } - - g_task_return_boolean (task, TRUE); - g_object_unref (task); -} - -/** - * pinos_context_get_channel_info_by_id: - * @context: a connected #PinosContext - * @id: a channel id - * @flags: extra #PinosChannelInfoFlags - * @cb: a #PinosChannelInfoCallback - * @cancelable: a #GCancellable - * @callback: a #GAsyncReadyCallback to call when the operation is finished - * @user_data: user data passed to @cb - * - * Call @cb for the channel with @id. - */ -void -pinos_context_get_channel_info_by_id (PinosContext *context, - gpointer id, - PinosChannelInfoFlags flags, - PinosChannelInfoCallback cb, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) -{ - PinosChannelInfo info; - GDBusProxy *proxy; - GTask *task; - - g_return_if_fail (PINOS_IS_CONTEXT (context)); - g_return_if_fail (id != NULL); - g_return_if_fail (cb != NULL); - - task = g_task_new (context, cancellable, callback, user_data); - - proxy = G_DBUS_PROXY (id); - - channel_fill_info (&info, proxy); - cb (context, &info, user_data); - channel_clear_info (&info); - - g_task_return_boolean (task, TRUE); - g_object_unref (task); -} - - -static void -connection_fill_info (PinosConnectionInfo *info, GDBusProxy *proxy) -{ - GHashTable *changed = g_object_get_data (G_OBJECT (proxy), "pinos-changed-properties"); - - info->id = proxy; - info->connection_path = g_dbus_proxy_get_object_path (proxy); - - info->change_mask = 0; - SET_STRING ("SourcePort", source_port_path, 0); - SET_STRING ("DestinationPort", destination_port_path, 1); - - if (changed) - g_hash_table_remove_all (changed); -} - -static void -connection_clear_info (PinosConnectionInfo *info) -{ -} - -/** - * pinos_context_list_connection_info: - * @context: a connected #PinosContext - * @flags: extra #PinosConnectionInfoFlags - * @cb: a #PinosConnectionInfoCallback - * @cancelable: a #GCancellable - * @callback: a #GAsyncReadyCallback to call when the operation is finished - * @user_data: user data passed to @cb - * - * Call @cb for each connection. - */ -void -pinos_context_list_connection_info (PinosContext *context, - PinosConnectionInfoFlags flags, - PinosConnectionInfoCallback cb, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) -{ - PinosContextPrivate *priv; - GList *walk; - GTask *task; - - g_return_if_fail (PINOS_IS_CONTEXT (context)); - g_return_if_fail (cb != NULL); - - task = g_task_new (context, cancellable, callback, user_data); - - priv = context->priv; - - for (walk = priv->connections; walk; walk = g_list_next (walk)) { - GDBusProxy *proxy = walk->data; - PinosConnectionInfo info; - - connection_fill_info (&info, proxy); - cb (context, &info, user_data); - connection_clear_info (&info); - } - - g_task_return_boolean (task, TRUE); - g_object_unref (task); -} - -/** - * pinos_context_get_connection_info_by_id: - * @context: a connected #PinosContext - * @id: a connection id - * @flags: extra #PinosConnectionInfoFlags - * @cb: a #PinosConnectionInfoCallback - * @cancelable: a #GCancellable - * @callback: a #GAsyncReadyCallback to call when the operation is finished - * @user_data: user data passed to @cb - * - * Call @cb for the connection with @id. - */ -void -pinos_context_get_connection_info_by_id (PinosContext *context, - gpointer id, - PinosConnectionInfoFlags flags, - PinosConnectionInfoCallback cb, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) -{ - PinosConnectionInfo info; - GDBusProxy *proxy; - GTask *task; - - g_return_if_fail (PINOS_IS_CONTEXT (context)); - g_return_if_fail (id != NULL); - g_return_if_fail (cb != NULL); - - task = g_task_new (context, cancellable, callback, user_data); - - proxy = G_DBUS_PROXY (id); - - connection_fill_info (&info, proxy); - cb (context, &info, user_data); - connection_clear_info (&info); + link_clear_info (&info); g_task_return_boolean (task, TRUE); g_object_unref (task); diff --git a/pinos/client/introspect.h b/pinos/client/introspect.h index 70fdde2ce..fc8aa9945 100644 --- a/pinos/client/introspect.h +++ b/pinos/client/introspect.h @@ -64,24 +64,6 @@ typedef enum { const gchar * pinos_direction_as_string (PinosDirection direction); -/** - * PinosPortState: - * @PINOS_PORT_STATE_ERROR: the port is in error - * @PINOS_PORT_STATE_STOPPED: the port is stopped - * @PINOS_PORT_STATE_STARTING: the port is starting - * @PINOS_PORT_STATE_STREAMING: the port is streaming - * - * The different port states - */ -typedef enum { - PINOS_PORT_STATE_ERROR = -1, - PINOS_PORT_STATE_STOPPED = 0, - PINOS_PORT_STATE_STARTING = 1, - PINOS_PORT_STATE_STREAMING = 2, -} PinosPortState; - -const gchar * pinos_port_state_as_string (PinosPortState state); - #include #include @@ -261,217 +243,60 @@ void pinos_context_get_node_info_by_id (PinosContext *context, /** - * PinosPortInfo: - * @id: generic id of the port - * @port_path: the unique path of the port, suitable for connecting - * @node_path: the node path of the port - * @direction: the direction of the port - * @change_mask: bitfield of changed fields since last call - * @name: name the port, suitable for display - * @peers: paths to peer ports - * @properties: the properties of the port - * @possible_formats: the possible formats this port can consume - * @format: the current format on this port - * - * The port information. Extra information can be added in later - * versions. - */ -typedef struct { - gpointer id; - const char *port_path; - const char *node_path; - PinosDirection direction; - guint64 change_mask; - const char *name; - PinosProperties *properties; - gchar **peers; - GBytes *possible_formats; - GBytes *format; -} PinosPortInfo; - -/** - * PinosPortInfoFlags: - * @PINOS_PORT_INFO_FLAGS_NONE: no flags - * @PINOS_PORT_INFO_FLAGS_FORMATS: include formats - * - * Extra flags to pass to pinos_context_get_port_info_list. - */ -typedef enum { - PINOS_PORT_INFO_FLAGS_NONE = 0, - PINOS_PORT_INFO_FLAGS_FORMATS = (1 << 0) -} PinosPortInfoFlags; - -/** - * PinosPortInfoCallback: - * @c: a #PinosContext - * @info: a #PinosPortInfo - * @user_data: user data - * - * Callback with information about the Pinos port in @info. - */ -typedef void (*PinosPortInfoCallback) (PinosContext *c, - const PinosPortInfo *info, - gpointer user_data); - -void pinos_context_list_port_info (PinosContext *context, - PinosPortInfoFlags flags, - PinosPortInfoCallback cb, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -void pinos_context_get_port_info_by_id (PinosContext *context, - gpointer id, - PinosPortInfoFlags flags, - PinosPortInfoCallback cb, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - - -/** - * PinosChannelState: - * @PINOS_CHANNEL_STATE_ERROR: the channel is in error - * @PINOS_CHANNEL_STATE_STOPPED: the channel is stopped - * @PINOS_CHANNEL_STATE_STARTING: the channel is starting - * @PINOS_CHANNEL_STATE_STREAMING: the channel is streaming - * - * The different channel states - */ -typedef enum { - PINOS_CHANNEL_STATE_ERROR = -1, - PINOS_CHANNEL_STATE_STOPPED = 0, - PINOS_CHANNEL_STATE_STARTING = 1, - PINOS_CHANNEL_STATE_STREAMING = 2, -} PinosChannelState; - -const gchar * pinos_channel_state_as_string (PinosChannelState state); - -/** - * PinosChannelInfo: - * @id: generic id of the channel_ - * @channel_path: the unique path of the channel - * @direction: the channel direction - * @client_path: the owner client - * @change_mask: bitfield of changed fields since last call - * @port_path: the owner port - * @properties: the properties of the channel - * @state: the state - * @possible_formats: the possible formats - * @format: when streaming, the current format - * - * The channel information. Extra information can be added in later - * versions. - */ -typedef struct { - gpointer id; - const char *channel_path; - PinosDirection direction; - const char *client_path; - guint64 change_mask; - const char *port_path; - PinosProperties *properties; - PinosChannelState state; - GBytes *possible_formats; - GBytes *format; -} PinosChannelInfo; - -/** - * PinosChannelInfoFlags: - * @PINOS_CHANNEL_INFO_FLAGS_NONE: no flags - * @PINOS_CHANNEL_INFO_FLAGS_NO_INPUT: don't list input channels - * @PINOS_CHANNEL_INFO_FLAGS_NO_OUTPUT: don't list output channels - * - * Extra flags to pass to pinos_context_list_channel_info() and - * pinos_context_get_channel_info_by_id(). - */ -typedef enum { - PINOS_CHANNEL_INFO_FLAGS_NONE = 0, - PINOS_CHANNEL_INFO_FLAGS_NO_INPUT = (1 << 0), - PINOS_CHANNEL_INFO_FLAGS_NO_OUTPUT = (1 << 1), -} PinosChannelInfoFlags; - - -/** - * PinosChannelInfoCallback: - * @c: a #PinosContext - * @info: a #PinosChannelInfo - * @user_data: user data - * - * Callback with information about the Pinos channel in @info. - */ -typedef void (*PinosChannelInfoCallback) (PinosContext *c, - const PinosChannelInfo *info, - gpointer user_data); - -void pinos_context_list_channel_info (PinosContext *context, - PinosChannelInfoFlags flags, - PinosChannelInfoCallback cb, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -void pinos_context_get_channel_info_by_id (PinosContext *context, - gpointer id, - PinosChannelInfoFlags flags, - PinosChannelInfoCallback cb, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -/** - * PinosConnectionInfo: - * @id: generic id of the connection - * @connection_path: the unique path of the connection + * PinosLinkInfo: + * @id: generic id of the link + * @link_path: the unique path of the link * @change_mask: bitfield of changed fields since last call * @source_port_path: the source port * @destination_port_path: the destination port * - * The connection information. Extra information can be added in later + * The link information. Extra information can be added in later * versions. */ typedef struct { gpointer id; - const char *connection_path; + const char *link_path; guint64 change_mask; const char *source_port_path; const char *destination_port_path; -} PinosConnectionInfo; +} PinosLinkInfo; /** - * PinosConnectionInfoFlags: - * @PINOS_CONNECTION_INFO_FLAGS_NONE: no flags + * PinosLinkInfoFlags: + * @PINOS_LINK_INFO_FLAGS_NONE: no flags * - * Extra flags to pass to pinos_context_list_connection_info() and - * pinos_context_get_connection_info_by_id(). + * Extra flags to pass to pinos_context_list_link_info() and + * pinos_context_get_link_info_by_id(). */ typedef enum { - PINOS_CONNECTION_INFO_FLAGS_NONE = 0, -} PinosConnectionInfoFlags; + PINOS_LINK_INFO_FLAGS_NONE = 0, +} PinosLinkInfoFlags; /** - * PinosConnectionInfoCallback: + * PinosLinkInfoCallback: * @c: a #PinosContext - * @info: a #PinosConnectionInfo + * @info: a #PinosLinkInfo * @user_data: user data * - * Callback with information about the Pinos connection in @info. + * Callback with information about the Pinos link in @info. */ -typedef void (*PinosConnectionInfoCallback) (PinosContext *c, - const PinosConnectionInfo *info, - gpointer user_data); +typedef void (*PinosLinkInfoCallback) (PinosContext *c, + const PinosLinkInfo *info, + gpointer user_data); -void pinos_context_list_connection_info (PinosContext *context, - PinosConnectionInfoFlags flags, - PinosConnectionInfoCallback cb, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -void pinos_context_get_connection_info_by_id (PinosContext *context, - gpointer id, - PinosConnectionInfoFlags flags, - PinosConnectionInfoCallback cb, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); +void pinos_context_list_link_info (PinosContext *context, + PinosLinkInfoFlags flags, + PinosLinkInfoCallback cb, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +void pinos_context_get_link_info_by_id (PinosContext *context, + gpointer id, + PinosLinkInfoFlags flags, + PinosLinkInfoCallback cb, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); G_END_DECLS #endif /* __PINOS_INTROSPECT_H__ */ diff --git a/pinos/client/private.h b/pinos/client/private.h index 0869f83ea..e072c8b5d 100644 --- a/pinos/client/private.h +++ b/pinos/client/private.h @@ -40,9 +40,7 @@ struct _PinosContextPrivate GList *clients; GList *nodes; - GList *ports; - GList *connections; - GList *channels; + GList *links; }; void pinos_subscribe_get_proxy (PinosSubscribe *subscribe, diff --git a/pinos/client/stream.c b/pinos/client/stream.c index ec9890fbd..51bffbd7f 100644 --- a/pinos/client/stream.c +++ b/pinos/client/stream.c @@ -240,14 +240,14 @@ subscription_cb (PinosSubscribe *subscribe, PinosStreamPrivate *priv = stream->priv; switch (flags) { - case PINOS_SUBSCRIPTION_FLAG_CHANNEL: + case PINOS_SUBSCRIPTION_FLAG_NODE: if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE) { if (object == priv->node && !priv->disconnecting) { stream_set_state (stream, PINOS_STREAM_STATE_ERROR, g_error_new_literal (G_IO_ERROR, G_IO_ERROR_CLOSED, - "Channel disappeared")); + "Node disappeared")); } } break; @@ -888,7 +888,7 @@ do_node_init (PinosStream *stream) pu.direction = priv->direction; pu.n_possible_formats = priv->possible_formats->len; - pu.possible_formats = (const SpaFormat **)priv->possible_formats->pdata; + pu.possible_formats = (SpaFormat **)priv->possible_formats->pdata; pu.props = NULL; pu.info = &priv->port_info; priv->port_info.flags = SPA_PORT_INFO_FLAG_NONE | diff --git a/pinos/client/subscribe.c b/pinos/client/subscribe.c index 87dd69e96..ca2eb0a38 100644 --- a/pinos/client/subscribe.c +++ b/pinos/client/subscribe.c @@ -108,11 +108,8 @@ notify_event (PinosSubscribe *subscribe, else if (g_strcmp0 (interface_name, "org.pinos.Node1") == 0) { flags = PINOS_SUBSCRIPTION_FLAG_NODE; } - else if (g_strcmp0 (interface_name, "org.pinos.Port1") == 0) { - flags = PINOS_SUBSCRIPTION_FLAG_PORT; - } - else if (g_strcmp0 (interface_name, "org.pinos.Channel1") == 0) { - flags = PINOS_SUBSCRIPTION_FLAG_CHANNEL; + else if (g_strcmp0 (interface_name, "org.pinos.Link1") == 0) { + flags = PINOS_SUBSCRIPTION_FLAG_LINK; } g_signal_emit (subscribe, signals[SIGNAL_SUBSCRIPTION_EVENT], 0, event, flags, data->proxy); diff --git a/pinos/client/subscribe.h b/pinos/client/subscribe.h index 74c8ffbef..e6e7dd8cb 100644 --- a/pinos/client/subscribe.h +++ b/pinos/client/subscribe.h @@ -48,11 +48,10 @@ typedef enum { PINOS_SUBSCRIPTION_FLAG_DAEMON = (1 << 0), PINOS_SUBSCRIPTION_FLAG_CLIENT = (1 << 1), PINOS_SUBSCRIPTION_FLAG_NODE = (1 << 2), - PINOS_SUBSCRIPTION_FLAG_PORT = (1 << 3), - PINOS_SUBSCRIPTION_FLAG_CHANNEL = (1 << 4) + PINOS_SUBSCRIPTION_FLAG_LINK = (1 << 3) } PinosSubscriptionFlags; -#define PINOS_SUBSCRIPTION_FLAGS_ALL 0x1f +#define PINOS_SUBSCRIPTION_FLAGS_ALL 0x0f typedef enum { PINOS_SUBSCRIPTION_EVENT_NEW = 0, diff --git a/pinos/dbus/org.pinos.xml b/pinos/dbus/org.pinos.xml index a82651dd8..4ac68e5ce 100644 --- a/pinos/dbus/org.pinos.xml +++ b/pinos/dbus/org.pinos.xml @@ -53,8 +53,8 @@ - - + + @@ -132,8 +132,8 @@ - - + + diff --git a/pinos/server/link.c b/pinos/server/link.c index 86e56d65e..47d499905 100644 --- a/pinos/server/link.c +++ b/pinos/server/link.c @@ -358,6 +358,29 @@ on_deactivate (PinosPort *port, gpointer user_data) return TRUE; } +static void +on_property_notify (GObject *obj, + GParamSpec *pspec, + gpointer user_data) +{ + PinosLink *link = user_data; + PinosLinkPrivate *priv = link->priv; + + if (pspec == NULL || strcmp (g_param_spec_get_name (pspec), "output") == 0) { + gchar *port = g_strdup_printf ("%s:%d", pinos_node_get_object_path (priv->output->node), + priv->output->id); + pinos_link1_set_src_port (priv->iface, port); + g_free (port); + } + if (pspec == NULL || strcmp (g_param_spec_get_name (pspec), "input") == 0) { + gchar *port = g_strdup_printf ("%s:%d", pinos_node_get_object_path (priv->input->node), + priv->input->id); + pinos_link1_set_dest_port (priv->iface, port); + g_free (port); + } +} + + static void pinos_link_constructed (GObject * object) { @@ -380,10 +403,13 @@ pinos_link_constructed (GObject * object) g_signal_connect (priv->output, "activate", (GCallback) on_activate, link); g_signal_connect (priv->output, "deactivate", (GCallback) on_deactivate, link); - g_debug ("link %p: constructed", link); - link_register_object (link); + g_signal_connect (link, "notify", (GCallback) on_property_notify, link); G_OBJECT_CLASS (pinos_link_parent_class)->constructed (object); + + on_property_notify (G_OBJECT (link), NULL, link); + g_debug ("link %p: constructed", link); + link_register_object (link); } static void diff --git a/pinos/server/node.c b/pinos/server/node.c index b111d46d9..168952795 100644 --- a/pinos/server/node.c +++ b/pinos/server/node.c @@ -374,8 +374,8 @@ pinos_node_constructed (GObject * obj) if (priv->sender == NULL) { priv->sender = g_strdup (pinos_daemon_get_sender (priv->daemon)); - pinos_node1_set_owner (priv->iface, priv->sender); } + on_property_notify (G_OBJECT (node), NULL, node); node_register_object (node); } diff --git a/pinos/tools/pinos-monitor.c b/pinos/tools/pinos-monitor.c index 4fabbebe0..42157d871 100644 --- a/pinos/tools/pinos-monitor.c +++ b/pinos/tools/pinos-monitor.c @@ -23,60 +23,6 @@ static GMainLoop *loop; -static gboolean -print_field (GQuark field, const GValue * value, gpointer user_data) -{ - gchar *mark = user_data; - gchar *str = gst_value_serialize (value); - - g_print ("%c\t\t%15s: %s\n", *mark, g_quark_to_string (field), str); - g_free (str); - return TRUE; -} - -static void -print_formats (const gchar *name, GBytes *formats, gchar mark) -{ - GstCaps *caps = NULL; - guint i; - - if (formats == NULL) - goto done; - - caps = gst_caps_from_string (g_bytes_get_data (formats, NULL)); - g_print ("%c\t%s:\n", mark, name); - - if (gst_caps_is_any (caps)) { - g_print ("%c\t\tANY\n", mark); - goto done; - } - if (gst_caps_is_empty (caps)) { - g_print ("%c\t\tEMPTY\n", mark); - goto done; - } - for (i = 0; i < gst_caps_get_size (caps); i++) { - GstStructure *structure = gst_caps_get_structure (caps, i); - GstCapsFeatures *features = gst_caps_get_features (caps, i); - - if (features && (gst_caps_features_is_any (features) || - !gst_caps_features_is_equal (features, - GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY))) { - gchar *features_string = gst_caps_features_to_string (features); - - g_print ("%c\t\t%s(%s)\n", mark, gst_structure_get_name (structure), - features_string); - g_free (features_string); - } else { - g_print ("%c\t\t%s\n", mark, gst_structure_get_name (structure)); - } - gst_structure_foreach (structure, print_field, &mark); - } - -done: - if (caps) - gst_caps_unref (caps); -} - static void print_properties (PinosProperties *props, gchar mark) { @@ -92,32 +38,6 @@ print_properties (PinosProperties *props, gchar mark) } } -static void -print_peers (gchar **peers, gchar mark) -{ - GValue list = G_VALUE_INIT; - gint idx = 0; - gchar *str; - - g_value_init (&list, GST_TYPE_LIST); - - if (peers != NULL) { - while (peers[idx]) { - GValue peer = G_VALUE_INIT; - - g_value_init (&peer, G_TYPE_STRING); - g_value_set_string (&peer, peers[idx]); - gst_value_list_append_and_take_value (&list, &peer); - idx++; - } - } - - str = gst_value_serialize (&list); - g_print ("%c\tpeers: %s\n", mark, str); - g_free (str); - g_value_unset (&list); -} - static void info_ready (GObject *o, GAsyncResult *res, gpointer user_data) { @@ -182,56 +102,17 @@ dump_node_info (PinosContext *c, const PinosNodeInfo *info, gpointer user_data) } static void -dump_port_info (PinosContext *c, const PinosPortInfo *info, gpointer user_data) +dump_link_info (PinosContext *c, const PinosLinkInfo *info, gpointer user_data) { DumpData *data = user_data; g_print ("\tid: %p\n", info->id); - g_print ("\tport-path: \"%s\"\n", info->port_path); - if (data->print_all) { - g_print ("\tnode-path: \"%s\"\n", info->node_path); - g_print ("\tdirection: \"%s\"\n", pinos_direction_as_string (info->direction)); - g_print ("%c\tname: \"%s\"\n", MARK_CHANGE (0), info->name); - print_peers (info->peers, MARK_CHANGE (1)); - print_properties (info->properties, MARK_CHANGE (2)); - print_formats ("possible formats", info->possible_formats, MARK_CHANGE (3)); - print_formats ("format", info->format, MARK_CHANGE (4)); - } -} - -static void -dump_channel_info (PinosContext *c, const PinosChannelInfo *info, gpointer user_data) -{ - DumpData *data = user_data; - - g_print ("\tid: %p\n", info->id); - g_print ("\tchannel-path: \"%s\"\n", info->channel_path); - if (data->print_all) { - g_print ("\tdirection: \"%s\"\n", pinos_direction_as_string (info->direction)); - g_print ("\tclient-path: \"%s\"\n", info->client_path); - - g_print ("%c\tnode-path: \"%s\"\n", MARK_CHANGE (0), info->port_path); - print_properties (info->properties, MARK_CHANGE (1)); - g_print ("%c\tstate: \"%s\"\n", MARK_CHANGE (2), pinos_channel_state_as_string (info->state)); - print_formats ("possible formats", info->possible_formats, MARK_CHANGE (3)); - print_formats ("format", info->format, MARK_CHANGE (4)); - } -} - -#if 0 -static void -dump_connection_info (PinosContext *c, const PinosConnectionInfo *info, gpointer user_data) -{ - DumpData *data = user_data; - - g_print ("\tid: %p\n", info->id); - g_print ("\tconnection-path: \"%s\"\n", info->connection_path); + g_print ("\tlink-path: \"%s\"\n", info->link_path); if (data->print_all) { g_print ("%c\tsource-port-path: \"%s\"\n", MARK_CHANGE (0), info->source_port_path); g_print ("%c\tdestination-port-path: \"%s\"\n", MARK_CHANGE (1), info->destination_port_path); } } -#endif static void dump_object (PinosContext *context, gpointer id, PinosSubscriptionFlags flags, @@ -263,24 +144,15 @@ dump_object (PinosContext *context, gpointer id, PinosSubscriptionFlags flags, info_ready, data); } - else if (flags & PINOS_SUBSCRIPTION_FLAG_PORT) { - pinos_context_get_port_info_by_id (context, + else if (flags & PINOS_SUBSCRIPTION_FLAG_LINK) { + pinos_context_get_link_info_by_id (context, id, - PINOS_PORT_INFO_FLAGS_FORMATS, - dump_port_info, + PINOS_LINK_INFO_FLAGS_NONE, + dump_link_info, NULL, info_ready, data); } - else if (flags & PINOS_SUBSCRIPTION_FLAG_CHANNEL) { - pinos_context_get_channel_info_by_id (context, - id, - PINOS_CHANNEL_INFO_FLAGS_NONE, - dump_channel_info, - NULL, - info_ready, - data); - } } static void diff --git a/spa/include/spa/format.h b/spa/include/spa/format.h index e6f0ea083..f52d60e68 100644 --- a/spa/include/spa/format.h +++ b/spa/include/spa/format.h @@ -89,7 +89,6 @@ typedef enum { SPA_PROP_ID_MEDIA_CUSTOM_START = 200, } SpaFormatProps; - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/spa/include/spa/node.h b/spa/include/spa/node.h index 65da279ec..9800441cc 100644 --- a/spa/include/spa/node.h +++ b/spa/include/spa/node.h @@ -118,6 +118,7 @@ typedef enum { * @buffer_id: a buffer id will be set * @offset: offset to get * @size: size to get + * @event: output event * @status: a status * * Output information for a node. @@ -128,6 +129,7 @@ typedef struct { uint32_t buffer_id; off_t offset; size_t size; + SpaEvent *event; SpaResult status; } SpaOutputInfo; diff --git a/spa/lib/format.c b/spa/lib/format.c index acc70d9f9..e3b898bda 100644 --- a/spa/lib/format.c +++ b/spa/lib/format.c @@ -32,9 +32,5 @@ spa_format_to_string (const SpaFormat *format, char **result) if (format == NULL || result == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - - - - return SPA_RESULT_OK; } diff --git a/spa/lib/props.c b/spa/lib/props.c index dce475c5e..9dc331097 100644 --- a/spa/lib/props.c +++ b/spa/lib/props.c @@ -44,8 +44,7 @@ spa_props_set_prop (SpaProps *props, if (info->maxsize < value->size) return SPA_RESULT_WRONG_PROPERTY_SIZE; - if (info->offset != 0) - memcpy ((uint8_t*)props + info->offset, value->value, value->size); + memcpy (SPA_MEMBER (props, info->offset, void), value->value, value->size); props->unset_mask &= ~(1u << index); @@ -74,8 +73,7 @@ spa_props_get_prop (const SpaProps *props, value->type = info->type; value->size = info->maxsize; - if (info->offset != 0) - value->value = (uint8_t*)props + info->offset; + value->value = SPA_MEMBER (props, info->offset, void); return SPA_RESULT_OK; } @@ -103,8 +101,7 @@ spa_props_copy (const SpaProps *src, if (value.size > info->maxsize) return SPA_RESULT_WRONG_PROPERTY_SIZE; - if (info->offset) - memcpy ((uint8_t*)dest + info->offset, value.value, value.size); + memcpy (SPA_MEMBER (dest, info->offset, void), value.value, value.size); dest->unset_mask &= ~(1u << i); }