Module API – Developer Documentation – PulseAudio (original) (raw)

Logo

Home About Community Download Documentation Planet

↩ Back to Developer Documentation


Interface of pa_module

When you write a module, it can be thought as a subclass of pa_module, if you're familiar with the object oriented programming concepts. pa_module with its associated functions define some basic functionality that all the different modules include and refine. Let's see if there's any useful stuff in that basic functionality.

I'll walk you through the interface, see pulsecore/module.h for a more compact reference, and also for the complete definitions, as I won't repeat the field and function types here.

struct pa_module

core

name

argument

index

dl

init

done

userdata

The next three fields are part of the automatic unloading functionality, and you need to care about only one of them (n_used), and you can ignore that too, if you don't want to support the functionality.

n_used

auto_unload

last_used_time

unload_requested

Functions and macros

Loading and unloading functions are primarily for the daemon, except pa_module_unload_request, but if you want to do some module management, feel free.

pa_module_load

pa_module_unload

pa_module_unload_by_index

pa_module_unload_all

pa_module_unload_unused

pa_module_unload_request

pa_module_set_used

PA_MODULE_AUTHOR

PA_MODULE_DESCRIPTION

PA_MODULE_USAGE

PA_MODULE_VERSION

pa_module_get_info

Automatic unloading

Automatic unloading is part of the autoload feature of PulseAudio. The modules that the user has told the system to load automatically are also unloaded automatically, if they support it.

If you want your module to support automatic unloading, keep the n_used field updated by calling pa_module_set_used in right places. What are the "right places", is fully up to you. Setting the user count to zero causes an unload if the counter isn't reset to some other value quickly.