mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
pass the client object around
Pass the client object around, it's easier to deal with than the sender id. Fix the ASYNC return check Don't overwrite the fds of a pollitem, instead keep an index of their position in the global fd array.
This commit is contained in:
parent
7b53fa8685
commit
c6861845a7
14 changed files with 123 additions and 79 deletions
|
|
@ -274,7 +274,7 @@ make_node (SpaNode **node, const char *lib, const char *name)
|
|||
/**
|
||||
* pinos_client_node_new:
|
||||
* @daemon: a #PinosDaemon
|
||||
* @sender: the path of the owner
|
||||
* @client: the client owner
|
||||
* @name: a name
|
||||
* @properties: extra properties
|
||||
*
|
||||
|
|
@ -284,7 +284,7 @@ make_node (SpaNode **node, const char *lib, const char *name)
|
|||
*/
|
||||
PinosNode *
|
||||
pinos_client_node_new (PinosDaemon *daemon,
|
||||
const gchar *sender,
|
||||
PinosClient *client,
|
||||
const gchar *name,
|
||||
PinosProperties *properties)
|
||||
{
|
||||
|
|
@ -302,7 +302,7 @@ pinos_client_node_new (PinosDaemon *daemon,
|
|||
|
||||
return g_object_new (PINOS_TYPE_CLIENT_NODE,
|
||||
"daemon", daemon,
|
||||
"sender", sender,
|
||||
"client", client,
|
||||
"name", name,
|
||||
"properties", properties,
|
||||
"node", n,
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ struct _PinosClientNodeClass {
|
|||
GType pinos_client_node_get_type (void);
|
||||
|
||||
PinosNode * pinos_client_node_new (PinosDaemon *daemon,
|
||||
const gchar *sender,
|
||||
PinosClient *client,
|
||||
const gchar *name,
|
||||
PinosProperties *properties);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,10 +22,14 @@
|
|||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include <pinos/server/daemon.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _PinosClient PinosClient;
|
||||
typedef struct _PinosClientClass PinosClientClass;
|
||||
typedef struct _PinosClientPrivate PinosClientPrivate;
|
||||
|
||||
#include <pinos/server/daemon.h>
|
||||
|
||||
#define PINOS_TYPE_CLIENT (pinos_client_get_type ())
|
||||
#define PINOS_IS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_CLIENT))
|
||||
#define PINOS_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_CLIENT))
|
||||
|
|
@ -35,10 +39,6 @@ G_BEGIN_DECLS
|
|||
#define PINOS_CLIENT_CAST(obj) ((PinosClient*)(obj))
|
||||
#define PINOS_CLIENT_CLASS_CAST(klass) ((PinosClientClass*)(klass))
|
||||
|
||||
typedef struct _PinosClient PinosClient;
|
||||
typedef struct _PinosClientClass PinosClientClass;
|
||||
typedef struct _PinosClientPrivate PinosClientPrivate;
|
||||
|
||||
/**
|
||||
* PinosClient:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ struct _PinosDaemonPrivate
|
|||
GDBusConnection *connection;
|
||||
GDBusObjectManagerServer *server_manager;
|
||||
|
||||
gchar *object_path;
|
||||
|
||||
GList *nodes;
|
||||
|
||||
GHashTable *clients;
|
||||
|
|
@ -60,6 +62,7 @@ enum
|
|||
PROP_0,
|
||||
PROP_CONNECTION,
|
||||
PROP_PROPERTIES,
|
||||
PROP_OBJECT_PATH,
|
||||
};
|
||||
|
||||
static void
|
||||
|
|
@ -135,6 +138,7 @@ handle_create_node (PinosDaemon1 *interface,
|
|||
PinosProperties *props;
|
||||
|
||||
sender = g_dbus_method_invocation_get_sender (invocation);
|
||||
client = sender_get_client (daemon, sender, TRUE);
|
||||
|
||||
g_debug ("daemon %p: create node: %s", daemon, sender);
|
||||
|
||||
|
|
@ -144,12 +148,12 @@ handle_create_node (PinosDaemon1 *interface,
|
|||
if (factory != NULL) {
|
||||
node = pinos_node_factory_create_node (factory,
|
||||
daemon,
|
||||
sender,
|
||||
client,
|
||||
arg_name,
|
||||
props);
|
||||
} else {
|
||||
node = pinos_node_new (daemon,
|
||||
sender,
|
||||
client,
|
||||
arg_name,
|
||||
props,
|
||||
NULL);
|
||||
|
|
@ -160,7 +164,6 @@ handle_create_node (PinosDaemon1 *interface,
|
|||
if (node == NULL)
|
||||
goto no_node;
|
||||
|
||||
client = sender_get_client (daemon, sender, TRUE);
|
||||
pinos_client_add_object (client, G_OBJECT (node));
|
||||
|
||||
g_signal_connect (node,
|
||||
|
|
@ -189,7 +192,7 @@ no_node:
|
|||
static void
|
||||
on_link_state_notify (GObject *obj,
|
||||
GParamSpec *pspec,
|
||||
PinosClient *client)
|
||||
PinosDaemon *daemon)
|
||||
{
|
||||
PinosLink *link = PINOS_LINK (obj);
|
||||
GError *error = NULL;
|
||||
|
|
@ -198,17 +201,20 @@ on_link_state_notify (GObject *obj,
|
|||
state = pinos_link_get_state (link, &error);
|
||||
switch (state) {
|
||||
case PINOS_LINK_STATE_ERROR:
|
||||
g_warning ("link %p: state error: %s", link, error->message);
|
||||
{
|
||||
g_warning ("daemon %p: link %p: state error: %s", daemon, link, error->message);
|
||||
|
||||
if (link->input_node && pinos_client_has_object (client, G_OBJECT (link->input_node))) {
|
||||
if (link->input_node) {
|
||||
pinos_node_report_error (link->input_node, g_error_copy (error));
|
||||
}
|
||||
if (link->output_node && pinos_client_has_object (client, G_OBJECT (link->output_node))) {
|
||||
if (link->output_node) {
|
||||
pinos_node_report_error (link->output_node, g_error_copy (error));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case PINOS_LINK_STATE_UNLINKED:
|
||||
g_warning ("link %p: unlinked", link);
|
||||
g_warning ("daemon %p: link %p: unlinked", daemon, link);
|
||||
break;
|
||||
case PINOS_LINK_STATE_INIT:
|
||||
case PINOS_LINK_STATE_NEGOTIATING:
|
||||
|
|
@ -236,7 +242,6 @@ on_port_added (PinosNode *node, PinosDirection direction, PinosDaemon *this)
|
|||
path = pinos_properties_get (props, "pinos.target.node");
|
||||
|
||||
if (path) {
|
||||
const gchar *sender;
|
||||
guint target_port;
|
||||
guint node_port;
|
||||
|
||||
|
|
@ -275,8 +280,8 @@ on_port_added (PinosNode *node, PinosDirection direction, PinosDaemon *this)
|
|||
if (link == NULL)
|
||||
goto error;
|
||||
|
||||
sender = pinos_node_get_sender (node);
|
||||
if (sender && (client = sender_get_client (this, sender, FALSE))) {
|
||||
client = pinos_node_get_client (node);
|
||||
if (client) {
|
||||
pinos_client_add_object (client, G_OBJECT (link));
|
||||
}
|
||||
|
||||
|
|
@ -370,12 +375,13 @@ handle_create_client_node (PinosDaemon1 *interface,
|
|||
gint fdidx;
|
||||
|
||||
sender = g_dbus_method_invocation_get_sender (invocation);
|
||||
client = sender_get_client (daemon, sender, TRUE);
|
||||
|
||||
g_debug ("daemon %p: create client-node: %s", daemon, sender);
|
||||
props = pinos_properties_from_variant (arg_properties);
|
||||
|
||||
node = pinos_client_node_new (daemon,
|
||||
sender,
|
||||
client,
|
||||
arg_name,
|
||||
props);
|
||||
pinos_properties_free (props);
|
||||
|
|
@ -384,7 +390,6 @@ handle_create_client_node (PinosDaemon1 *interface,
|
|||
if (socket == NULL)
|
||||
goto no_socket;
|
||||
|
||||
client = sender_get_client (daemon, sender, TRUE);
|
||||
pinos_client_add_object (client, G_OBJECT (node));
|
||||
|
||||
object_path = pinos_node_get_object_path (PINOS_NODE (node));
|
||||
|
|
@ -427,6 +432,8 @@ export_server_object (PinosDaemon *daemon,
|
|||
pinos_object_skeleton_set_daemon1 (skel, priv->iface);
|
||||
|
||||
g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (skel));
|
||||
g_free (priv->object_path);
|
||||
priv->object_path = g_strdup (g_dbus_object_get_object_path (G_DBUS_OBJECT (skel)));
|
||||
g_object_unref (skel);
|
||||
}
|
||||
|
||||
|
|
@ -464,6 +471,7 @@ name_lost_handler (GDBusConnection *connection,
|
|||
|
||||
g_dbus_object_manager_server_unexport (manager, PINOS_DBUS_OBJECT_SERVER);
|
||||
g_dbus_object_manager_server_set_connection (manager, connection);
|
||||
g_clear_pointer (&priv->object_path, g_free);
|
||||
priv->connection = connection;
|
||||
}
|
||||
|
||||
|
|
@ -482,20 +490,14 @@ pinos_daemon_new (PinosProperties *properties)
|
|||
}
|
||||
|
||||
const gchar *
|
||||
pinos_daemon_get_sender (PinosDaemon *daemon)
|
||||
pinos_daemon_get_object_path (PinosDaemon *daemon)
|
||||
{
|
||||
PinosDaemonPrivate *priv;
|
||||
const gchar *res;
|
||||
|
||||
g_return_val_if_fail (PINOS_IS_DAEMON (daemon), NULL);
|
||||
priv = daemon->priv;
|
||||
|
||||
if (priv->connection)
|
||||
res = g_dbus_connection_get_unique_name (priv->connection);
|
||||
else
|
||||
res = NULL;
|
||||
|
||||
return res;
|
||||
return priv->object_path;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -702,6 +704,10 @@ pinos_daemon_get_property (GObject *_object,
|
|||
g_value_set_object (value, priv->connection);
|
||||
break;
|
||||
|
||||
case PROP_OBJECT_PATH:
|
||||
g_value_set_string (value, priv->object_path);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (daemon, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -808,6 +814,15 @@ pinos_daemon_class_init (PinosDaemonClass * klass)
|
|||
G_PARAM_CONSTRUCT |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_OBJECT_PATH,
|
||||
g_param_spec_string ("object-path",
|
||||
"Object Path",
|
||||
"The object path",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ struct _PinosDaemonClass {
|
|||
GType pinos_daemon_get_type (void);
|
||||
|
||||
PinosDaemon * pinos_daemon_new (PinosProperties *properties);
|
||||
const gchar * pinos_daemon_get_sender (PinosDaemon *daemon);
|
||||
const gchar * pinos_daemon_get_object_path (PinosDaemon *daemon);
|
||||
|
||||
void pinos_daemon_start (PinosDaemon *daemon);
|
||||
void pinos_daemon_stop (PinosDaemon *daemon);
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ pinos_node_factory_get_name (PinosNodeFactory *factory)
|
|||
* pinos_node_factory_create_node:
|
||||
* @factory: A #PinosNodeFactory
|
||||
* @daemon: a #PinosDaemon
|
||||
* @sender: the path of the owner
|
||||
* @client: the owner client
|
||||
* @name: node name
|
||||
* @props: #PinosProperties for the node
|
||||
*
|
||||
|
|
@ -164,7 +164,7 @@ pinos_node_factory_get_name (PinosNodeFactory *factory)
|
|||
PinosNode *
|
||||
pinos_node_factory_create_node (PinosNodeFactory *factory,
|
||||
PinosDaemon *daemon,
|
||||
const gchar *sender,
|
||||
PinosClient *client,
|
||||
const gchar *name,
|
||||
PinosProperties *props)
|
||||
{
|
||||
|
|
@ -177,5 +177,5 @@ pinos_node_factory_create_node (PinosNodeFactory *factory,
|
|||
return NULL;
|
||||
|
||||
g_debug ("node factory %p: create node", factory);
|
||||
return klass->create_node (factory, daemon, sender, name, props);
|
||||
return klass->create_node (factory, daemon, client, name, props);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ typedef struct _PinosNodeFactoryClass PinosNodeFactoryClass;
|
|||
typedef struct _PinosNodeFactoryPrivate PinosNodeFactoryPrivate;
|
||||
|
||||
#include <pinos/server/daemon.h>
|
||||
#include <pinos/server/client.h>
|
||||
|
||||
#define PINOS_TYPE_NODE_FACTORY (pinos_node_factory_get_type ())
|
||||
#define PINOS_IS_NODE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_NODE_FACTORY))
|
||||
|
|
@ -61,7 +62,7 @@ struct _PinosNodeFactoryClass {
|
|||
|
||||
PinosNode * (*create_node) (PinosNodeFactory *factory,
|
||||
PinosDaemon *daemon,
|
||||
const gchar *sender,
|
||||
PinosClient *client,
|
||||
const gchar *name,
|
||||
PinosProperties *properties);
|
||||
};
|
||||
|
|
@ -69,13 +70,14 @@ struct _PinosNodeFactoryClass {
|
|||
/* normal GObject stuff */
|
||||
GType pinos_node_factory_get_type (void);
|
||||
|
||||
const gchar * pinos_node_factory_get_name (PinosNodeFactory *node_factory);
|
||||
PinosNode * pinos_node_factory_create_node (PinosNodeFactory *factory,
|
||||
PinosDaemon *daemon,
|
||||
const gchar *sender,
|
||||
PinosClient *client,
|
||||
const gchar *name,
|
||||
PinosProperties *props);
|
||||
|
||||
const gchar * pinos_node_factory_get_name (PinosNodeFactory *node_factory);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __PINOS_NODE_FACTORY_H__ */
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ struct _PinosNodePrivate
|
|||
PinosDaemon *daemon;
|
||||
PinosNode1 *iface;
|
||||
|
||||
gchar *sender;
|
||||
PinosClient *client;
|
||||
gchar *object_path;
|
||||
gchar *name;
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ enum
|
|||
{
|
||||
PROP_0,
|
||||
PROP_DAEMON,
|
||||
PROP_SENDER,
|
||||
PROP_CLIENT,
|
||||
PROP_RTLOOP,
|
||||
PROP_OBJECT_PATH,
|
||||
PROP_NAME,
|
||||
|
|
@ -513,8 +513,8 @@ pinos_node_get_property (GObject *_object,
|
|||
g_value_set_object (value, priv->daemon);
|
||||
break;
|
||||
|
||||
case PROP_SENDER:
|
||||
g_value_set_string (value, priv->sender);
|
||||
case PROP_CLIENT:
|
||||
g_value_set_object (value, priv->client);
|
||||
break;
|
||||
|
||||
case PROP_RTLOOP:
|
||||
|
|
@ -557,8 +557,8 @@ pinos_node_set_property (GObject *_object,
|
|||
priv->daemon = g_value_dup_object (value);
|
||||
break;
|
||||
|
||||
case PROP_SENDER:
|
||||
priv->sender = g_value_dup_string (value);
|
||||
case PROP_CLIENT:
|
||||
priv->client = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
case PROP_RTLOOP:
|
||||
|
|
@ -640,8 +640,11 @@ on_property_notify (GObject *obj,
|
|||
PinosNode *this = user_data;
|
||||
PinosNodePrivate *priv = this->priv;
|
||||
|
||||
if (pspec == NULL || strcmp (g_param_spec_get_name (pspec), "sender") == 0) {
|
||||
pinos_node1_set_owner (priv->iface, priv->sender);
|
||||
if (pspec == NULL || strcmp (g_param_spec_get_name (pspec), "client") == 0) {
|
||||
if (priv->client)
|
||||
pinos_node1_set_owner (priv->iface, pinos_client_get_object_path (priv->client));
|
||||
else
|
||||
pinos_node1_set_owner (priv->iface, pinos_daemon_get_object_path (priv->daemon));
|
||||
}
|
||||
if (pspec == NULL || strcmp (g_param_spec_get_name (pspec), "name") == 0) {
|
||||
pinos_node1_set_name (priv->iface, pinos_node_get_name (this));
|
||||
|
|
@ -687,9 +690,6 @@ pinos_node_constructed (GObject * obj)
|
|||
this->node->info->items[i].value);
|
||||
}
|
||||
|
||||
if (priv->sender == NULL)
|
||||
priv->sender = g_strdup (pinos_daemon_get_sender (priv->daemon));
|
||||
|
||||
if (this->node->state > SPA_NODE_STATE_INIT) {
|
||||
init_complete (this);
|
||||
} else {
|
||||
|
|
@ -725,7 +725,6 @@ pinos_node_finalize (GObject * obj)
|
|||
g_clear_object (&priv->daemon);
|
||||
g_clear_object (&priv->iface);
|
||||
g_clear_object (&priv->loop);
|
||||
g_free (priv->sender);
|
||||
g_free (priv->name);
|
||||
g_clear_error (&priv->error);
|
||||
if (priv->properties)
|
||||
|
|
@ -761,11 +760,11 @@ pinos_node_class_init (PinosNodeClass * klass)
|
|||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_SENDER,
|
||||
g_param_spec_string ("sender",
|
||||
"Sender",
|
||||
"The Sender",
|
||||
NULL,
|
||||
PROP_CLIENT,
|
||||
g_param_spec_object ("client",
|
||||
"Client",
|
||||
"The Client",
|
||||
PINOS_TYPE_CLIENT,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
|
@ -894,7 +893,7 @@ pinos_node_init (PinosNode * node)
|
|||
/**
|
||||
* pinos_node_new:
|
||||
* @daemon: a #PinosDaemon
|
||||
* @sender: the path of the owner
|
||||
* @client: the client owner
|
||||
* @name: a name
|
||||
* @properties: extra properties
|
||||
*
|
||||
|
|
@ -904,7 +903,7 @@ pinos_node_init (PinosNode * node)
|
|||
*/
|
||||
PinosNode *
|
||||
pinos_node_new (PinosDaemon *daemon,
|
||||
const gchar *sender,
|
||||
PinosClient *client,
|
||||
const gchar *name,
|
||||
PinosProperties *properties,
|
||||
SpaNode *node)
|
||||
|
|
@ -913,7 +912,7 @@ pinos_node_new (PinosDaemon *daemon,
|
|||
|
||||
return g_object_new (PINOS_TYPE_NODE,
|
||||
"daemon", daemon,
|
||||
"sender", sender,
|
||||
"client", client,
|
||||
"name", name,
|
||||
"properties", properties,
|
||||
"node", node,
|
||||
|
|
@ -997,22 +996,22 @@ pinos_node_get_daemon (PinosNode *node)
|
|||
}
|
||||
|
||||
/**
|
||||
* pinos_node_get_sender:
|
||||
* pinos_node_get_client:
|
||||
* @node: a #PinosNode
|
||||
*
|
||||
* Get the owner path of @node.
|
||||
* Get the owner client of @node.
|
||||
*
|
||||
* Returns: the owner path of @node.
|
||||
* Returns: the owner client of @node.
|
||||
*/
|
||||
const gchar *
|
||||
pinos_node_get_sender (PinosNode *node)
|
||||
PinosClient *
|
||||
pinos_node_get_client (PinosNode *node)
|
||||
{
|
||||
PinosNodePrivate *priv;
|
||||
|
||||
g_return_val_if_fail (PINOS_IS_NODE (node), NULL);
|
||||
priv = node->priv;
|
||||
|
||||
return priv->sender;
|
||||
return priv->client;
|
||||
}
|
||||
/**
|
||||
* pinos_node_get_object_path:
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ typedef struct _PinosNodePrivate PinosNodePrivate;
|
|||
#include <pinos/client/introspect.h>
|
||||
#include <pinos/server/daemon.h>
|
||||
#include <pinos/server/link.h>
|
||||
#include <pinos/server/client.h>
|
||||
|
||||
#define PINOS_TYPE_NODE (pinos_node_get_type ())
|
||||
#define PINOS_IS_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_NODE))
|
||||
|
|
@ -79,7 +80,7 @@ struct _PinosNodeClass {
|
|||
GType pinos_node_get_type (void);
|
||||
|
||||
PinosNode * pinos_node_new (PinosDaemon *daemon,
|
||||
const gchar *sender,
|
||||
PinosClient *client,
|
||||
const gchar *name,
|
||||
PinosProperties *properties,
|
||||
SpaNode *node);
|
||||
|
|
@ -89,7 +90,7 @@ const gchar * pinos_node_get_name (PinosNode *node);
|
|||
PinosProperties * pinos_node_get_properties (PinosNode *node);
|
||||
|
||||
PinosDaemon * pinos_node_get_daemon (PinosNode *node);
|
||||
const gchar * pinos_node_get_sender (PinosNode *node);
|
||||
PinosClient * pinos_node_get_client (PinosNode *node);
|
||||
const gchar * pinos_node_get_object_path (PinosNode *node);
|
||||
|
||||
guint pinos_node_get_free_port (PinosNode *node,
|
||||
|
|
|
|||
|
|
@ -35,9 +35,10 @@ struct _PinosRTLoopPrivate
|
|||
{
|
||||
unsigned int n_poll;
|
||||
SpaPollItem poll[16];
|
||||
int idx[16];
|
||||
|
||||
bool rebuild_fds;
|
||||
SpaPollFd fds[16];
|
||||
SpaPollFd fds[32];
|
||||
unsigned int n_fds;
|
||||
|
||||
gboolean running;
|
||||
|
|
@ -81,8 +82,8 @@ loop (void *user_data)
|
|||
n_idle++;
|
||||
}
|
||||
}
|
||||
if (n_idle > 0)
|
||||
continue;
|
||||
// if (n_idle > 0)
|
||||
// continue;
|
||||
|
||||
/* rebuild */
|
||||
if (priv->rebuild_fds) {
|
||||
|
|
@ -96,7 +97,7 @@ loop (void *user_data)
|
|||
|
||||
for (j = 0; j < p->n_fds; j++)
|
||||
priv->fds[priv->n_fds + j] = p->fds[j];
|
||||
p->fds = &priv->fds[priv->n_fds];
|
||||
priv->idx[i] = priv->n_fds;
|
||||
priv->n_fds += p->n_fds;
|
||||
}
|
||||
priv->rebuild_fds = false;
|
||||
|
|
@ -107,7 +108,7 @@ loop (void *user_data)
|
|||
SpaPollItem *p = &priv->poll[i];
|
||||
|
||||
if (p->enabled && p->before_cb) {
|
||||
ndata.fds = p->fds;
|
||||
ndata.fds = &priv->fds[priv->idx[i]];
|
||||
ndata.n_fds = p->n_fds;
|
||||
ndata.user_data = p->user_data;
|
||||
p->before_cb (&ndata);
|
||||
|
|
@ -138,7 +139,7 @@ loop (void *user_data)
|
|||
SpaPollItem *p = &priv->poll[i];
|
||||
|
||||
if (p->enabled && p->after_cb) {
|
||||
ndata.fds = p->fds;
|
||||
ndata.fds = &priv->fds[priv->idx[i]];
|
||||
ndata.n_fds = p->n_fds;
|
||||
ndata.user_data = p->user_data;
|
||||
p->after_cb (&ndata);
|
||||
|
|
|
|||
|
|
@ -64,11 +64,13 @@ typedef enum {
|
|||
SPA_RESULT_ASYNC_BUSY = -30,
|
||||
} SpaResult;
|
||||
|
||||
#define SPA_ASYNC_MASK (3 << 30)
|
||||
#define SPA_ASYNC_SEQ_MASK (SPA_RESULT_ASYNC - 1)
|
||||
|
||||
#define SPA_RESULT_IS_OK(res) ((res) >= 0)
|
||||
#define SPA_RESULT_IS_ERROR(res) ((res) < 0)
|
||||
#define SPA_RESULT_IS_ASYNC(res) (((res) & SPA_RESULT_ASYNC) == SPA_RESULT_ASYNC)
|
||||
#define SPA_RESULT_IS_ASYNC(res) (((res) & SPA_ASYNC_MASK) == SPA_RESULT_ASYNC)
|
||||
|
||||
#define SPA_ASYNC_SEQ_MASK (SPA_RESULT_ASYNC - 1)
|
||||
#define SPA_RESULT_ASYNC_SEQ(res) ((res) & SPA_ASYNC_SEQ_MASK)
|
||||
#define SPA_RESULT_RETURN_ASYNC(seq) (SPA_RESULT_ASYNC | ((seq) & SPA_ASYNC_SEQ_MASK))
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ struct _SpaMemoryChunk {
|
|||
* SpaMemory:
|
||||
* @refcount: a refcount
|
||||
* @notify: notify when refcount is 0
|
||||
* @user_data: owner specific used data
|
||||
* @user_data: owner specific user data
|
||||
* @pool_id: the id of the pool
|
||||
* @id: the memory id
|
||||
* @flags: extra memory flags
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ struct _SpaAudioTestSrc {
|
|||
#define DEFAULT_WAVE 0
|
||||
#define DEFAULT_VOLUME 1.0
|
||||
#define DEFAULT_FREQ 440.0
|
||||
#define DEFAULT_LIVE false
|
||||
#define DEFAULT_LIVE true
|
||||
|
||||
static const double min_volume = 0.0;
|
||||
static const double max_volume = 10.0;
|
||||
|
|
@ -534,6 +534,9 @@ clear_buffers (SpaAudioTestSrc *this)
|
|||
this->alloc_buffers = NULL;
|
||||
this->n_buffers = 0;
|
||||
this->have_buffers = false;
|
||||
this->info.flags &= ~SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS;
|
||||
SPA_QUEUE_INIT (&this->empty);
|
||||
SPA_QUEUE_INIT (&this->ready);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -719,6 +722,9 @@ spa_audiotestsrc_node_port_use_buffers (SpaNode *node,
|
|||
}
|
||||
this->n_buffers = n_buffers;
|
||||
this->have_buffers = true;
|
||||
this->info.flags |= SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS;
|
||||
} else {
|
||||
this->info.flags &= ~SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS;
|
||||
}
|
||||
|
||||
if (this->have_buffers) {
|
||||
|
|
@ -739,6 +745,7 @@ spa_audiotestsrc_node_port_alloc_buffers (SpaNode *node,
|
|||
uint32_t *n_buffers)
|
||||
{
|
||||
SpaAudioTestSrc *this;
|
||||
unsigned int i;
|
||||
|
||||
if (node == NULL || node->handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -754,7 +761,12 @@ spa_audiotestsrc_node_port_alloc_buffers (SpaNode *node,
|
|||
if (!this->have_buffers)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
*n_buffers = SPA_MIN (*n_buffers, this->n_buffers);
|
||||
|
||||
for (i = 0; i < *n_buffers; i++)
|
||||
buffers[i] = this->alloc_buffers[i].outbuf;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ struct _SpaVideoTestSrc {
|
|||
SpaQueue ready;
|
||||
};
|
||||
|
||||
#define DEFAULT_LIVE false
|
||||
#define DEFAULT_LIVE true
|
||||
|
||||
enum {
|
||||
PROP_ID_LIVE,
|
||||
|
|
@ -482,6 +482,9 @@ clear_buffers (SpaVideoTestSrc *this)
|
|||
this->alloc_buffers = NULL;
|
||||
this->n_buffers = 0;
|
||||
this->have_buffers = false;
|
||||
this->info.flags &= ~SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS;
|
||||
SPA_QUEUE_INIT (&this->empty);
|
||||
SPA_QUEUE_INIT (&this->ready);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -668,6 +671,9 @@ spa_videotestsrc_node_port_use_buffers (SpaNode *node,
|
|||
}
|
||||
this->n_buffers = n_buffers;
|
||||
this->have_buffers = true;
|
||||
this->info.flags |= SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS;
|
||||
} else {
|
||||
this->info.flags &= ~SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS;
|
||||
}
|
||||
|
||||
if (this->have_buffers) {
|
||||
|
|
@ -688,6 +694,7 @@ spa_videotestsrc_node_port_alloc_buffers (SpaNode *node,
|
|||
uint32_t *n_buffers)
|
||||
{
|
||||
SpaVideoTestSrc *this;
|
||||
unsigned int i;
|
||||
|
||||
if (node == NULL || node->handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -703,7 +710,12 @@ spa_videotestsrc_node_port_alloc_buffers (SpaNode *node,
|
|||
if (!this->have_buffers)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
*n_buffers = SPA_MIN (*n_buffers, this->n_buffers);
|
||||
|
||||
for (i = 0; i < *n_buffers; i++)
|
||||
buffers[i] = this->alloc_buffers[i].outbuf;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue