Use the param user field to tag changes in the params.
codec changes emits an EnumFormat and Props change.
Accumulate various param changes and emit them together.
ALSA has problems with creating more than 8 configs per card so cache
the config per card and reuse it.
Fixes problems with no devices after logging out and in again because
ALSA can't create UCM profiles anymore.
See #1553
If you use multiple BT adapters, it's annoying that PW tries to
autoconnect to the device via all available adapters, and you end up
with multiple connections to the same device (which does not necessarily
work).
Avoid this by autoconnecting with only the first adapter that sees the
device.
We don't currently implement encoding for the duplex channel
for these codecs, so they are not fully functional as A2DP sinks,
and their main use is anyway with headphones.
Also, the number of endpoints in BlueZ appears to be limited, and
appears to be counted across all adapters. Unclear whether this comes
from AVDTP limitation, but currently plugging in a second BT adapter
causes the second media application registration to fail. This change
reduces the number of endpoints enough so that registration succeeds for
two adapters.
We need to manage our own flags based on the direction of the follower.
We also need to make sure we only clear the NEED_CONFIGURE flag
after we are actually configured, not just when we configured our
internal converter.
See #1548
For hdmi and iec958 devices, enumerate the iec958 formats and
codecs. Initially only PCM is supported as a codec but with
a property or an init option, the list of codecs can be dynamically
configured.
Add Format subtype and codec property.
Add codecs to include in the format codec property.
Add property to configure elements with supported codecs.
Add type info.
When in passthrough mode, use the position io to update the
io_rate_match fields for the follower. This makes it possible for the
follower to also provide the right amount of data when the converter
is not selected in passthrough.
Add an option to configure the converter in None port config where it
removes all the ports. We can use this when removing the converter to
make sure all it's ports are removed.
When we remove the converter, make sure we expose the follower ports
directly so we can use them for passthrough.
There doesn't seem to be a way to control the A2DP duplex microphone
HW volume gain, and devices sometimes have very low mic volumes.
Work around this by boosting the software volume scale by +20 dB. If it
causes clipping, the user can just reduce the volume to bring SW gain
below 1.0.
aptX-LL sink devices may send back mSBC encoded data corresponding to
microphone input. It appears to be enabled when the bidirectional link
is set in the caps, and the device also supports this.
Implement mSBC decoding in the duplex channel.
Tested to be working on Avantree Aria Pro.
For unknown reason the BT socket when working with A2DP "duplex" stream,
sometimes stops waking up poll when data arrives. Regardless, recv() can
read data packets from it.
To work around this, when A2DP source is in duplex mode, instead of
polling on data, we poll on a timer.
Some non-standard A2DP codecs (FastStream/aptX-LL) have "voice duplex
channel" that can be used to provide an A2DP duplex mode.
Add support for duplex channels, accounting for the fact that the two
directions may be encoded with different actual codecs.
This pushes the latency to 256 samples, which still seems to work
Latency of 128 seems to be too small. (NB. the number of input samples
is also the size of packets sent in bytes)
Since pipewire clients usually use powers of two, this may be the
smallest value that makes sense.
Support the low-latency variant of the aptx codec.
The magic mostly seems to be on the device side, since the stream is the
same as standard aptx, but latency is smaller even if stream/packet
sizes are the same.
Sound output latency is noticeably less than with the standard aptx.
Tested on Sennheiser HD 250 / Avantree Aria Pro.
The codec in principle also supports bidirectional duplex streams,
but that is not implemented here.
The codec IDs are user-visible properties.
Some codecs can have multiple endpoints (e.g. different caps struct, or
multiple possible vendor ids), so this detail should not leak to the
user.
This property is exposed on the device Route and forwarded to the
nodes. It then configured the process_latency.ns field, which
influences the reported port latency.
This makes it possible to change the internal port latency on the
sink and source with pavucontrol and tweak the synchronization to
compensate for internal latencies in the device.
Disable flush polling when we don't have data ready to write to the
socket (or socket send failed). This avoids entering into a poll busy
loop, which may result to rtkit killing the process.
Enable SBC-XQ by default, and move it at the end of the codecs list, so
that bluez does not connect to it automatically except when it is the
codec used previously.
When the codec is disabled by quirks, it won't appear in the codecs
list, and so can't be selected by user (and so won't be connected
automatically).
However, since SelectConfiguration does not carry information which
device is in question, we cannot prevent BlueZ connecting to the codec
even if it's disabled for a specific device. If the "impossible" occurs
regardless, we won't reject the connection and the profile will be shown
as the generic "A2DP" one. If the sound is garbled, the user can select
some other profile that works.
HF indicator 2 (see [assigned-numbers], Hands-Free Profile) is able to
report battery percentage at 1% intervals (in range [0, 100]), contrary
to the `+XAPL` `+IPHONEACCEV` extension which only supports 10%
increments. This does not guarantee increased granularity however, as
peers may still be limited to imprecise battery measurements internally
or round to coarser percentages.
Supporting both additionally broadens the range of devices for which PW
can report its battery level.
[assigned-numbers]:
https://www.bluetooth.com/specifications/assigned-numbers/
We need to do this or else newly plugged devices might not load.
It does not seem to harm UCM config on my machine, so this reverts
3d372424cc
See #1478
When we store the real_volume we get a hardware_volume as stored
in the mixer and a residual software_volume.
When we read the volume from the card, we need to compare this against
the hardware_volume we stored to check if something changed, not
against the real_volume that also contains the leftover software_volume.
spa_strstartswith() is more immediately understandable.
Coccinelle spatch file:
@@
expression E1, E2;
@@
- strstr(E1, E2) != E1
+ !spa_strstartswith(E1, E2)
@@
expression E1, E2;
@@
- strstr(E1, E2) == E1
+ spa_strstartswith(E1, E2)
Applied to the tree except for alsa/acp/compat.h because it looks like
that header is still mostly as-is from PA.
libfreeaptx is a fork of libopenaptx prior to the dubious licensing
situation was introduced to the library.
As it's fully API compatible, let's use that instead for those who
want to use aptX support.
The library source is available at https://github.com/iamthehorker/libfreeaptx
Add a DONT_FIXATE flag to spa_pod_props. The flag avoids fixation
of the property by spa_pod_fixate().
When filtering properties, 'and' the flags together in the filtered
property. This mostly preserves the merged property flags. It also
merges the DONT_FIXATE flags so that when both sides can handle
the non-fixated result, it will be returned.
This can be used to let PipeWire filter out the common property
fields and leave the final selection of fields to the producer. This can
only work when the final selected field can be transported in some
other way than the format param, like on the buffer fields or in
metadata. One use case is negotiation of the DMABUF modifiers.
See #1084
The ringbuffer can't be written to from multiple threads.
When both the main loop and data thread do _invoke, they both write to
the ringbuffer and cause it to be corrupted because the ringbuffer is
not multi-writer safe.
Doing invoke from the thread itself is usually done to flush things out
so we really only need to flush the ringbuffer and call the callback.
See #1451
To fix build warning about a variable being unused in LibCamera::stop():
[1/2] Compiling C++ object spa/plugins/libcamera/libspa-libcamera.so.p/libcamera_wrapper.cpp.o
../spa/plugins/libcamera/libcamera_wrapper.cpp: In member function ‘void LibCamera::stop()’:
../spa/plugins/libcamera/libcamera_wrapper.cpp:531:58: warning: unused variable ‘buffer’ [-Wunused-variable]
531 | for (const std::unique_ptr<FrameBuffer> &buffer : this->allocator_->buffers(stream)) {
| ^~~~~~
The SPA plugin is including a <libcamera/buffer.h> header file, but this
got renamed to <libcamera/framebuffer.h> to match the defined class name:
../spa/plugins/libcamera/libcamera_wrapper.cpp:52:10: fatal error: libcamera/buffer.h: No such file or directory
52 | #include <libcamera/buffer.h>
| ^~~~~~~~~~~~~~~~~~~~
Fixes#1435
If socket write results to EAGAIN/EWOULDBLOCK or rx data starts late,
spa_bt_sco_io_write may return 0, and we should give up and skip ahead
(and not loop in RT thread with very small timeout).
First calculate the size of the aligned payload and then check if
we can fit this aligned payload in the remaining space in the
ringbuffer.
Otherwise we might be able to fit the item + payload in the remaining
space but then place the alignment bytes at the begginning, which would
break alignment of the next invoke_item struct.
Also check if there is enough space to write the payload bytes.
We check if there is enough space for the invoke_item structure first.
Then we calculate how much bytes we need to use for the payload but we
fail to check if we can actually write that much data, risking
overwriting existing data from the ringbuffer and causing a crash later
when we try to jump to invalid memory.
Add some more comments.
The kernel-provided SCO write MTU is currently never the correct packet
size for writing, so don't try to use it. Some adapter firmware (eg.
BCM20702A0 0b05:17cb) appears in practice sensitive to the alignment of
the msbc frames, and writes with wrong packet size break things but only
on certain headsets. For other adapters, this doesn't appear to matter.
This is a bitfield, but it's unclear what it achieves since this is the
only member of a bitfield, so it may be more efficient to just make it a
bool.
Fixes a LGTM warning:
Bit field started of type int should have explicitly unsigned integral, explicitly signed integral, or enumeration type.
`sizes` members participate in multiplication and subsequent assignment
into port->bpf, which has size_t. So LGTM rightfully complains, there's
a chance the multiplication will overflow before the assignment happens.
Should have no influence on performance since 64 bit multiplication is
as fast, and since the struct is constified, a wise compiler should make
sure it doesn't take excess space either.
Fixes LGTM warning:
Multiplication result may overflow 'unsigned int' before it is converted to 'size_t'.
That was found by GCC fanalyze pass. Fixes warning:
../spa/plugins/audioconvert/resample-native.c: In function ‘resample_native_init’:
../spa/plugins/audioconvert/resample-native.c:385:9: warning: dereference of NULL ‘0B’ [CWE-476] [-Wanalyzer-null-dereference]
385 | spa_log_debug(r->log, "native %p: q:%d in:%d out:%d n_taps:%d n_phases:%d features:%08x:%08x",
Check if we are driving or following and only start the timers when we
are the driver of the graph.
Ready events from non-drivers are not really a problem because they are
ignored. They only cause unnecessary wakeups in the graph.
Mark some structures, arrays static/const at various places.
In some cases this prevents unnecessary initialization
when a function is entered.
All in all, the text segments across all shared
libraries are reduced by about 2 KiB. However,
the total size increases by about 2 KiB as well.
Instead of spa_aprintf(), convert `rfcomm_send_{cmd,query}`
to take a printf-style format string.
Furthermore, handle overflows and return errors from
`rfcomm_send_{cmd,reply}`. And make those functions
take an rfcomm as argument instead of any spa_source.
And match conversion specifiers to the actual types
in format strings.
Strip the alibpref from the device string in the mapping name. This
name is used to generate the node name eventually and we don't want
this random identifier in it.
Fixes#1362
To iterate over an array of `T`, the iterator must be `(const) T *`,
so that the types are compatible when `T[]` decays into `T *`.
In the example when `struct foo *[]` decays, it becomes `struct foo **`,
which is not compatible with the the type of iterator, `struct foo *`.
Fix that by changing the type of the array to `struct foo[]`.
If the caller asks for MemFd, pass a DmaBuf because it is mostly
the same for v4l2.
Not very correct but it's not yet trivial to fall back to memfd.
And this way we have something to give to the clients that will work
when the client asks for MemFd or MemPtr.
libcamera commit ec7afef665a87eb389a5a4cb9ff35e9c24bbcc29 (2021-06-24)
changed the name of the generated pkg-config file from 'camera.pc'
to 'libcamera.pc'.
First look for the libcamera dependency under the new name 'libcamera',
and if that's not found, look for it under the older name 'camera'.
Fixes#1355
Several places in the code don't handle reconnecting DBus connections
yet. In those cases, a ref to the DBusConnection handle needs to be
kept, so that there's no use-after-free if it gets freed by spa_dbus
if the connection is broken.
Adjust spa_dbus so that others keeping additional refs is safe.
Until now the 'v4l2' feature was not actually checking that its
required header has been found, this commit adds a check for
<linux/videodev2.h> and correctly reports both header status and whether
the feature itself ends up enabled (depends on libudev).
As suggested by George Kiagiadakis, adds calls to summary() function
for each feature that is by default set to auto, so that an overview
of their effective state is printed at the end of meson setup or
meson --reconfigure command.
Currently ordering is a bit messy but tidying it up would detach
the summary() functions from the dependencies they rely on and could
be done later along with meson_options.txt re-ordering so that the
two match as much as possible.
Add more info to the main SPA page and split the design vs plugin pages up,
together with some more documentation to ideally lower make this easier to
understand on a glance.
Most of the actual plugin loading documentation are unmodified.
When setting the Latency parameter on one side of the converter, set
it also on the other size. We should actually implement propagating
the latency through all the elements of the converter later.
Implement latency handling on fmtconvert.
merger and splitter change latency on all ports when on port changes.
All this makes the configured and exposed latencies visible on all
ports from adapter.
Fixes a number of warnings that look like this:
In file included from ../spa/include/spa/utils/result.h:37,
from ../spa/plugins/alsa/alsa-seq.c:35:
In function ‘set_timers’,
inlined from ‘do_reassign_follower’ at ../spa/plugins/alsa/alsa-seq.c:909:2:
../spa/include/spa/utils/defs.h:191:39: warning: ‘now.tv_sec’ may be used uninitialized [-Wmaybe-uninitialized]
191 | #define SPA_TIMESPEC_TO_NSEC(ts) ((ts)->tv_sec * SPA_NSEC_PER_SEC + (ts)->tv_nsec)
| ~~~~^~~~~~~~
../spa/plugins/alsa/alsa-seq.c:840:28: note: in expansion of macro ‘SPA_TIMESPEC_TO_NSEC’
840 | state->next_time = SPA_TIMESPEC_TO_NSEC(&now);
| ^~~~~~~~~~~~~~~~~~~~
../spa/plugins/alsa/alsa-seq.c: In function ‘do_reassign_follower’:
../spa/plugins/alsa/alsa-seq.c:836:25: note: ‘now’ declared here
836 | struct timespec now;
| ^~~
The reason for these warnings is that spa_system_clock_gettime() may
fail if a version check fails, but the code in question didn't check for
the possible fail. If it failed, then execution would continue, and the
arguments that were passed to the macro will be used uninitialized.
Fix this by checking whether function succeeded.
Use the quirks database to check whether to enable MSBC codec for each
device.
If quirks don't allow ALT1 mode for an USB adapter, check whether the
adapter has an usable ALT6 mode and disable MSBC if not.
It seems few devices support the Device Id via bluez.
Try to figure out vendor/product ids for usb devices also via sysfs.
Also try to figure out the adapter bus type.
Keep all types of devices, only emit device info if device has audio profiles.
Heuristically add profiles based on bluez actions so device can still be connected
even without initial UUIDs info from signal InterfaceAdded for org.bluez.Device1.
Fixes#1330
SPA_PLUGIN_DIR is exported in pkgconfig as 'plugindir'
PIPEWIRE_MODULE_DIR is exported as 'moduledir'
PIPEWIRE_CONFIG_DIR is exported only in uninstalled environments
as 'confdatadir' (not making this public due to the possible upcoming
configuration changes in pipewire)
All variables are also exported on the meson dependency objects,
so that subprojects can find them.
Wireplumber can then find them like this:
pipewire_moduledir = pipewire_dep.get_variable(
pkgconfig: 'moduledir', internal: 'moduledir', default_value: '')
... and this works regardless of whether wireplumber is being
configured as a subproject or using the uninstalled pkgconfig files
or using the system installation of pipewire.
This is required in order to run wireplumber tests in the
uninstalled environment with 'meson test'
This allows meson subprojects (or projects using pipewire as a meson
subproject) to be able to use dependency('libpipewire-0.3') and
dependency('libspa-0.2') to find the uninstalled versions of these
libraries directly from the build dir instead of going through pkg-config
Always set the HAVE_OUTPUT flag because we always consume the
input and produce output, either to a buffer or an error.
This makes sure processing never stalls when something is wrong
on the output side.
See #1305
Follow the rate of the _io_position area and adjust the resampler
to match. This ensures that we always process at the DSP samplerate
to the target negotiated fixed rate of the device/stream.
The merger and splitter use the samplerate from the _io_position
for the DSP formats so set the samplerate to 0 to make sure we
don't use it to negotiate a format with the peer.
Move the code to check the position duration for changes to one
new method.
Also check for samplerate changes and adjust the resampler state
accordingly.
impl_add_listener() could be called more than one time, ensure that we always emit node info
so that session manager(bluez-monitor) can receives it.
Fixes#1308
Previously, the configured test file would be named like the following:
spa-include-test-spa_control_control_h..cpp
fix that by removing one of the dots.
Furthermore, use the already existing `find` object instead of
calling `find_program` one more time.
Strip the _alibpref from the device name, it contains a local counter
to identify the ucm card that should remain internal. We set a flag on
the device to notify of this.
Re-add the _alibpref of the local card to the device name if the
device was flagged.
See #1286
The _alibpref of the device was created in the session manager and
does not match our local _alibpref. Patch the device name with
the local _alibpref to make things match.
See #1286
The alibpref fallback does not contain the card number but it is
a local counter instead. Just check if it starts with something in
case the alsa library is not patched to return _alibpref.
Move the spa tests to the pwtest framework. The pod tests have only been
wrapped in the function callers, they don't use the variuos pwtest helpers -
too much work for very little gain here. Can be done incrementally if needed.
Note that this removes the spa tests from the installed tests. Arguably,
installing those tests was unnecessary anyway since they are static binaries
and don't load anything. So having them installed runs the same tests as
having them run in the source tree.
Goal for the pwtest framework is to allow for installed tests, just not there
yet.
Heavily inspired by libinput's litest framework (built around check), this is
a from-scratch framework that simplifies adding tests for various parts of
pipewire. See the pwtest.h documentation for details but the basics are:
- PW_TEST() and PWTEST_SUITE() specify the tests to be run
- Test are run in forked processes, any errors/signals are caught and printed
to the log
- Tests have a custom pipewire daemon started on demand to talk to [1]. The
daemon's log is available in the test output.
- Output is YAML to be processed into whatever format needed
[1] There are limits here, since we can't emulate devices yet there is only
so much we can rely on with the daemon.
If we have a C++ compiler, compile all the #include tests with that - it'll
pick up any issues that a C compiler will pick up anyway. This saves us from
having a separate C++ compiler test and it'll test each header separately for
C++ compatibility..
These headers are designed for including in the project. So the user doesn't
need to install valgrind-devel and we don't have to worry about whether the
headers are available or not.
For each header in the spa directory, generate a compilation test that
includes just that header. This way we can pick up missing #includes.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Set this once during setup so we don't have to remember to call fflush() after
each logging operation.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
In the interested of making the logs narrower, let's drop some digits from the
clock_gettime() seconds value. Clamping to 5 digigts, this gives us just under
28h before we wrap which is likely good enough for debugging.
Write the timestamp and location into a temporary buffer, then include them in
the message print. This makes bugs involving size vs length less likely and
provides a fixed limit for how much space the filename can take in the
message.
Replace the manually maintained header list with a Python script that finds
all header files and includes them in order. This adds another 25 or so
previously headers to the C++ compilation tests.
The two are functionally equivalent, but spa_snprintf never returns a value
higher than the size, preventing memory corruption where our input string
exceeds the target buffer size (see c851349f1).
Niche case: we can no longer differ between real overflow and fitting an
N-byte string into an N+1 sized buffer, we now get a "...truncated" message
now for log messages of exactly 999 bytes long.
Wraps the glibc snprintf/vsnprintf calls, but aborts if given a negative size
and zero-terminates the buffer on error.
The returned value is clipped to size - 1 which avoids issues like the one
fixed in c851349f17.
void* cannot be automatically type-casted so let's do this explicitly.
../spa/include/spa/param/latency-utils.h: In function ‘spa_pod* spa_latency_build(spa_pod_builder*, uint32_t, const spa_latency_info*)’:
../spa/include/spa/pod/builder.h:651:1: error: invalid conversion from ‘void*’ to ‘spa_pod*’ [-fpermissive]
First element is a spa_list, so {{0}} it is.
../spa/include/spa/node/utils.h:98:40: warning: missing braces around initializer for ‘spa_list’ [-Wmissing-braces]
98 | struct spa_hook listener = { 0 };
In file included from spa/tests/test-cpp.cpp:49:
../spa/include/spa/param/latency-utils.h: In function ‘int spa_latency_parse(const spa_pod*, spa_latency_info*)’:
../spa/include/spa/param/latency-utils.h:95:25: error: invalid conversion from ‘int’ to ‘spa_direction’ [-fpermissive]
95 | info->direction &= 1;
| ~~~~~~~~~~~~~~~~^~~~
| |
| int
On machines with a 32 bits long, converting a negative value will
still result in v == (uint32_t)v and the unit test will fail.
Extend to 64 bits and strtoull to reject negative values in atou32.
bluez5 nodes will always be removed & created again during profile changing, hence
node volume & mute will always be reset. This is OK if profile did changed, because
session manager would carries volume & mute to bluez5 route param. But if profile
was not changed after setting profile (a2dp-sink-sbc -> a2dp-sink -> a2dp-sink-sbc),
session manager would think node volume & mute are not changed and no route
setting is performed, causing route volume out of sync with node volume.
To fix this, we emit node volume and mute right after bluez5 node is created.
Fixes#1254
Use _alibpref to check if a device needs a UCM local config. Mark
the device as such and use this to set the OPEN_UCM property on
the device.
Open the UCM for a card when the device has the property set. Use the
same logic for loading the UCM as the acp code.
See #1251
UCM devices can require local data from use_case_mgr_open() but since
we do that in a separate process, make sure we reopen the use case
manager in case we are passed a UCM device so that the config is
available.
See #1251
When we enable a device, the node will be created and its software
volume will be set to 100%. Update the device volume with this as
well so that changing the volume has an effect.
Fixes#1198
According to the alsa-info.txt in the pipewire issues of #747 and #1206,
the Front Playback Volume is shared by Headphone and Lineout or
Headphone and Speaker, But Headphone, Lineout or Speaker they all have
independent Playback Switch, change to only use switch to mute the
Lineout or Speaker. This could resolve the issues of #747 and #1206.
See #1206 and #747
If the message was too long, then the `vsnprintf()` call would
fill up `location`, leaving no space for the color escape sequence
and the newline, causing a stack buffer overrun here:
size += snprintf(p + size, len - size, "%s\n", impl->colors ? suffix : "");
Fix that by reserving the last 24 bytes of the message buffer.
Implement a port recalculate latency method that takes the min
and max latency of all peer ports and sets that as the new port
latency.
When a link is made, let the output and input port recalculate
latencies.
Pass latency param in audioconvert.
Add a new latency param that contains a latency object.
The latency object contains the min and max delay from a port to
the terminal sink/source. It is also possible to express this
delay as a fraction of the quantum to avoid having to recalculate
the latency every time the quantum changes.
When we add a new listener to an object, it will emit the full state
of the object. For this it temporarily sets the change_mask to all
changes. Restore the previous state after this or else we might not
emit the right change_mask for the next listener.
Consider the case where one there are two listeners on an object.
The object emits a change and the first listener wants to enumerate the
changed params. For this is adds a new listener and then triggers the
enumeration. If we set the change_mask to 0 after adding the listener,
the second listener would get a 0 change_mask and fail to update
its state.
This requires a helper script: doxygen doesn't differ between static methods
and static inline methods. EXTRACT_STATIC defines whether it parses *any*
static method but we're currently using all C files as input files as well. We
cannot convince doxygen to just parse static inline functions in header files
so for SPA we hack around this: meson passes the spa headers to a shell script
with simply copies those changed to `/* static */ inline void (foo)` and doxygen
then runs on those header files.
The result: we get all spa functions added to your doxygen output at the cost
of a few sed calls.
Subdirectories buffer, control, debug, monitor, pod, support and utils, others
are still missing. Headers are grouped either per subdirectory (e.g. buffer/
gets added to group spa_buffer) or per-file (e.g. spa_json is a separate
group), whatever seemed like the most sensible approach.
Motu M4 has four inputs (two line-in inputs, and two complete ones
with gain and XLR and whatnot), as well as four outputs (two monitor
pairs, and an unnaccounted headphone).
Sadly, like a few other interfaces, it wasn't being given an input
profile, since the matching code goes through default.conf testing
each config, and ends up selecting 'analog-surround-40', which does
not have input mapping. The inputs would fallback to 'multichannel-
input', which also doesn't have input paths.
Add input paths to all analog-surround-* mappings, and remove their
'direction=output' fields since they handle both out and in.
This flag is used to announce that the respective key is mandatory and
therefore the object containing this key is not suitable to be merged
with other objects missing it.
This replaces the manual check for "true" and some (inconsistent) return value
of atoi. All those instances now require either "true" or "1" to parse as
true, any other value (including NULL) is boolean false.