mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-14 06:59:57 -05:00
Add poll interface and remove poll events
Use an interface to change items in a poll loop.
This commit is contained in:
parent
fc4fd1424a
commit
2905d91467
20 changed files with 227 additions and 148 deletions
|
|
@ -57,7 +57,7 @@ struct _PinosDaemonPrivate
|
|||
|
||||
GHashTable *node_factories;
|
||||
|
||||
SpaSupport support[2];
|
||||
SpaSupport support[3];
|
||||
SpaLog log;
|
||||
};
|
||||
|
||||
|
|
@ -842,11 +842,12 @@ do_logv (SpaLog *log,
|
|||
{
|
||||
char text[16*1024], location[128];
|
||||
static const char *levels[] = {
|
||||
"NONE",
|
||||
"ERROR",
|
||||
"WARN",
|
||||
"INFO",
|
||||
"TRACE",
|
||||
"-",
|
||||
"E",
|
||||
"W",
|
||||
"I",
|
||||
"D",
|
||||
"T",
|
||||
};
|
||||
vsnprintf (text, sizeof(text), fmt, args);
|
||||
snprintf (location, sizeof(location), "%s:%i %s()", file, line, func);
|
||||
|
|
@ -899,8 +900,10 @@ pinos_daemon_init (PinosDaemon * daemon)
|
|||
priv->support[0].data = daemon->map;
|
||||
priv->support[1].uri = SPA_LOG_URI;
|
||||
priv->support[1].data = daemon->log;
|
||||
priv->support[2].uri = SPA_POLL__DataLoop;
|
||||
priv->support[2].data = &priv->loop->poll;
|
||||
daemon->support = priv->support;
|
||||
daemon->n_support = 2;
|
||||
daemon->n_support = 3;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -453,24 +453,6 @@ on_node_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
|
|||
break;
|
||||
}
|
||||
|
||||
case SPA_NODE_EVENT_TYPE_ADD_POLL:
|
||||
{
|
||||
SpaPollItem *item = event->data;
|
||||
pinos_rtloop_add_poll (priv->loop, item);
|
||||
break;
|
||||
}
|
||||
case SPA_NODE_EVENT_TYPE_UPDATE_POLL:
|
||||
{
|
||||
SpaPollItem *item = event->data;
|
||||
pinos_rtloop_update_poll (priv->loop, item);
|
||||
break;
|
||||
}
|
||||
case SPA_NODE_EVENT_TYPE_REMOVE_POLL:
|
||||
{
|
||||
SpaPollItem *item = event->data;
|
||||
pinos_rtloop_remove_poll (priv->loop, item);
|
||||
break;
|
||||
}
|
||||
case SPA_NODE_EVENT_TYPE_NEED_INPUT:
|
||||
{
|
||||
SpaNodeEventNeedInput *ni = event->data;
|
||||
|
|
|
|||
|
|
@ -190,9 +190,11 @@ stop_thread (PinosRTLoop *this, gboolean in_thread)
|
|||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
pinos_rtloop_add_poll (PinosRTLoop *this, SpaPollItem *item)
|
||||
static SpaResult
|
||||
do_add_item (SpaPoll *poll,
|
||||
SpaPollItem *item)
|
||||
{
|
||||
PinosRTLoop *this = SPA_CONTAINER_OF (poll, PinosRTLoop, poll);
|
||||
PinosRTLoopPrivate *priv = this->priv;
|
||||
gboolean in_thread = pthread_equal (priv->thread, pthread_self());
|
||||
unsigned int i;
|
||||
|
|
@ -211,12 +213,15 @@ pinos_rtloop_add_poll (PinosRTLoop *this, SpaPollItem *item)
|
|||
if (priv->poll[i].fds)
|
||||
g_debug ("poll %d: %p %d", i, priv->poll[i].user_data, priv->poll[i].fds[0].fd);
|
||||
}
|
||||
return TRUE;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
gboolean
|
||||
pinos_rtloop_update_poll (PinosRTLoop *this, SpaPollItem *item)
|
||||
|
||||
static SpaResult
|
||||
do_update_item (SpaPoll *poll,
|
||||
SpaPollItem *item)
|
||||
{
|
||||
PinosRTLoop *this = SPA_CONTAINER_OF (poll, PinosRTLoop, poll);
|
||||
PinosRTLoopPrivate *priv = this->priv;
|
||||
gboolean in_thread = pthread_equal (priv->thread, pthread_self());
|
||||
unsigned int i;
|
||||
|
|
@ -231,13 +236,14 @@ pinos_rtloop_update_poll (PinosRTLoop *this, SpaPollItem *item)
|
|||
if (!in_thread)
|
||||
wakeup_thread (this);
|
||||
|
||||
return TRUE;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
pinos_rtloop_remove_poll (PinosRTLoop *this, SpaPollItem *item)
|
||||
static SpaResult
|
||||
do_remove_item (SpaPoll *poll,
|
||||
SpaPollItem *item)
|
||||
{
|
||||
PinosRTLoop *this = SPA_CONTAINER_OF (poll, PinosRTLoop, poll);
|
||||
PinosRTLoopPrivate *priv = this->priv;
|
||||
gboolean in_thread = pthread_equal (priv->thread, pthread_self());
|
||||
unsigned int i;
|
||||
|
|
@ -263,7 +269,7 @@ pinos_rtloop_remove_poll (PinosRTLoop *this, SpaPollItem *item)
|
|||
if (priv->poll[i].fds)
|
||||
g_debug ("poll %d: %p %d", i, priv->poll[i].user_data, priv->poll[i].fds[0].fd);
|
||||
}
|
||||
return TRUE;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -321,6 +327,13 @@ pinos_rtloop_init (PinosRTLoop * this)
|
|||
this->priv = PINOS_RTLOOP_GET_PRIVATE (this);
|
||||
|
||||
g_debug ("rt-loop %p: new", this);
|
||||
|
||||
this->poll.handle = NULL;
|
||||
this->poll.size = sizeof (SpaPoll);
|
||||
this->poll.info = NULL;
|
||||
this->poll.add_item = do_add_item;
|
||||
this->poll.update_item = do_update_item;
|
||||
this->poll.remove_item = do_remove_item;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ typedef struct _PinosRTLoopPrivate PinosRTLoopPrivate;
|
|||
struct _PinosRTLoop {
|
||||
GObject object;
|
||||
|
||||
SpaPoll poll;
|
||||
|
||||
PinosRTLoopPrivate *priv;
|
||||
};
|
||||
|
||||
|
|
@ -64,6 +66,7 @@ GType pinos_rtloop_get_type (void);
|
|||
|
||||
PinosRTLoop * pinos_rtloop_new (void);
|
||||
|
||||
|
||||
gboolean pinos_rtloop_add_poll (PinosRTLoop *loop,
|
||||
SpaPollItem *item);
|
||||
gboolean pinos_rtloop_update_poll (PinosRTLoop *loop,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue