mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -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
				
			
		| 
						 | 
				
			
			@ -27,7 +27,7 @@
 | 
			
		|||
#include <fcntl.h>
 | 
			
		||||
#include <dlfcn.h>
 | 
			
		||||
#include <poll.h>
 | 
			
		||||
 | 
			
		||||
#include <sys/eventfd.h>
 | 
			
		||||
 | 
			
		||||
#include <gio/gunixfdlist.h>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -220,6 +220,13 @@ loop (void *user_data)
 | 
			
		|||
      g_debug ("client-node %p: select timeout", this);
 | 
			
		||||
      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) {
 | 
			
		||||
      ndata.fds = priv->poll.fds;
 | 
			
		||||
      ndata.n_fds = priv->poll.n_fds;
 | 
			
		||||
| 
						 | 
				
			
			@ -241,7 +248,7 @@ start_thread (PinosClientNode *this)
 | 
			
		|||
  if (!priv->running) {
 | 
			
		||||
    priv->running = true;
 | 
			
		||||
    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;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -253,6 +260,11 @@ stop_thread (PinosClientNode *this)
 | 
			
		|||
  PinosClientNodePrivate *priv = this->priv;
 | 
			
		||||
 | 
			
		||||
  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;
 | 
			
		||||
    pthread_join (priv->thread, NULL);
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -305,6 +317,7 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
 | 
			
		|||
            PinosPort *port = walk->data;
 | 
			
		||||
            pinos_port_activate (port);
 | 
			
		||||
          }
 | 
			
		||||
          g_list_free (ports);
 | 
			
		||||
        }
 | 
			
		||||
        default:
 | 
			
		||||
          break;
 | 
			
		||||
| 
						 | 
				
			
			@ -314,11 +327,12 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
 | 
			
		|||
    case SPA_EVENT_TYPE_ADD_POLL:
 | 
			
		||||
    {
 | 
			
		||||
      SpaPollItem *poll = event->data;
 | 
			
		||||
      unsigned int i;
 | 
			
		||||
 | 
			
		||||
      priv->poll = *poll;
 | 
			
		||||
      priv->fds[0] = poll->fds[0];
 | 
			
		||||
      priv->n_fds = 1;
 | 
			
		||||
      priv->poll.fds = priv->fds;
 | 
			
		||||
      priv->poll.fds = &priv->fds[priv->n_fds];
 | 
			
		||||
      for (i = 0; i < poll->n_fds; i++)
 | 
			
		||||
        priv->fds[priv->n_fds++] = poll->fds[i];
 | 
			
		||||
 | 
			
		||||
      start_thread (this);
 | 
			
		||||
      break;
 | 
			
		||||
| 
						 | 
				
			
			@ -406,6 +420,7 @@ pinos_client_node_dispose (GObject * object)
 | 
			
		|||
  PinosClientNode *this = PINOS_CLIENT_NODE (object);
 | 
			
		||||
 | 
			
		||||
  g_debug ("client-node %p: dispose", this);
 | 
			
		||||
  stop_thread (this);
 | 
			
		||||
 | 
			
		||||
  G_OBJECT_CLASS (pinos_client_node_parent_class)->dispose (object);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -413,10 +428,17 @@ pinos_client_node_dispose (GObject * object)
 | 
			
		|||
static void
 | 
			
		||||
pinos_client_node_finalize (GObject * object)
 | 
			
		||||
{
 | 
			
		||||
  PinosNode *node = PINOS_NODE (object);
 | 
			
		||||
  PinosClientNode *this = PINOS_CLIENT_NODE (object);
 | 
			
		||||
  PinosClientNodePrivate *priv = this->priv;
 | 
			
		||||
 | 
			
		||||
  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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -424,11 +446,17 @@ static void
 | 
			
		|||
pinos_client_node_constructed (GObject * object)
 | 
			
		||||
{
 | 
			
		||||
  PinosClientNode *this = PINOS_CLIENT_NODE (object);
 | 
			
		||||
  PinosClientNodePrivate *priv = this->priv;
 | 
			
		||||
 | 
			
		||||
  g_debug ("client-node %p: constructed", this);
 | 
			
		||||
 | 
			
		||||
  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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -209,6 +209,7 @@ pinos_client_dispose (GObject * object)
 | 
			
		|||
  g_debug ("client %p: dispose", client);
 | 
			
		||||
  copy = g_list_copy (priv->objects);
 | 
			
		||||
  g_list_free_full (copy, g_object_unref);
 | 
			
		||||
  g_list_free (priv->objects);
 | 
			
		||||
 | 
			
		||||
  client_unregister_object (client);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -248,6 +248,7 @@ handle_create_client_node (PinosDaemon1           *interface,
 | 
			
		|||
                                 sender,
 | 
			
		||||
                                 arg_name,
 | 
			
		||||
                                 props);
 | 
			
		||||
  pinos_properties_free (props);
 | 
			
		||||
 | 
			
		||||
  socket = pinos_client_node_get_socket_pair (PINOS_CLIENT_NODE (node), &error);
 | 
			
		||||
  if (socket == NULL)
 | 
			
		||||
| 
						 | 
				
			
			@ -265,6 +266,7 @@ handle_create_client_node (PinosDaemon1           *interface,
 | 
			
		|||
 | 
			
		||||
  fdlist = g_unix_fd_list_new ();
 | 
			
		||||
  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_variant_new ("(oh)", object_path, fdidx), fdlist);
 | 
			
		||||
| 
						 | 
				
			
			@ -532,7 +534,7 @@ pinos_daemon_find_port (PinosDaemon     *daemon,
 | 
			
		|||
{
 | 
			
		||||
  PinosDaemonPrivate *priv;
 | 
			
		||||
  PinosPort *best = NULL;
 | 
			
		||||
  GList *nodes, *ports;
 | 
			
		||||
  GList *nodes, *ports, *walk;
 | 
			
		||||
  gboolean have_name, created_port = FALSE;
 | 
			
		||||
 | 
			
		||||
  g_return_val_if_fail (PINOS_IS_DAEMON (daemon), NULL);
 | 
			
		||||
| 
						 | 
				
			
			@ -557,8 +559,9 @@ pinos_daemon_find_port (PinosDaemon     *daemon,
 | 
			
		|||
      node_found = TRUE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (ports = pinos_node_get_ports (n); ports; ports = g_list_next (ports)) {
 | 
			
		||||
      PinosPort *p = ports->data;
 | 
			
		||||
    ports = pinos_node_get_ports (n);
 | 
			
		||||
    for (walk = ports; walk; walk = g_list_next (walk)) {
 | 
			
		||||
      PinosPort *p = walk->data;
 | 
			
		||||
      PinosDirection dir;
 | 
			
		||||
 | 
			
		||||
      g_object_get (p, "direction", &dir, NULL);
 | 
			
		||||
| 
						 | 
				
			
			@ -572,6 +575,8 @@ pinos_daemon_find_port (PinosDaemon     *daemon,
 | 
			
		|||
        break;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    g_list_free (ports);
 | 
			
		||||
 | 
			
		||||
    if (best == NULL && node_found) {
 | 
			
		||||
      guint id;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -572,6 +572,8 @@ pinos_link_dispose (GObject * object)
 | 
			
		|||
 | 
			
		||||
  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->output, 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)) {
 | 
			
		||||
      filename = find_module (newpath, name);
 | 
			
		||||
    }
 | 
			
		||||
    g_free (newpath);
 | 
			
		||||
 | 
			
		||||
    if (filename != NULL)
 | 
			
		||||
      break;
 | 
			
		||||
| 
						 | 
				
			
			@ -263,6 +264,8 @@ pinos_module_load (PinosDaemon  * daemon,
 | 
			
		|||
  g_debug ("trying to load module: %s (%s)", name, filename);
 | 
			
		||||
 | 
			
		||||
  gmodule = g_module_open (filename, G_MODULE_BIND_LOCAL);
 | 
			
		||||
  g_free (filename);
 | 
			
		||||
 | 
			
		||||
  if (gmodule == NULL) {
 | 
			
		||||
    g_set_error (err, PINOS_MODULE_ERROR, PINOS_MODULE_ERROR_LOADING,
 | 
			
		||||
        "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);
 | 
			
		||||
  pinos_daemon_unexport (priv->daemon, priv->object_path);
 | 
			
		||||
  g_clear_pointer (&priv->object_path, g_free);
 | 
			
		||||
  pinos_daemon_remove_node (priv->daemon, node);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue