mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	cleanups
This commit is contained in:
		
							parent
							
								
									dfbfb4c9ee
								
							
						
					
					
						commit
						0d2fa5ebc8
					
				
					 6 changed files with 66 additions and 79 deletions
				
			
		| 
						 | 
				
			
			@ -47,7 +47,60 @@ typedef struct {
 | 
			
		|||
  PinosListener link_state_changed;
 | 
			
		||||
} ModuleImpl;
 | 
			
		||||
 | 
			
		||||
static void try_link_port (PinosNode *node, PinosPort *port, ModuleImpl *impl);
 | 
			
		||||
static void
 | 
			
		||||
try_link_port (PinosNode *node, PinosPort *port, ModuleImpl *impl)
 | 
			
		||||
{
 | 
			
		||||
  //PinosClient *client;
 | 
			
		||||
  PinosProperties *props;
 | 
			
		||||
  const char *path;
 | 
			
		||||
  char *error = NULL;
 | 
			
		||||
  PinosLink *link;
 | 
			
		||||
 | 
			
		||||
  props = node->properties;
 | 
			
		||||
  if (props == NULL)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  path = pinos_properties_get (props, "pinos.target.node");
 | 
			
		||||
 | 
			
		||||
  pinos_log_debug ("module %p: try to find and link to node %s", impl, path);
 | 
			
		||||
 | 
			
		||||
  if (path) {
 | 
			
		||||
    PinosPort *target;
 | 
			
		||||
 | 
			
		||||
    target = pinos_core_find_port (impl->core,
 | 
			
		||||
                                   port,
 | 
			
		||||
                                   atoi (path),
 | 
			
		||||
                                   NULL,
 | 
			
		||||
                                   NULL,
 | 
			
		||||
                                   &error);
 | 
			
		||||
    if (target == NULL)
 | 
			
		||||
      goto error;
 | 
			
		||||
 | 
			
		||||
    if (port->direction == PINOS_DIRECTION_OUTPUT)
 | 
			
		||||
      link = pinos_port_link (port, target, NULL, NULL, &error);
 | 
			
		||||
    else
 | 
			
		||||
      link = pinos_port_link (target, port, NULL, NULL, &error);
 | 
			
		||||
 | 
			
		||||
    if (link == NULL)
 | 
			
		||||
      goto error;
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
    client = pinos_node_get_client (node);
 | 
			
		||||
    if (client)
 | 
			
		||||
      pinos_client_add_object (client, &link->object);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    pinos_link_activate (link);
 | 
			
		||||
  }
 | 
			
		||||
  return;
 | 
			
		||||
 | 
			
		||||
error:
 | 
			
		||||
  {
 | 
			
		||||
    pinos_node_report_error (node, error);
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
on_link_port_unlinked (PinosListener *listener,
 | 
			
		||||
| 
						 | 
				
			
			@ -106,60 +159,6 @@ on_link_state_changed (PinosListener *listener,
 | 
			
		|||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
try_link_port (PinosNode *node, PinosPort *port, ModuleImpl *impl)
 | 
			
		||||
{
 | 
			
		||||
  //PinosClient *client;
 | 
			
		||||
  PinosProperties *props;
 | 
			
		||||
  const char *path;
 | 
			
		||||
  char *error = NULL;
 | 
			
		||||
  PinosLink *link;
 | 
			
		||||
 | 
			
		||||
  props = node->properties;
 | 
			
		||||
  if (props == NULL)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  path = pinos_properties_get (props, "pinos.target.node");
 | 
			
		||||
 | 
			
		||||
  pinos_log_debug ("module %p: try to find and link to node %s", impl, path);
 | 
			
		||||
 | 
			
		||||
  if (path) {
 | 
			
		||||
    PinosPort *target;
 | 
			
		||||
 | 
			
		||||
    target = pinos_core_find_port (impl->core,
 | 
			
		||||
                                   port,
 | 
			
		||||
                                   atoi (path),
 | 
			
		||||
                                   NULL,
 | 
			
		||||
                                   NULL,
 | 
			
		||||
                                   &error);
 | 
			
		||||
    if (target == NULL)
 | 
			
		||||
      goto error;
 | 
			
		||||
 | 
			
		||||
    if (port->direction == PINOS_DIRECTION_OUTPUT)
 | 
			
		||||
      link = pinos_port_link (port, target, NULL, NULL, &error);
 | 
			
		||||
    else
 | 
			
		||||
      link = pinos_port_link (target, port, NULL, NULL, &error);
 | 
			
		||||
 | 
			
		||||
    if (link == NULL)
 | 
			
		||||
      goto error;
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
    client = pinos_node_get_client (node);
 | 
			
		||||
    if (client)
 | 
			
		||||
      pinos_client_add_object (client, &link->object);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    pinos_link_activate (link);
 | 
			
		||||
  }
 | 
			
		||||
  return;
 | 
			
		||||
 | 
			
		||||
error:
 | 
			
		||||
  {
 | 
			
		||||
    pinos_node_report_error (node, error);
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
on_port_added (PinosListener *listener,
 | 
			
		||||
               PinosNode     *node,
 | 
			
		||||
| 
						 | 
				
			
			@ -256,7 +255,7 @@ on_global_removed (PinosListener *listener,
 | 
			
		|||
 *
 | 
			
		||||
 * Returns: a new #ModuleImpl
 | 
			
		||||
 */
 | 
			
		||||
ModuleImpl *
 | 
			
		||||
static ModuleImpl *
 | 
			
		||||
module_new (PinosCore       *core,
 | 
			
		||||
            PinosProperties *properties)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -284,7 +283,8 @@ module_new (PinosCore       *core,
 | 
			
		|||
  return impl;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
#if 0
 | 
			
		||||
static void
 | 
			
		||||
module_destroy (ModuleImpl *impl)
 | 
			
		||||
{
 | 
			
		||||
  pinos_log_debug ("module %p: destroy", impl);
 | 
			
		||||
| 
						 | 
				
			
			@ -300,10 +300,9 @@ module_destroy (ModuleImpl *impl)
 | 
			
		|||
  pinos_signal_remove (&impl->link_state_changed);
 | 
			
		||||
  free (impl);
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
bool pinos__module_init (PinosModule *module, const char * args);
 | 
			
		||||
 | 
			
		||||
G_MODULE_EXPORT bool
 | 
			
		||||
bool
 | 
			
		||||
pinos__module_init (PinosModule * module, const char * args)
 | 
			
		||||
{
 | 
			
		||||
  module_new (module->core, NULL);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -673,7 +673,7 @@ pinos_protocol_dbus_destroy (PinosProtocolDBus *proto)
 | 
			
		|||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
G_MODULE_EXPORT bool
 | 
			
		||||
bool
 | 
			
		||||
pinos__module_init (PinosModule * module, const char * args)
 | 
			
		||||
{
 | 
			
		||||
  pinos_protocol_dbus_new (module->core, NULL);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,9 +24,7 @@
 | 
			
		|||
#include "spa-monitor.h"
 | 
			
		||||
#include "spa-node.h"
 | 
			
		||||
 | 
			
		||||
bool pinos__module_init (PinosModule *module, const char * args);
 | 
			
		||||
 | 
			
		||||
G_MODULE_EXPORT bool
 | 
			
		||||
bool
 | 
			
		||||
pinos__module_init (PinosModule * module, const char * args)
 | 
			
		||||
{
 | 
			
		||||
  pinos_spa_monitor_load (module->core, "build/spa/plugins/alsa/libspa-alsa.so", "alsa-monitor", args);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1289,8 +1289,6 @@ pinos_client_node_new (PinosCore       *core,
 | 
			
		|||
  PinosClientNodeImpl *impl;
 | 
			
		||||
  PinosClientNode *this;
 | 
			
		||||
 | 
			
		||||
  g_return_val_if_fail (core, NULL);
 | 
			
		||||
 | 
			
		||||
  impl = calloc (1, sizeof (PinosClientNodeImpl));
 | 
			
		||||
  impl->core = core;
 | 
			
		||||
  impl->ctrl_fd = -1;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,17 +34,17 @@ libpinoscore_c_args = [
 | 
			
		|||
]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
libpinoscore = shared_library('pinoscore', pinoscore_sources, gdbus_target,
 | 
			
		||||
libpinoscore = shared_library('pinoscore', pinoscore_sources,
 | 
			
		||||
  version : libversion,
 | 
			
		||||
  soversion : soversion,
 | 
			
		||||
  c_args : libpinoscore_c_args,
 | 
			
		||||
  include_directories : [configinc, spa_inc],
 | 
			
		||||
  link_with : spalib,
 | 
			
		||||
  install : true,
 | 
			
		||||
  dependencies : [gobject_dep, gmodule_dep, glib_dep, gio_dep, mathlib, dl_lib, pinos_dep],
 | 
			
		||||
  dependencies : [mathlib, dl_lib, pinos_dep],
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
pinoscore_dep = declare_dependency(link_with : libpinoscore,
 | 
			
		||||
  include_directories : [configinc, spa_inc],
 | 
			
		||||
  dependencies : [glib_dep, gobject_dep, gmodule_dep, pinos_dep],
 | 
			
		||||
  dependencies : [pinos_dep],
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -61,8 +61,8 @@ update_port_ids (PinosNode *node, bool create)
 | 
			
		|||
                        &n_output_ports,
 | 
			
		||||
                        &max_output_ports);
 | 
			
		||||
 | 
			
		||||
  input_port_ids = g_alloca (sizeof (uint32_t) * n_input_ports);
 | 
			
		||||
  output_port_ids = g_alloca (sizeof (uint32_t) * n_output_ports);
 | 
			
		||||
  input_port_ids = alloca (sizeof (uint32_t) * n_input_ports);
 | 
			
		||||
  output_port_ids = alloca (sizeof (uint32_t) * n_output_ports);
 | 
			
		||||
 | 
			
		||||
  spa_node_get_port_ids (node->node,
 | 
			
		||||
                         max_input_ports,
 | 
			
		||||
| 
						 | 
				
			
			@ -600,8 +600,6 @@ pinos_node_get_free_port (PinosNode       *node,
 | 
			
		|||
  SpaList *ports;
 | 
			
		||||
  PinosPort *port = NULL, *p;
 | 
			
		||||
 | 
			
		||||
  g_return_val_if_fail (node, NULL);
 | 
			
		||||
 | 
			
		||||
  if (direction == PINOS_DIRECTION_INPUT) {
 | 
			
		||||
    max_ports = node->transport->area->max_inputs;
 | 
			
		||||
    n_ports = node->transport->area->n_inputs;
 | 
			
		||||
| 
						 | 
				
			
			@ -674,8 +672,6 @@ pinos_node_set_state (PinosNode      *node,
 | 
			
		|||
{
 | 
			
		||||
  SpaResult res = SPA_RESULT_OK;
 | 
			
		||||
 | 
			
		||||
  g_return_val_if_fail (node, SPA_RESULT_INVALID_ARGUMENTS);
 | 
			
		||||
 | 
			
		||||
  remove_idle_timeout (node);
 | 
			
		||||
 | 
			
		||||
  pinos_log_debug ("node %p: set state %s", node, pinos_node_state_as_string (state));
 | 
			
		||||
| 
						 | 
				
			
			@ -786,8 +782,6 @@ pinos_node_report_idle (PinosNode *node)
 | 
			
		|||
{
 | 
			
		||||
  PinosNodeImpl *impl = SPA_CONTAINER_OF (node, PinosNodeImpl, this);
 | 
			
		||||
 | 
			
		||||
  g_return_if_fail (node);
 | 
			
		||||
 | 
			
		||||
  pinos_log_debug ("node %p: report idle", node);
 | 
			
		||||
  pinos_node_set_state (node, PINOS_NODE_STATE_IDLE);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -806,8 +800,6 @@ pinos_node_report_idle (PinosNode *node)
 | 
			
		|||
void
 | 
			
		||||
pinos_node_report_busy (PinosNode *node)
 | 
			
		||||
{
 | 
			
		||||
  g_return_if_fail (node);
 | 
			
		||||
 | 
			
		||||
  pinos_log_debug ("node %p: report busy", node);
 | 
			
		||||
  pinos_node_set_state (node, PINOS_NODE_STATE_RUNNING);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue