This fixes several integer overflow problems in the POD parser, as well
as fixing a returns-twice warning from GCC and integer truncation
problems in SPA_FLAG_CLEAR and SPA_ROUND_DOWN_N. The integer overflows
can result in a tiny POD being treated as a huge one, causing
out-of-bounds reads.
At the moment, cross compilation may not work in certain cases because
checks are carried out against the build machine instead of the host machine.
Replace uses of `build_machine` with `host_machine` to fix that.
In native compilation, all three "machine objects" available in meson
are the same, so this change should have no effect in that case.
More: https://mesonbuild.com/Cross-compilation.html
Unfortunately, libX11 has global error and I/O error handlers,
which make it inconvenient to use them from library code.
Since libX11 1.7.0, there is a per-display "exit_handler" which
is called from `_XIOError()`, however, the global I/O error
handler is still called before that, and that - by default -
calls `exit(1)` in `_XDefaultIOError()` after printing the error
to stderr.
To avoid exiting, custom handlers will be registered when
libpipewire-module-x11-bell.so is loaded given that at
that moment the default handlers are installed.
When the shared object is unloaded, the handlers will
be reset to the default ones given that the currently
registered handlers are the ones that were registered
when the module was loaded.
The logic only works correctly if there are no concurrent
calls to `XSet{IO}ErrorHandler()` while `{set,restore}_x11_handlers()`
is running. Since module-x11-bell is probably mostly going to
be loaded in `pipewire-pulse`, this seems like a reasonable
assumption to make.
Since meson 0.59.0, a feature object has an `allowed()`
method which returns true when the feature is set to
'enabled' or 'auto'.
Utilize that instead of the previously used
not feature.disabled()
Most feature checks already use #ifdef, and do not care about
the value of the macro. Convert all feature checks to do that,
and simplify the meson build scripts by replacing
if cond
cdata.set('X', 1)
endif
with
cdata.set('X', cond)
Since 01c6fd0a88 the
minimum required meson version is 0.59.0, and since
meson 0.58.0, `get_variable()` on a dependency object
accepts a positional argument. The "type" of variable
(internal, pkgconfig, etc.) in that case does not need
to be specified explicitly.
Since 01c6fd0a88 the
minimum required meson version is 0.59.0, therefore
there is no need to check if it's at least 0.58.0,
which was needed for the devenv functionality.
I don't think PipeWire currently has a way to temporarily alias
module-rtkit to module-rt though, so right now this would break realtime
scheduling for people with modified configs that use module-rtkit.
When creating a new build directory, Meson prints a warning:
WARNING: Project specifies a minimum meson_version '>= 0.56.0' but
uses features which were added in newer versions:
* 0.59.0: {'unescaped_variables arg in pkgconfig.generate'}
Since 0.59.0 was released a while ago and no one has complained so far,
it should be reasonable to just bump the minimum version required,
rather than try to make it 0.56.0 compliant.
Use `meson.project_{build,source}_root()` instead of
`meson.{build,source}_root()` because those functions
do not work as expected when used inside a subproject,
and they have been deprecated in meson 0.56.0.
The paths are calculated relative to the project root,
so use the appropriate functions to retrieve it
instead of using the current build/source directory.