mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-14 08:56:37 -05:00
cleanups
Remove some unused things. Work on shutdown.
This commit is contained in:
parent
9485bd77e7
commit
463954a299
17 changed files with 166 additions and 99 deletions
|
|
@ -35,21 +35,6 @@
|
||||||
#define PINOS_SPA_ALSA_SINK_GET_PRIVATE(obj) \
|
#define PINOS_SPA_ALSA_SINK_GET_PRIVATE(obj) \
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_SPA_ALSA_SINK, PinosSpaAlsaSinkPrivate))
|
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_SPA_ALSA_SINK, PinosSpaAlsaSinkPrivate))
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
PinosSpaAlsaSink *sink;
|
|
||||||
|
|
||||||
PinosPort *port;
|
|
||||||
} SinkPortData;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
guint32 id;
|
|
||||||
guint32 type;
|
|
||||||
int fd;
|
|
||||||
guint64 offset;
|
|
||||||
guint64 size;
|
|
||||||
void *data;
|
|
||||||
} MemBlock;
|
|
||||||
|
|
||||||
struct _PinosSpaAlsaSinkPrivate
|
struct _PinosSpaAlsaSinkPrivate
|
||||||
{
|
{
|
||||||
PinosProperties *props;
|
PinosProperties *props;
|
||||||
|
|
@ -61,10 +46,6 @@ struct _PinosSpaAlsaSinkPrivate
|
||||||
|
|
||||||
gboolean running;
|
gboolean running;
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
|
|
||||||
GHashTable *mem_ids;
|
|
||||||
|
|
||||||
GList *ports;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
|
@ -216,6 +197,14 @@ on_sink_event (SpaNode *node, SpaEvent *event, void *user_data)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SPA_EVENT_TYPE_REMOVE_POLL:
|
||||||
|
{
|
||||||
|
if (priv->running) {
|
||||||
|
priv->running = false;
|
||||||
|
pthread_join (priv->thread, NULL);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case SPA_EVENT_TYPE_STATE_CHANGE:
|
case SPA_EVENT_TYPE_STATE_CHANGE:
|
||||||
{
|
{
|
||||||
SpaEventStateChange *sc = event->data;
|
SpaEventStateChange *sc = event->data;
|
||||||
|
|
@ -252,25 +241,32 @@ setup_node (PinosSpaAlsaSink *this)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
stop_pipeline (PinosSpaAlsaSink *sink)
|
pause_pipeline (PinosSpaAlsaSink *sink)
|
||||||
{
|
{
|
||||||
PinosNode *node = PINOS_NODE (sink);
|
PinosNode *node = PINOS_NODE (sink);
|
||||||
PinosSpaAlsaSinkPrivate *priv = sink->priv;
|
|
||||||
SpaResult res;
|
SpaResult res;
|
||||||
SpaCommand cmd;
|
SpaCommand cmd;
|
||||||
|
|
||||||
g_debug ("spa-alsa-sink %p: stopping pipeline", sink);
|
g_debug ("spa-alsa-sink %p: pausing pipeline", sink);
|
||||||
|
|
||||||
if (priv->running) {
|
|
||||||
priv->running = false;
|
|
||||||
pthread_join (priv->thread, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd.type = SPA_COMMAND_PAUSE;
|
cmd.type = SPA_COMMAND_PAUSE;
|
||||||
if ((res = spa_node_send_command (node->node, &cmd)) < 0)
|
if ((res = spa_node_send_command (node->node, &cmd)) < 0)
|
||||||
g_debug ("got error %d", res);
|
g_debug ("got error %d", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
suspend_pipeline (PinosSpaAlsaSink *this)
|
||||||
|
{
|
||||||
|
PinosNode *node = PINOS_NODE (this);
|
||||||
|
SpaResult res;
|
||||||
|
|
||||||
|
g_debug ("spa-alsa-sink %p: suspend pipeline", this);
|
||||||
|
|
||||||
|
if ((res = spa_node_port_set_format (node->node, 0, 0, NULL)) < 0) {
|
||||||
|
g_warning ("error unset format output: %d", res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
destroy_pipeline (PinosSpaAlsaSink *sink)
|
destroy_pipeline (PinosSpaAlsaSink *sink)
|
||||||
{
|
{
|
||||||
|
|
@ -287,13 +283,14 @@ set_state (PinosNode *node,
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case PINOS_NODE_STATE_SUSPENDED:
|
case PINOS_NODE_STATE_SUSPENDED:
|
||||||
|
suspend_pipeline (this);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PINOS_NODE_STATE_INITIALIZING:
|
case PINOS_NODE_STATE_INITIALIZING:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PINOS_NODE_STATE_IDLE:
|
case PINOS_NODE_STATE_IDLE:
|
||||||
stop_pipeline (this);
|
pause_pipeline (this);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PINOS_NODE_STATE_RUNNING:
|
case PINOS_NODE_STATE_RUNNING:
|
||||||
|
|
@ -335,8 +332,7 @@ set_property (GObject *object,
|
||||||
static void
|
static void
|
||||||
on_activate (PinosPort *port, gpointer user_data)
|
on_activate (PinosPort *port, gpointer user_data)
|
||||||
{
|
{
|
||||||
SinkPortData *data = user_data;
|
PinosNode *node = user_data;
|
||||||
PinosNode *node = PINOS_NODE (data->sink);
|
|
||||||
|
|
||||||
g_debug ("port %p: activate", port);
|
g_debug ("port %p: activate", port);
|
||||||
|
|
||||||
|
|
@ -346,26 +342,12 @@ on_activate (PinosPort *port, gpointer user_data)
|
||||||
static void
|
static void
|
||||||
on_deactivate (PinosPort *port, gpointer user_data)
|
on_deactivate (PinosPort *port, gpointer user_data)
|
||||||
{
|
{
|
||||||
SinkPortData *data = user_data;
|
PinosNode *node = user_data;
|
||||||
PinosNode *node = PINOS_NODE (data->sink);
|
|
||||||
|
|
||||||
g_debug ("port %p: deactivate", port);
|
g_debug ("port %p: deactivate", port);
|
||||||
pinos_node_report_idle (node);
|
pinos_node_report_idle (node);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
free_sink_port_data (SinkPortData *data)
|
|
||||||
{
|
|
||||||
g_slice_free (SinkPortData, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
free_mem_block (MemBlock *b)
|
|
||||||
{
|
|
||||||
munmap (b->data, b->size);
|
|
||||||
g_slice_free (MemBlock, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
on_received_buffer (PinosPort *port,
|
on_received_buffer (PinosPort *port,
|
||||||
uint32_t buffer_id,
|
uint32_t buffer_id,
|
||||||
|
|
@ -421,46 +403,26 @@ add_port (PinosNode *node,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
PinosSpaAlsaSink *sink = PINOS_SPA_ALSA_SINK (node);
|
PinosSpaAlsaSink *sink = PINOS_SPA_ALSA_SINK (node);
|
||||||
PinosSpaAlsaSinkPrivate *priv = sink->priv;
|
PinosPort *port;
|
||||||
SinkPortData *data;
|
|
||||||
|
|
||||||
data = g_slice_new0 (SinkPortData);
|
port = PINOS_NODE_CLASS (pinos_spa_alsa_sink_parent_class)
|
||||||
data->sink = sink;
|
|
||||||
data->port = PINOS_NODE_CLASS (pinos_spa_alsa_sink_parent_class)
|
|
||||||
->add_port (node, id, error);
|
->add_port (node, id, error);
|
||||||
|
|
||||||
pinos_port_set_received_cb (data->port, on_received_buffer, on_received_event, sink, NULL);
|
pinos_port_set_received_cb (port, on_received_buffer, on_received_event, sink, NULL);
|
||||||
|
|
||||||
g_debug ("connecting signals");
|
g_debug ("connecting signals");
|
||||||
g_signal_connect (data->port, "activate", (GCallback) on_activate, data);
|
g_signal_connect (port, "activate", (GCallback) on_activate, sink);
|
||||||
g_signal_connect (data->port, "deactivate", (GCallback) on_deactivate, data);
|
g_signal_connect (port, "deactivate", (GCallback) on_deactivate, sink);
|
||||||
|
|
||||||
priv->ports = g_list_append (priv->ports, data);
|
return port;
|
||||||
|
|
||||||
return data->port;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
remove_port (PinosNode *node,
|
remove_port (PinosNode *node,
|
||||||
PinosPort *port)
|
PinosPort *port)
|
||||||
{
|
{
|
||||||
PinosSpaAlsaSink *sink = PINOS_SPA_ALSA_SINK (node);
|
return PINOS_NODE_CLASS (pinos_spa_alsa_sink_parent_class)
|
||||||
PinosSpaAlsaSinkPrivate *priv = sink->priv;
|
->remove_port (node, port);
|
||||||
GList *walk;
|
|
||||||
|
|
||||||
for (walk = priv->ports; walk; walk = g_list_next (walk)) {
|
|
||||||
SinkPortData *data = walk->data;
|
|
||||||
|
|
||||||
if (data->port == port) {
|
|
||||||
free_sink_port_data (data);
|
|
||||||
priv->ports = g_list_delete_link (priv->ports, walk);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (priv->ports == NULL)
|
|
||||||
pinos_node_report_idle (node);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -481,7 +443,6 @@ sink_finalize (GObject * object)
|
||||||
|
|
||||||
destroy_pipeline (sink);
|
destroy_pipeline (sink);
|
||||||
pinos_properties_free (priv->props);
|
pinos_properties_free (priv->props);
|
||||||
g_hash_table_unref (priv->mem_ids);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (pinos_spa_alsa_sink_parent_class)->finalize (object);
|
G_OBJECT_CLASS (pinos_spa_alsa_sink_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
@ -507,11 +468,8 @@ pinos_spa_alsa_sink_class_init (PinosSpaAlsaSinkClass * klass)
|
||||||
static void
|
static void
|
||||||
pinos_spa_alsa_sink_init (PinosSpaAlsaSink * sink)
|
pinos_spa_alsa_sink_init (PinosSpaAlsaSink * sink)
|
||||||
{
|
{
|
||||||
PinosSpaAlsaSinkPrivate *priv;
|
PinosSpaAlsaSinkPrivate *priv = sink->priv = PINOS_SPA_ALSA_SINK_GET_PRIVATE (sink);
|
||||||
|
|
||||||
priv = sink->priv = PINOS_SPA_ALSA_SINK_GET_PRIVATE (sink);
|
|
||||||
priv->props = pinos_properties_new (NULL, NULL);
|
priv->props = pinos_properties_new (NULL, NULL);
|
||||||
priv->mem_ids = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) free_mem_block);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PinosNode *
|
PinosNode *
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,6 @@ struct _PinosSpaV4l2SourcePrivate
|
||||||
|
|
||||||
gboolean running;
|
gboolean running;
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
|
|
||||||
GBytes *format;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
|
@ -143,13 +141,13 @@ on_source_event (SpaNode *node, SpaEvent *event, void *user_data)
|
||||||
{
|
{
|
||||||
SpaOutputInfo info[1] = { 0, };
|
SpaOutputInfo info[1] = { 0, };
|
||||||
SpaResult res;
|
SpaResult res;
|
||||||
GList *walk;
|
GList *ports, *walk;
|
||||||
|
|
||||||
if ((res = spa_node_port_pull_output (node, 1, info)) < 0)
|
if ((res = spa_node_port_pull_output (node, 1, info)) < 0)
|
||||||
g_debug ("spa-v4l2-source %p: got pull error %d, %d", this, res, info[0].status);
|
g_debug ("spa-v4l2-source %p: got pull error %d, %d", this, res, info[0].status);
|
||||||
|
|
||||||
walk = pinos_node_get_ports (PINOS_NODE (this));
|
ports = pinos_node_get_ports (PINOS_NODE (this));
|
||||||
for (; walk; walk = g_list_next (walk)) {
|
for (walk = ports; walk; walk = g_list_next (walk)) {
|
||||||
PinosPort *port = walk->data;
|
PinosPort *port = walk->data;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
|
|
@ -158,6 +156,7 @@ on_source_event (SpaNode *node, SpaEvent *event, void *user_data)
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
g_list_free (ports);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -351,11 +350,15 @@ source_constructed (GObject * object)
|
||||||
static void
|
static void
|
||||||
source_finalize (GObject * object)
|
source_finalize (GObject * object)
|
||||||
{
|
{
|
||||||
|
PinosNode *node = PINOS_NODE (object);
|
||||||
PinosSpaV4l2Source *source = PINOS_SPA_V4L2_SOURCE (object);
|
PinosSpaV4l2Source *source = PINOS_SPA_V4L2_SOURCE (object);
|
||||||
|
|
||||||
g_debug ("spa-source %p: dispose", source);
|
g_debug ("spa-source %p: dispose", source);
|
||||||
destroy_pipeline (source);
|
destroy_pipeline (source);
|
||||||
|
|
||||||
|
spa_handle_clear (node->node->handle);
|
||||||
|
g_free (node->node->handle);
|
||||||
|
|
||||||
G_OBJECT_CLASS (pinos_spa_v4l2_source_parent_class)->finalize (object);
|
G_OBJECT_CLASS (pinos_spa_v4l2_source_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
#include <sys/eventfd.h>
|
||||||
|
|
||||||
#include <gio/gunixfdlist.h>
|
#include <gio/gunixfdlist.h>
|
||||||
|
|
||||||
|
|
@ -220,6 +220,13 @@ loop (void *user_data)
|
||||||
g_debug ("client-node %p: select timeout", this);
|
g_debug ("client-node %p: select timeout", this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (priv->fds[0].revents & POLLIN) {
|
||||||
|
uint64_t u;
|
||||||
|
if (read (priv->fds[0].fd, &u, sizeof(uint64_t)) != sizeof(uint64_t))
|
||||||
|
g_warning ("client-node %p: failed to read fd", strerror (errno));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (priv->poll.after_cb) {
|
if (priv->poll.after_cb) {
|
||||||
ndata.fds = priv->poll.fds;
|
ndata.fds = priv->poll.fds;
|
||||||
ndata.n_fds = priv->poll.n_fds;
|
ndata.n_fds = priv->poll.n_fds;
|
||||||
|
|
@ -241,7 +248,7 @@ start_thread (PinosClientNode *this)
|
||||||
if (!priv->running) {
|
if (!priv->running) {
|
||||||
priv->running = true;
|
priv->running = true;
|
||||||
if ((err = pthread_create (&priv->thread, NULL, loop, this)) != 0) {
|
if ((err = pthread_create (&priv->thread, NULL, loop, this)) != 0) {
|
||||||
g_debug ("client-node %p: can't create thread", strerror (err));
|
g_warning ("client-node %p: can't create thread", strerror (err));
|
||||||
priv->running = false;
|
priv->running = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -253,6 +260,11 @@ stop_thread (PinosClientNode *this)
|
||||||
PinosClientNodePrivate *priv = this->priv;
|
PinosClientNodePrivate *priv = this->priv;
|
||||||
|
|
||||||
if (priv->running) {
|
if (priv->running) {
|
||||||
|
uint64_t u = 1;
|
||||||
|
|
||||||
|
if (write (priv->fds[0].fd, &u, sizeof(uint64_t)) != sizeof(uint64_t))
|
||||||
|
g_warning ("client-node %p: failed to write fd", strerror (errno));
|
||||||
|
|
||||||
priv->running = false;
|
priv->running = false;
|
||||||
pthread_join (priv->thread, NULL);
|
pthread_join (priv->thread, NULL);
|
||||||
}
|
}
|
||||||
|
|
@ -305,6 +317,7 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
|
||||||
PinosPort *port = walk->data;
|
PinosPort *port = walk->data;
|
||||||
pinos_port_activate (port);
|
pinos_port_activate (port);
|
||||||
}
|
}
|
||||||
|
g_list_free (ports);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
@ -314,11 +327,12 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
|
||||||
case SPA_EVENT_TYPE_ADD_POLL:
|
case SPA_EVENT_TYPE_ADD_POLL:
|
||||||
{
|
{
|
||||||
SpaPollItem *poll = event->data;
|
SpaPollItem *poll = event->data;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
priv->poll = *poll;
|
priv->poll = *poll;
|
||||||
priv->fds[0] = poll->fds[0];
|
priv->poll.fds = &priv->fds[priv->n_fds];
|
||||||
priv->n_fds = 1;
|
for (i = 0; i < poll->n_fds; i++)
|
||||||
priv->poll.fds = priv->fds;
|
priv->fds[priv->n_fds++] = poll->fds[i];
|
||||||
|
|
||||||
start_thread (this);
|
start_thread (this);
|
||||||
break;
|
break;
|
||||||
|
|
@ -406,6 +420,7 @@ pinos_client_node_dispose (GObject * object)
|
||||||
PinosClientNode *this = PINOS_CLIENT_NODE (object);
|
PinosClientNode *this = PINOS_CLIENT_NODE (object);
|
||||||
|
|
||||||
g_debug ("client-node %p: dispose", this);
|
g_debug ("client-node %p: dispose", this);
|
||||||
|
stop_thread (this);
|
||||||
|
|
||||||
G_OBJECT_CLASS (pinos_client_node_parent_class)->dispose (object);
|
G_OBJECT_CLASS (pinos_client_node_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
@ -413,10 +428,17 @@ pinos_client_node_dispose (GObject * object)
|
||||||
static void
|
static void
|
||||||
pinos_client_node_finalize (GObject * object)
|
pinos_client_node_finalize (GObject * object)
|
||||||
{
|
{
|
||||||
|
PinosNode *node = PINOS_NODE (object);
|
||||||
PinosClientNode *this = PINOS_CLIENT_NODE (object);
|
PinosClientNode *this = PINOS_CLIENT_NODE (object);
|
||||||
|
PinosClientNodePrivate *priv = this->priv;
|
||||||
|
|
||||||
g_debug ("client-node %p: finalize", this);
|
g_debug ("client-node %p: finalize", this);
|
||||||
|
|
||||||
|
g_clear_object (&priv->sockets[0]);
|
||||||
|
g_clear_object (&priv->sockets[1]);
|
||||||
|
spa_handle_clear (node->node->handle);
|
||||||
|
g_free (node->node->handle);
|
||||||
|
|
||||||
G_OBJECT_CLASS (pinos_client_node_parent_class)->finalize (object);
|
G_OBJECT_CLASS (pinos_client_node_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -424,11 +446,17 @@ static void
|
||||||
pinos_client_node_constructed (GObject * object)
|
pinos_client_node_constructed (GObject * object)
|
||||||
{
|
{
|
||||||
PinosClientNode *this = PINOS_CLIENT_NODE (object);
|
PinosClientNode *this = PINOS_CLIENT_NODE (object);
|
||||||
|
PinosClientNodePrivate *priv = this->priv;
|
||||||
|
|
||||||
g_debug ("client-node %p: constructed", this);
|
g_debug ("client-node %p: constructed", this);
|
||||||
|
|
||||||
G_OBJECT_CLASS (pinos_client_node_parent_class)->constructed (object);
|
G_OBJECT_CLASS (pinos_client_node_parent_class)->constructed (object);
|
||||||
|
|
||||||
|
priv->fds[0].fd = eventfd (0, 0);
|
||||||
|
priv->fds[0].events = POLLIN | POLLPRI | POLLERR;
|
||||||
|
priv->fds[0].revents = 0;
|
||||||
|
priv->n_fds = 1;
|
||||||
|
|
||||||
setup_node (this);
|
setup_node (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,7 @@ pinos_client_dispose (GObject * object)
|
||||||
g_debug ("client %p: dispose", client);
|
g_debug ("client %p: dispose", client);
|
||||||
copy = g_list_copy (priv->objects);
|
copy = g_list_copy (priv->objects);
|
||||||
g_list_free_full (copy, g_object_unref);
|
g_list_free_full (copy, g_object_unref);
|
||||||
|
g_list_free (priv->objects);
|
||||||
|
|
||||||
client_unregister_object (client);
|
client_unregister_object (client);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -248,6 +248,7 @@ handle_create_client_node (PinosDaemon1 *interface,
|
||||||
sender,
|
sender,
|
||||||
arg_name,
|
arg_name,
|
||||||
props);
|
props);
|
||||||
|
pinos_properties_free (props);
|
||||||
|
|
||||||
socket = pinos_client_node_get_socket_pair (PINOS_CLIENT_NODE (node), &error);
|
socket = pinos_client_node_get_socket_pair (PINOS_CLIENT_NODE (node), &error);
|
||||||
if (socket == NULL)
|
if (socket == NULL)
|
||||||
|
|
@ -265,6 +266,7 @@ handle_create_client_node (PinosDaemon1 *interface,
|
||||||
|
|
||||||
fdlist = g_unix_fd_list_new ();
|
fdlist = g_unix_fd_list_new ();
|
||||||
fdidx = g_unix_fd_list_append (fdlist, g_socket_get_fd (socket), &error);
|
fdidx = g_unix_fd_list_append (fdlist, g_socket_get_fd (socket), &error);
|
||||||
|
g_object_unref (socket);
|
||||||
|
|
||||||
g_dbus_method_invocation_return_value_with_unix_fd_list (invocation,
|
g_dbus_method_invocation_return_value_with_unix_fd_list (invocation,
|
||||||
g_variant_new ("(oh)", object_path, fdidx), fdlist);
|
g_variant_new ("(oh)", object_path, fdidx), fdlist);
|
||||||
|
|
@ -532,7 +534,7 @@ pinos_daemon_find_port (PinosDaemon *daemon,
|
||||||
{
|
{
|
||||||
PinosDaemonPrivate *priv;
|
PinosDaemonPrivate *priv;
|
||||||
PinosPort *best = NULL;
|
PinosPort *best = NULL;
|
||||||
GList *nodes, *ports;
|
GList *nodes, *ports, *walk;
|
||||||
gboolean have_name, created_port = FALSE;
|
gboolean have_name, created_port = FALSE;
|
||||||
|
|
||||||
g_return_val_if_fail (PINOS_IS_DAEMON (daemon), NULL);
|
g_return_val_if_fail (PINOS_IS_DAEMON (daemon), NULL);
|
||||||
|
|
@ -557,8 +559,9 @@ pinos_daemon_find_port (PinosDaemon *daemon,
|
||||||
node_found = TRUE;
|
node_found = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ports = pinos_node_get_ports (n); ports; ports = g_list_next (ports)) {
|
ports = pinos_node_get_ports (n);
|
||||||
PinosPort *p = ports->data;
|
for (walk = ports; walk; walk = g_list_next (walk)) {
|
||||||
|
PinosPort *p = walk->data;
|
||||||
PinosDirection dir;
|
PinosDirection dir;
|
||||||
|
|
||||||
g_object_get (p, "direction", &dir, NULL);
|
g_object_get (p, "direction", &dir, NULL);
|
||||||
|
|
@ -572,6 +575,8 @@ pinos_daemon_find_port (PinosDaemon *daemon,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
g_list_free (ports);
|
||||||
|
|
||||||
if (best == NULL && node_found) {
|
if (best == NULL && node_found) {
|
||||||
guint id;
|
guint id;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -572,6 +572,8 @@ pinos_link_dispose (GObject * object)
|
||||||
|
|
||||||
g_debug ("link %p: dispose", this);
|
g_debug ("link %p: dispose", this);
|
||||||
|
|
||||||
|
do_pause (this);
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_data (priv->input, this);
|
g_signal_handlers_disconnect_by_data (priv->input, this);
|
||||||
g_signal_handlers_disconnect_by_data (priv->output, this);
|
g_signal_handlers_disconnect_by_data (priv->output, this);
|
||||||
g_signal_handlers_disconnect_by_data (priv->input->node, this);
|
g_signal_handlers_disconnect_by_data (priv->input->node, this);
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,7 @@ find_module (const gchar * path, const gchar *name)
|
||||||
if (g_file_test (newpath, G_FILE_TEST_IS_DIR)) {
|
if (g_file_test (newpath, G_FILE_TEST_IS_DIR)) {
|
||||||
filename = find_module (newpath, name);
|
filename = find_module (newpath, name);
|
||||||
}
|
}
|
||||||
|
g_free (newpath);
|
||||||
|
|
||||||
if (filename != NULL)
|
if (filename != NULL)
|
||||||
break;
|
break;
|
||||||
|
|
@ -263,6 +264,8 @@ pinos_module_load (PinosDaemon * daemon,
|
||||||
g_debug ("trying to load module: %s (%s)", name, filename);
|
g_debug ("trying to load module: %s (%s)", name, filename);
|
||||||
|
|
||||||
gmodule = g_module_open (filename, G_MODULE_BIND_LOCAL);
|
gmodule = g_module_open (filename, G_MODULE_BIND_LOCAL);
|
||||||
|
g_free (filename);
|
||||||
|
|
||||||
if (gmodule == NULL) {
|
if (gmodule == NULL) {
|
||||||
g_set_error (err, PINOS_MODULE_ERROR, PINOS_MODULE_ERROR_LOADING,
|
g_set_error (err, PINOS_MODULE_ERROR, PINOS_MODULE_ERROR_LOADING,
|
||||||
"Failed to open module: %s", g_module_error ());
|
"Failed to open module: %s", g_module_error ());
|
||||||
|
|
|
||||||
|
|
@ -390,6 +390,7 @@ node_unregister_object (PinosNode *node)
|
||||||
|
|
||||||
g_debug ("node %p: unregister object %s", node, priv->object_path);
|
g_debug ("node %p: unregister object %s", node, priv->object_path);
|
||||||
pinos_daemon_unexport (priv->daemon, priv->object_path);
|
pinos_daemon_unexport (priv->daemon, priv->object_path);
|
||||||
|
g_clear_pointer (&priv->object_path, g_free);
|
||||||
pinos_daemon_remove_node (priv->daemon, node);
|
pinos_daemon_remove_node (priv->daemon, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,21 @@ struct _SpaHandle {
|
||||||
SpaResult (*get_interface) (SpaHandle *handle,
|
SpaResult (*get_interface) (SpaHandle *handle,
|
||||||
uint32_t interface_id,
|
uint32_t interface_id,
|
||||||
void **interface);
|
void **interface);
|
||||||
|
/**
|
||||||
|
* SpaHandle::clear
|
||||||
|
* @handle: a pointer to memory
|
||||||
|
*
|
||||||
|
* Clean up the memory of @handle. After this, @handle should not be used
|
||||||
|
* anymore.
|
||||||
|
*
|
||||||
|
* Returns: #SPA_RESULT_OK on success
|
||||||
|
*/
|
||||||
|
SpaResult (*clear) (SpaHandle *handle);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define spa_handle_get_interface(h,...) (h)->get_interface((h),__VA_ARGS__)
|
||||||
|
#define spa_handle_clear(h) (h)->clear((h))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SpaInterfaceInfo:
|
* SpaInterfaceInfo:
|
||||||
* @interface_id: the id of the interface, can be used to get the interface
|
* @interface_id: the id of the interface, can be used to get the interface
|
||||||
|
|
@ -99,6 +112,7 @@ struct _SpaHandleFactory {
|
||||||
*/
|
*/
|
||||||
SpaResult (*init) (const SpaHandleFactory *factory,
|
SpaResult (*init) (const SpaHandleFactory *factory,
|
||||||
SpaHandle *handle);
|
SpaHandle *handle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SpaHandle::enum_interface_info:
|
* SpaHandle::enum_interface_info:
|
||||||
* @factory: a #SpaHandleFactory
|
* @factory: a #SpaHandleFactory
|
||||||
|
|
@ -117,6 +131,9 @@ struct _SpaHandleFactory {
|
||||||
void **state);
|
void **state);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define spa_handle_factory_init(h,...) (h)->init((h),__VA_ARGS__)
|
||||||
|
#define spa_handle_factory_enum_interface_info(h,...) (h)->enum_interface_info((h),__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SpaEnumHandleFactoryFunc:
|
* SpaEnumHandleFactoryFunc:
|
||||||
* @factory: a location to hold the factory result
|
* @factory: a location to hold the factory result
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ spa_memory_alloc_with_fd (uint32_t pool_id, void *data, size_t size)
|
||||||
if (!(mem = spa_memory_alloc (pool_id)))
|
if (!(mem = spa_memory_alloc (pool_id)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
{
|
{
|
||||||
char filename[] = "/dev/shm/spa-tmpfile.XXXXXX";
|
char filename[] = "/dev/shm/spa-tmpfile.XXXXXX";
|
||||||
mem->fd = mkostemp (filename, O_CLOEXEC);
|
mem->fd = mkostemp (filename, O_CLOEXEC);
|
||||||
|
|
@ -176,7 +176,7 @@ spa_memory_alloc_with_fd (uint32_t pool_id, void *data, size_t size)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if 1
|
#if 0
|
||||||
{
|
{
|
||||||
unsigned int seals;
|
unsigned int seals;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -678,6 +678,12 @@ spa_alsa_sink_get_interface (SpaHandle *handle,
|
||||||
return SPA_RESULT_OK;
|
return SPA_RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SpaResult
|
||||||
|
alsa_sink_clear (SpaHandle *handle)
|
||||||
|
{
|
||||||
|
return SPA_RESULT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static SpaResult
|
static SpaResult
|
||||||
alsa_sink_init (const SpaHandleFactory *factory,
|
alsa_sink_init (const SpaHandleFactory *factory,
|
||||||
SpaHandle *handle)
|
SpaHandle *handle)
|
||||||
|
|
@ -688,6 +694,7 @@ alsa_sink_init (const SpaHandleFactory *factory,
|
||||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||||
|
|
||||||
handle->get_interface = spa_alsa_sink_get_interface;
|
handle->get_interface = spa_alsa_sink_get_interface;
|
||||||
|
handle->clear = alsa_sink_clear;
|
||||||
|
|
||||||
this = (SpaALSASink *) handle;
|
this = (SpaALSASink *) handle;
|
||||||
this->node = alsasink_node;
|
this->node = alsasink_node;
|
||||||
|
|
|
||||||
|
|
@ -770,6 +770,12 @@ spa_audiomixer_get_interface (SpaHandle *handle,
|
||||||
return SPA_RESULT_OK;
|
return SPA_RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SpaResult
|
||||||
|
spa_audiomixer_clear (SpaHandle *handle)
|
||||||
|
{
|
||||||
|
return SPA_RESULT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static SpaResult
|
static SpaResult
|
||||||
spa_audiomixer_init (const SpaHandleFactory *factory,
|
spa_audiomixer_init (const SpaHandleFactory *factory,
|
||||||
SpaHandle *handle)
|
SpaHandle *handle)
|
||||||
|
|
@ -780,6 +786,7 @@ spa_audiomixer_init (const SpaHandleFactory *factory,
|
||||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||||
|
|
||||||
handle->get_interface = spa_audiomixer_get_interface;
|
handle->get_interface = spa_audiomixer_get_interface;
|
||||||
|
handle->clear = spa_audiomixer_clear;
|
||||||
|
|
||||||
this = (SpaAudioMixer *) handle;
|
this = (SpaAudioMixer *) handle;
|
||||||
this->node = audiomixer_node;
|
this->node = audiomixer_node;
|
||||||
|
|
|
||||||
|
|
@ -555,6 +555,12 @@ spa_audiotestsrc_get_interface (SpaHandle *handle,
|
||||||
return SPA_RESULT_OK;
|
return SPA_RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SpaResult
|
||||||
|
audiotestsrc_clear (SpaHandle *handle)
|
||||||
|
{
|
||||||
|
return SPA_RESULT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static SpaResult
|
static SpaResult
|
||||||
audiotestsrc_init (const SpaHandleFactory *factory,
|
audiotestsrc_init (const SpaHandleFactory *factory,
|
||||||
SpaHandle *handle)
|
SpaHandle *handle)
|
||||||
|
|
@ -565,6 +571,7 @@ audiotestsrc_init (const SpaHandleFactory *factory,
|
||||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||||
|
|
||||||
handle->get_interface = spa_audiotestsrc_get_interface;
|
handle->get_interface = spa_audiotestsrc_get_interface;
|
||||||
|
handle->clear = audiotestsrc_clear;
|
||||||
|
|
||||||
this = (SpaAudioTestSrc *) handle;
|
this = (SpaAudioTestSrc *) handle;
|
||||||
this->node = audiotestsrc_node;
|
this->node = audiotestsrc_node;
|
||||||
|
|
|
||||||
|
|
@ -1121,8 +1121,14 @@ spa_proxy_get_interface (SpaHandle *handle,
|
||||||
}
|
}
|
||||||
|
|
||||||
static SpaResult
|
static SpaResult
|
||||||
proxy_instantiate (const SpaHandleFactory *factory,
|
proxy_clear (SpaHandle *handle)
|
||||||
SpaHandle *handle)
|
{
|
||||||
|
return SPA_RESULT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SpaResult
|
||||||
|
proxy_init (const SpaHandleFactory *factory,
|
||||||
|
SpaHandle *handle)
|
||||||
{
|
{
|
||||||
SpaProxy *this;
|
SpaProxy *this;
|
||||||
|
|
||||||
|
|
@ -1130,6 +1136,7 @@ proxy_instantiate (const SpaHandleFactory *factory,
|
||||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||||
|
|
||||||
handle->get_interface = spa_proxy_get_interface;
|
handle->get_interface = spa_proxy_get_interface;
|
||||||
|
handle->clear = proxy_clear;
|
||||||
|
|
||||||
this = (SpaProxy *) handle;
|
this = (SpaProxy *) handle;
|
||||||
this->node = proxy_node;
|
this->node = proxy_node;
|
||||||
|
|
@ -1189,6 +1196,6 @@ const SpaHandleFactory spa_proxy_factory =
|
||||||
{ "proxy",
|
{ "proxy",
|
||||||
NULL,
|
NULL,
|
||||||
sizeof (SpaProxy),
|
sizeof (SpaProxy),
|
||||||
proxy_instantiate,
|
proxy_init,
|
||||||
proxy_enum_interface_info,
|
proxy_enum_interface_info,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -763,6 +763,12 @@ spa_v4l2_source_get_interface (SpaHandle *handle,
|
||||||
return SPA_RESULT_OK;
|
return SPA_RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SpaResult
|
||||||
|
v4l2_source_clear (SpaHandle *handle)
|
||||||
|
{
|
||||||
|
return SPA_RESULT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static SpaResult
|
static SpaResult
|
||||||
v4l2_source_init (const SpaHandleFactory *factory,
|
v4l2_source_init (const SpaHandleFactory *factory,
|
||||||
SpaHandle *handle)
|
SpaHandle *handle)
|
||||||
|
|
@ -773,6 +779,7 @@ v4l2_source_init (const SpaHandleFactory *factory,
|
||||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||||
|
|
||||||
handle->get_interface = spa_v4l2_source_get_interface;
|
handle->get_interface = spa_v4l2_source_get_interface;
|
||||||
|
handle->clear = v4l2_source_clear,
|
||||||
|
|
||||||
this = (SpaV4l2Source *) handle;
|
this = (SpaV4l2Source *) handle;
|
||||||
this->node = v4l2source_node;
|
this->node = v4l2source_node;
|
||||||
|
|
|
||||||
|
|
@ -667,8 +667,14 @@ spa_volume_get_interface (SpaHandle *handle,
|
||||||
}
|
}
|
||||||
|
|
||||||
static SpaResult
|
static SpaResult
|
||||||
volume_instantiate (const SpaHandleFactory *factory,
|
volume_clear (SpaHandle *handle)
|
||||||
SpaHandle *handle)
|
{
|
||||||
|
return SPA_RESULT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SpaResult
|
||||||
|
volume_init (const SpaHandleFactory *factory,
|
||||||
|
SpaHandle *handle)
|
||||||
{
|
{
|
||||||
SpaVolume *this;
|
SpaVolume *this;
|
||||||
|
|
||||||
|
|
@ -676,6 +682,7 @@ volume_instantiate (const SpaHandleFactory *factory,
|
||||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||||
|
|
||||||
handle->get_interface = spa_volume_get_interface;
|
handle->get_interface = spa_volume_get_interface;
|
||||||
|
handle->clear = volume_clear;
|
||||||
|
|
||||||
this = (SpaVolume *) handle;
|
this = (SpaVolume *) handle;
|
||||||
this->node = volume_node;
|
this->node = volume_node;
|
||||||
|
|
@ -732,6 +739,6 @@ const SpaHandleFactory spa_volume_factory =
|
||||||
{ "volume",
|
{ "volume",
|
||||||
NULL,
|
NULL,
|
||||||
sizeof (SpaVolume),
|
sizeof (SpaVolume),
|
||||||
volume_instantiate,
|
volume_init,
|
||||||
volume_enum_interface_info,
|
volume_enum_interface_info,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -545,6 +545,12 @@ spa_xv_sink_get_interface (SpaHandle *handle,
|
||||||
return SPA_RESULT_OK;
|
return SPA_RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SpaResult
|
||||||
|
xv_sink_clear (SpaHandle *handle)
|
||||||
|
{
|
||||||
|
return SPA_RESULT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static SpaResult
|
static SpaResult
|
||||||
xv_sink_init (const SpaHandleFactory *factory,
|
xv_sink_init (const SpaHandleFactory *factory,
|
||||||
SpaHandle *handle)
|
SpaHandle *handle)
|
||||||
|
|
@ -555,6 +561,7 @@ xv_sink_init (const SpaHandleFactory *factory,
|
||||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||||
|
|
||||||
handle->get_interface = spa_xv_sink_get_interface;
|
handle->get_interface = spa_xv_sink_get_interface;
|
||||||
|
handle->clear = xv_sink_clear;
|
||||||
|
|
||||||
this = (SpaXvSink *) handle;
|
this = (SpaXvSink *) handle;
|
||||||
this->node = xvsink_node;
|
this->node = xvsink_node;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue