mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	modules: support overriding default module arguments
Add support for some modules to use a module.$NAME.args config section to override the arguments of the module. Update the docs. Add more conditions to the module loading, use !false to also load the module when the condition is not set and so that we don't have to explicitly set each condition to true. Improve module-profiler example config.
This commit is contained in:
		
							parent
							
								
									4cf4bd210f
								
							
						
					
					
						commit
						ec972d4fdf
					
				
					 4 changed files with 89 additions and 24 deletions
				
			
		| 
						 | 
					@ -54,14 +54,6 @@ context.properties = {
 | 
				
			||||||
    #
 | 
					    #
 | 
				
			||||||
    #settings.check-quantum      = false
 | 
					    #settings.check-quantum      = false
 | 
				
			||||||
    #settings.check-rate         = false
 | 
					    #settings.check-rate         = false
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # keys checked below to disable module loading
 | 
					 | 
				
			||||||
    module.x11.bell = true
 | 
					 | 
				
			||||||
    # enables autoloading of access module, when disabled an alternative
 | 
					 | 
				
			||||||
    # access module needs to be loaded.
 | 
					 | 
				
			||||||
    module.access = true
 | 
					 | 
				
			||||||
    # enables autoloading of module-jackdbus-detect
 | 
					 | 
				
			||||||
    module.jackdbus-detect = true
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
context.properties.rules = [
 | 
					context.properties.rules = [
 | 
				
			||||||
| 
						 | 
					@ -114,6 +106,7 @@ context.modules = [
 | 
				
			||||||
    # RTKit if the user doesn't have permission to use regular realtime
 | 
					    # RTKit if the user doesn't have permission to use regular realtime
 | 
				
			||||||
    # scheduling. You can also clamp utilisation values to improve scheduling
 | 
					    # scheduling. You can also clamp utilisation values to improve scheduling
 | 
				
			||||||
    # on embedded and heterogeneous systems, e.g. Arm big.LITTLE devices.
 | 
					    # on embedded and heterogeneous systems, e.g. Arm big.LITTLE devices.
 | 
				
			||||||
 | 
					    # use module.rt.args = { ... } to override the arguments.
 | 
				
			||||||
    { name = libpipewire-module-rt
 | 
					    { name = libpipewire-module-rt
 | 
				
			||||||
        args = {
 | 
					        args = {
 | 
				
			||||||
            nice.level    = -11
 | 
					            nice.level    = -11
 | 
				
			||||||
| 
						 | 
					@ -124,6 +117,7 @@ context.modules = [
 | 
				
			||||||
            #uclamp.max = 1024
 | 
					            #uclamp.max = 1024
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        flags = [ ifexists nofail ]
 | 
					        flags = [ ifexists nofail ]
 | 
				
			||||||
 | 
					        condition = [ { module.rt = !false } ]
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # The native communication protocol.
 | 
					    # The native communication protocol.
 | 
				
			||||||
| 
						 | 
					@ -137,34 +131,51 @@ context.modules = [
 | 
				
			||||||
    # The profile module. Allows application to access profiler
 | 
					    # The profile module. Allows application to access profiler
 | 
				
			||||||
    # and performance data. It provides an interface that is used
 | 
					    # and performance data. It provides an interface that is used
 | 
				
			||||||
    # by pw-top and pw-profiler.
 | 
					    # by pw-top and pw-profiler.
 | 
				
			||||||
    { name = libpipewire-module-profiler }
 | 
					    # use module.profiler.args = { ... } to override the arguments.
 | 
				
			||||||
 | 
					    { name = libpipewire-module-profiler
 | 
				
			||||||
 | 
					        args = {
 | 
				
			||||||
 | 
					            #profile.interval.ms = 0
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        condition = [ { module.profiler = !false } ]
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Allows applications to create metadata objects. It creates
 | 
					    # Allows applications to create metadata objects. It creates
 | 
				
			||||||
    # a factory for Metadata objects.
 | 
					    # a factory for Metadata objects.
 | 
				
			||||||
    { name = libpipewire-module-metadata }
 | 
					    { name = libpipewire-module-metadata
 | 
				
			||||||
 | 
					        condition = [ { module.metadata = !false } ]
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Creates a factory for making devices that run in the
 | 
					    # Creates a factory for making devices that run in the
 | 
				
			||||||
    # context of the PipeWire server.
 | 
					    # context of the PipeWire server.
 | 
				
			||||||
    { name = libpipewire-module-spa-device-factory }
 | 
					    { name = libpipewire-module-spa-device-factory
 | 
				
			||||||
 | 
					        condition = [ { module.spa-device-factory = !false } ]
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Creates a factory for making nodes that run in the
 | 
					    # Creates a factory for making nodes that run in the
 | 
				
			||||||
    # context of the PipeWire server.
 | 
					    # context of the PipeWire server.
 | 
				
			||||||
    { name = libpipewire-module-spa-node-factory }
 | 
					    { name = libpipewire-module-spa-node-factory
 | 
				
			||||||
 | 
					        condition = [ { module.spa-node-factory = !false } ]
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Allows creating nodes that run in the context of the
 | 
					    # Allows creating nodes that run in the context of the
 | 
				
			||||||
    # client. Is used by all clients that want to provide
 | 
					    # client. Is used by all clients that want to provide
 | 
				
			||||||
    # data to PipeWire.
 | 
					    # data to PipeWire.
 | 
				
			||||||
    { name = libpipewire-module-client-node }
 | 
					    { name = libpipewire-module-client-node
 | 
				
			||||||
 | 
					        condition = [ { module.client-node = !false } ]
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Allows creating devices that run in the context of the
 | 
					    # Allows creating devices that run in the context of the
 | 
				
			||||||
    # client. Is used by the session manager.
 | 
					    # client. Is used by the session manager.
 | 
				
			||||||
    { name = libpipewire-module-client-device }
 | 
					    { name = libpipewire-module-client-device
 | 
				
			||||||
 | 
					        condition = [ { module.client-device = !false } ]
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # The portal module monitors the PID of the portal process
 | 
					    # The portal module monitors the PID of the portal process
 | 
				
			||||||
    # and tags connections with the same PID as portal
 | 
					    # and tags connections with the same PID as portal
 | 
				
			||||||
    # connections.
 | 
					    # connections.
 | 
				
			||||||
    { name = libpipewire-module-portal
 | 
					    { name = libpipewire-module-portal
 | 
				
			||||||
        flags = [ ifexists nofail ]
 | 
					        flags = [ ifexists nofail ]
 | 
				
			||||||
 | 
					        condition = [ { module.portal = !false } ]
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # The access module can perform access checks and block
 | 
					    # The access module can perform access checks and block
 | 
				
			||||||
| 
						 | 
					@ -178,18 +189,24 @@ context.modules = [
 | 
				
			||||||
            # for now enabled by default if access.socket is not specified
 | 
					            # for now enabled by default if access.socket is not specified
 | 
				
			||||||
            #access.legacy = true
 | 
					            #access.legacy = true
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        condition = [ { module.access = true } ]
 | 
					        condition = [ { module.access = !false } ]
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Makes a factory for wrapping nodes in an adapter with a
 | 
					    # Makes a factory for wrapping nodes in an adapter with a
 | 
				
			||||||
    # converter and resampler.
 | 
					    # converter and resampler.
 | 
				
			||||||
    { name = libpipewire-module-adapter }
 | 
					    { name = libpipewire-module-adapter
 | 
				
			||||||
 | 
					        condition = [ { module.adapter = !false } ]
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Makes a factory for creating links between ports.
 | 
					    # Makes a factory for creating links between ports.
 | 
				
			||||||
    { name = libpipewire-module-link-factory }
 | 
					    { name = libpipewire-module-link-factory
 | 
				
			||||||
 | 
					        condition = [ { module.link-factory = !false } ]
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Provides factories to make session manager objects.
 | 
					    # Provides factories to make session manager objects.
 | 
				
			||||||
    { name = libpipewire-module-session-manager }
 | 
					    { name = libpipewire-module-session-manager
 | 
				
			||||||
 | 
					        condition = [ { module.session-manager = !false } ]
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Use libcanberra to play X11 Bell
 | 
					    # Use libcanberra to play X11 Bell
 | 
				
			||||||
    { name = libpipewire-module-x11-bell
 | 
					    { name = libpipewire-module-x11-bell
 | 
				
			||||||
| 
						 | 
					@ -200,8 +217,11 @@ context.modules = [
 | 
				
			||||||
            #x11.xauthority = null
 | 
					            #x11.xauthority = null
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        flags = [ ifexists nofail ]
 | 
					        flags = [ ifexists nofail ]
 | 
				
			||||||
        condition = [ { module.x11.bell = true } ]
 | 
					        condition = [ { module.x11.bell = !false } ]
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    # The JACK DBus detection module. When jackdbus is started, this
 | 
				
			||||||
 | 
					    # will automatically make PipeWire become a JACK client.
 | 
				
			||||||
 | 
					    # use module.jackdbus-detect.args = { ... } to override the arguments.
 | 
				
			||||||
    { name = libpipewire-module-jackdbus-detect
 | 
					    { name = libpipewire-module-jackdbus-detect
 | 
				
			||||||
        args = {
 | 
					        args = {
 | 
				
			||||||
            #jack.library     = libjack.so.0
 | 
					            #jack.library     = libjack.so.0
 | 
				
			||||||
| 
						 | 
					@ -223,7 +243,7 @@ context.modules = [
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        flags = [ ifexists nofail ]
 | 
					        flags = [ ifexists nofail ]
 | 
				
			||||||
        condition = [ { module.jackdbus-detect = true } ]
 | 
					        condition = [ { module.jackdbus-detect = !false } ]
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -258,6 +278,7 @@ context.objects = [
 | 
				
			||||||
            #clock.id       = monotonic # realtime | tai | monotonic-raw | boottime
 | 
					            #clock.id       = monotonic # realtime | tai | monotonic-raw | boottime
 | 
				
			||||||
            #clock.name     = "clock.system.monotonic"
 | 
					            #clock.name     = "clock.system.monotonic"
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        condition = [ { factory.dummy-driver = !false } ]
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    { factory = spa-node-factory
 | 
					    { factory = spa-node-factory
 | 
				
			||||||
        args = {
 | 
					        args = {
 | 
				
			||||||
| 
						 | 
					@ -269,6 +290,7 @@ context.objects = [
 | 
				
			||||||
            node.freewheel  = true
 | 
					            node.freewheel  = true
 | 
				
			||||||
            #freewheel.wait = 10
 | 
					            #freewheel.wait = 10
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        condition = [ { factory.freewheel-driver = !false } ]
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # This creates a new Source node. It will have input ports
 | 
					    # This creates a new Source node. It will have input ports
 | 
				
			||||||
| 
						 | 
					@ -332,7 +354,7 @@ context.exec = [
 | 
				
			||||||
    # Run the session manager with -h for options.
 | 
					    # Run the session manager with -h for options.
 | 
				
			||||||
    #
 | 
					    #
 | 
				
			||||||
    @sm_comment@{ path = "@session_manager_path@" args = "@session_manager_args@"
 | 
					    @sm_comment@{ path = "@session_manager_path@" args = "@session_manager_args@"
 | 
				
			||||||
    @sm_comment@  condition = [ { exec.session-manager = null } { exec.session-manager = true } ] }
 | 
					    @sm_comment@  condition = [ { exec.session-manager = !false } ] }
 | 
				
			||||||
    #
 | 
					    #
 | 
				
			||||||
    # You can optionally start the pulseaudio-server here as well
 | 
					    # You can optionally start the pulseaudio-server here as well
 | 
				
			||||||
    # but it is better to start it as a systemd service.
 | 
					    # but it is better to start it as a systemd service.
 | 
				
			||||||
| 
						 | 
					@ -340,5 +362,5 @@ context.exec = [
 | 
				
			||||||
    # on another address with the -a option (eg. -a tcp:4713).
 | 
					    # on another address with the -a option (eg. -a tcp:4713).
 | 
				
			||||||
    #
 | 
					    #
 | 
				
			||||||
    @pulse_comment@{ path = "@pipewire_path@" args = [ "-c" "pipewire-pulse.conf" ]
 | 
					    @pulse_comment@{ path = "@pipewire_path@" args = [ "-c" "pipewire-pulse.conf" ]
 | 
				
			||||||
    @pulse_comment@  condition = [ { exec.pipewire-pulse = null } { exec.pipewire-pulse = true } ] }
 | 
					    @pulse_comment@  condition = [ { exec.pipewire-pulse = !false } ] }
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,6 +61,17 @@
 | 
				
			||||||
 *  }
 | 
					 *  }
 | 
				
			||||||
 * ]
 | 
					 * ]
 | 
				
			||||||
 *\endcode
 | 
					 *\endcode
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 * ## Config override
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * A `module.jackdbus-detect.args` config section can be added in the override directory
 | 
				
			||||||
 | 
					 * to override the module arguments.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 *\code{.unparsed}
 | 
				
			||||||
 | 
					 * module.jackdbus-detect.args = {
 | 
				
			||||||
 | 
					 *     #tunnel.mode    = duplex
 | 
				
			||||||
 | 
					 * }
 | 
				
			||||||
 | 
					 *\endcode
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -359,6 +370,9 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
 | 
				
			||||||
	impl->context = context;
 | 
						impl->context = context;
 | 
				
			||||||
	impl->properties = args ? pw_properties_new_string(args) : NULL;
 | 
						impl->properties = args ? pw_properties_new_string(args) : NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (impl->properties)
 | 
				
			||||||
 | 
							pw_context_conf_update_props(context, "module."NAME".args", impl->properties);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	impl->conn = spa_dbus_get_connection(dbus, SPA_DBUS_TYPE_SESSION);
 | 
						impl->conn = spa_dbus_get_connection(dbus, SPA_DBUS_TYPE_SESSION);
 | 
				
			||||||
	if (impl->conn == NULL) {
 | 
						if (impl->conn == NULL) {
 | 
				
			||||||
		res = -errno;
 | 
							res = -errno;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,7 +38,7 @@
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * - `profile.interval.ms`: Can be used to avoid gathering profiling information
 | 
					 * - `profile.interval.ms`: Can be used to avoid gathering profiling information
 | 
				
			||||||
 *			    on every processing cycle. This allows trading off
 | 
					 *			    on every processing cycle. This allows trading off
 | 
				
			||||||
 *			    CPU usage for profiling accuracy.
 | 
					 *			    CPU usage for profiling accuracy. Default 0
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * ## Example configuration
 | 
					 * ## Example configuration
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					@ -47,9 +47,24 @@
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 *\code{.unparsed}
 | 
					 *\code{.unparsed}
 | 
				
			||||||
 * context.modules = [
 | 
					 * context.modules = [
 | 
				
			||||||
 * { name = libpipewire-module-profiler }
 | 
					 * { name = libpipewire-module-profiler
 | 
				
			||||||
 | 
					 *   args = {
 | 
				
			||||||
 | 
					 *       #profile.interval.ms = 0
 | 
				
			||||||
 | 
					 *   }
 | 
				
			||||||
 | 
					 * }
 | 
				
			||||||
 * ]
 | 
					 * ]
 | 
				
			||||||
 *\endcode
 | 
					 *\endcode
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 * ## Config override
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * A `module.profiler.args` config section can be added in the override directory
 | 
				
			||||||
 | 
					 * to override the module arguments.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 *\code{.unparsed}
 | 
				
			||||||
 | 
					 * module.profiler.args = {
 | 
				
			||||||
 | 
					 *     #profile.interval.ms = 10
 | 
				
			||||||
 | 
					 * }
 | 
				
			||||||
 | 
					 *\endcode
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * ## See also
 | 
					 * ## See also
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					@ -513,6 +528,8 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
 | 
				
			||||||
	impl->properties = props;
 | 
						impl->properties = props;
 | 
				
			||||||
	impl->main_loop = pw_context_get_main_loop(impl->context);
 | 
						impl->main_loop = pw_context_get_main_loop(impl->context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						pw_context_conf_update_props(context, "module."NAME".args", props);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	impl->interval = SPA_NSEC_PER_MSEC *
 | 
						impl->interval = SPA_NSEC_PER_MSEC *
 | 
				
			||||||
		pw_properties_get_uint32(props, "profile.interval.ms", DEFAULT_INTERVAL);
 | 
							pw_properties_get_uint32(props, "profile.interval.ms", DEFAULT_INTERVAL);
 | 
				
			||||||
	impl->last_signal_time = 0;
 | 
						impl->last_signal_time = 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -115,6 +115,17 @@
 | 
				
			||||||
 * }
 | 
					 * }
 | 
				
			||||||
 * ]
 | 
					 * ]
 | 
				
			||||||
 *\endcode
 | 
					 *\endcode
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * ## Config override
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * A `module.rt.args` config section can be added in the override directory
 | 
				
			||||||
 | 
					 * to override the module arguments.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 *\code{.unparsed}
 | 
				
			||||||
 | 
					 * module.rt.args = {
 | 
				
			||||||
 | 
					 *      nice.level = 22
 | 
				
			||||||
 | 
					 * }
 | 
				
			||||||
 | 
					 *\endcode
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define NAME "rt"
 | 
					#define NAME "rt"
 | 
				
			||||||
| 
						 | 
					@ -1076,6 +1087,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
 | 
				
			||||||
		res = -errno;
 | 
							res = -errno;
 | 
				
			||||||
		goto error;
 | 
							goto error;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						pw_context_conf_update_props(context, "module."NAME".args", props);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	impl->context = context;
 | 
						impl->context = context;
 | 
				
			||||||
	impl->nice_level = pw_properties_get_int32(props, "nice.level", DEFAULT_NICE_LEVEL);
 | 
						impl->nice_level = pw_properties_get_int32(props, "nice.level", DEFAULT_NICE_LEVEL);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue