Commit graph

4095 commits

Author SHA1 Message Date
Wim Taymans e1deecc3cd impl-link: also update node id in properties
The link might have been made using the node name/nick/description but
we always want to place the id in the properties to make it easier for
apps to handle the relations between objects.

See #1723
2021-10-15 17:58:05 +02:00
Peter Hutterer 00bd3b5b59 media-session: store the config dir path in our object
The media session modules need to load config files through
sm_media_session_load_conf() and that must be the same config dir as our
main configuration file's directory.
2021-10-15 10:53:32 +10:00
Michael Olbrich d2ce51d504 stream: decrement busy counter when releasing dequeued buffers
For buffers on the 'dequeued' list, the busy counter was already
incremented in impl_node_process_input(). So it must be decremented again
when these buffers are removed.
2021-10-14 19:16:56 +00:00
Michael Olbrich 314ff82ff0 pipewiresrc: fix handling outstanding buffers when stopping
The current code has several issues if a pipewiresrc is stopped and deleted
while a buffer is still in use downstream.

 - pw_stream_queue_buffer() is never called for the corresponding
   pw_buffer. As a result, the busy counter is never decremented and
   pw_stream_dequeue_buffer() of the corresponding pipewire output will
   return NULL whenever it encounters this buffer.

 - The pipewiresrc does not own the buffer reference unless the buffer is
   queued in the source, so calling gst_buffer_unref() unconditionally
   causes refcount issues for the buffer.

 - buffer_recycle() can race with on_remove_buffer() and
   gst_pipewire_src_close(). As a result, buffer_recycle() may access pwsrc
   when it was already deleted.

The buffer has its own reference to the pool. So the pool object lock can
be used to ensure that the pwsrc, core and stream remain valid in.
buffer_recycle(). If the 'dispose' function pointer was already cleared,
then on_remove_buffer() has already finished, so abort early.

With the pool lock held, it is save to access the pipewire loop. Now the
loop lock can be used to synchronize with on_remove_buffer(). 'dispose'
must be checked again in case on_remove_buffer() was triggered by something
other than gst_pipewire_src_close().

In on_remove_buffer() unref the buffer if it is queued. Otherwise call
pw_stream_queue_buffer() to ensure that the busy counter is decremented
correctly.
2021-10-14 19:16:56 +00:00
Michael Olbrich 744a8aaeb7 gst: init last_error
Otherwise, it may be used uninitalized.
2021-10-14 19:16:56 +00:00
Wim Taymans 1f5396fedb stream: don't change to the error state on proxy errors
The proxy errors are really from the session manager informing us about
decisions it made (failure to link, etc). The state of the stream is not
really affected by this so just emit the error signal and let the app
decide what to do.
2021-10-14 16:00:40 +02:00
Wim Taymans 8c346ab3a7 pulse-server: list NETWORK flag on devices
Mark network sinks and sources with node.network.
2021-10-14 13:45:58 +02:00
Wim Taymans d6c1479ba0 module-zeroconf-discover: also parse the channel_map
So that we create the device with the same channel_map as the remote
end.

Fixes #1692
2021-10-14 13:28:43 +02:00
Wim Taymans 257bbb1fd5 echo-cancel: flush streams in PAUSED
so that we don't end up with old data when we resume.

Fixes #1660
2021-10-14 12:18:37 +02:00
Wim Taymans 30f8219afd stream: improve some debug 2021-10-14 10:02:13 +02:00
Peter Hutterer 40eb9578d5 media-session: make a few debug messages easier to understand
Especially with PIPEWIRE_LOG_LINE=false, those messages are too
confusing otherwise.
2021-10-14 07:51:27 +00:00
Peter Hutterer 6c156cdbb4 media-session: move the media-session config files to here 2021-10-14 07:51:27 +00:00
Peter Hutterer 3560f3ba2d media-session: add MEDIA_SESSION_CONFIG_DIR as lookup location
Use this to override the default $PIPEWIRE_CONFIG_DIR/media-session.d
directory. This allows us to have separate configuration directories for
pipewire and media-session.
2021-10-14 07:51:27 +00:00
Peter Hutterer 4ec2a6b320 modules: fix a property fetch
Leftover from an earlier version where get() was what is now called
fetch().

Fixes d8d7e90ceb21dac3723fa3c3fd3c2983afe1372
2021-10-14 06:32:20 +10:00
Wim Taymans 64d6ff4184 modules: flush and reset state in paused
So that we don't end up with previous data when we resume.

See #1660
2021-10-13 18:37:02 +02:00
Wim Taymans 6e818480c1 filter-chain: implement convoler_reset
To reset the state of the convolver.
2021-10-13 18:36:20 +02:00
Wim Taymans 0d1f7be0e9 context: the max quantum is never scaled with samplerate
Or else we could end up with a quantum > 8192 when we have a higher
samplerate than the default and we crash.

See #1702
2021-10-13 17:11:28 +02:00
Wim Taymans 058cecee7e pulse-server: remove some pw_log_info debug 2021-10-13 15:44:38 +02:00
Wim Taymans f1c29194a8 pulse-server: improve lookup of default source and sink
Make things work then there is no default input device and the default
source is actually the monitor of the default sink.

Also implement lookups of monitor sources with the monitor id as the
name.

Fixes #1691
2021-10-13 15:39:41 +02:00
Wim Taymans 1b09640b6f pulse-server: use find_device for get_info of a device
So that we also go through the same logic for finding the default
source and sink when needed.
2021-10-13 15:38:59 +02:00
Peter Hutterer 027dd25980 pipewire: declare pw_proxy_ref/unref
Both are already SPA_EXPORT but missing from the public header file.
2021-10-13 09:13:12 +00:00
Wim Taymans d8540cc596 impl-node: always deactivate node in suspend
pause_node() will check the IDLE state of the node and will not
deactivate the node when suspending when it was already IDLE.

Fixes an issue where node.pause-on-idle=false filters would not want to
resume after a suspend.
2021-10-13 10:54:45 +02:00
Wim Taymans e77a0e8dc4 impl-node: start always need activate_node 2021-10-13 10:51:24 +02:00
Wim Taymans e0974122ce impl-node: rename pending to pending_state for clarity 2021-10-13 10:50:41 +02:00
Peter Hutterer eabd00e012 properties: log a warning if the property type differs
If we try to fetch a property as some specific type and the parsing
fails, log a warning. This should catch any client bugs where the
properties are set wrongly.
2021-10-13 07:12:00 +00:00
Peter Hutterer 32fb369b66 modules: switch more modules to the new property helpers 2021-10-13 07:12:00 +00:00
Peter Hutterer c59ede837d pipewire: switch to new property helpers 2021-10-13 07:12:00 +00:00
Peter Hutterer 56bc3508c4 module-rt{kit}: replace get_default_int with the new property helper 2021-10-13 07:12:00 +00:00
Peter Hutterer 1d8d7e90ce modules: switch a few modules to the new property helpers 2021-10-13 07:12:00 +00:00
Peter Hutterer d8de1cb255 modules: switch to new property helpers 2021-10-13 07:12:00 +00:00
Peter Hutterer 12c5a9b7ea media-session: switch to new property helpers 2021-10-13 07:12:00 +00:00
Peter Hutterer 0028b294d0 properties: add type-specific pw_properties_get helpers
Two method calls to get properties,
- pw_properties_fetch_$type()
- pw_properties_get_$type()

The former allows for easy error checking and conditional setting of
properties. The latter for easy fetching of a property with a default
value. This simplifies the code and makes property parsing behave more
consistently across the code base.

Before:
   str = pw_properties_get(props, "foo");
   if (str)
	myval = pw_properties_parse_int(props, str);
	if (myval == 0) /* parsing error or a valid zero */
	    do_stuff(myval);

Now:
   if (pw_properties_fetch_int32(props, "foo", &myval) == 0)
	do_stuff(myval);
2021-10-13 07:12:00 +00:00
Peter Hutterer 696a4b22e9 module-rt{kit}: use spa_atoi32 instead of custom strtol
And duplicate the function into rtkit which had a similar but different
approach to it. Let's get both to do the same here.
2021-10-13 07:12:00 +00:00
Peter Hutterer 87a1e1534c daemon: let meson handle the uninstalled media-session path
If we build media-session before the daemon we have the executable
variable available and can rely on meson to fill in the path instead of
handling it manually.
2021-10-13 07:09:13 +00:00
Peter Hutterer c81dcae683 media-session: rename the executable variable name in meson.build
Makes it more obvious to access the result from other meson.build
files.
2021-10-13 07:09:13 +00:00
Peter Hutterer f4516e6745 media-session: decouple config from the pipewire daemon config
There are only two values we care about that are identical, we can
re-set those in a new configuration_data() object.

All the other values set by the pipewire daemon are related to how we
start the session manager which isn't applicable here.
2021-10-13 07:09:13 +00:00
Wim Taymans a5c64ffa3b impl-node: deactivate node in destroy
When pause-on-idle is false, the node can be destroyed without ever
being deactivated, which would crash. Make sure we deactivate in destroy
and remove the node from the graph.
2021-10-12 12:07:18 +02:00
Peter Hutterer 12379a9a3c pipewire: fix error message if the DBus library load failed
If the handle is NULL, we'd print out the strerror with res at whatever
value it currently has, leading to confusion.
2021-10-12 09:45:33 +10:00
Wim Taymans 9afb832d22 pulse-server: find the sink when doing monitor source lookup
When we do a lookup of a source with the monitor flag bits set in the
id, strip off the monitor bits se we can find the associated sink.

Fixes #1677
2021-10-11 17:02:13 +02:00
Wim Taymans 38981a4c8c filter-chain: biquad fequency is half the samplerate
See #1699
2021-10-11 16:07:13 +02:00
Wim Taymans 85d5c8cd6c cpu: add zero_denormals method
Add a method to enable/disable the denormals flush-to-zero and
denormals-as-zero CPU options.

Add a config option to make it possible to disable this again.

Fixes high CPU usage when dealing with denormals, which can happen
in many DSP functions.

Fixes #1681
2021-10-11 14:57:02 +02:00
Wim Taymans 036371c48f media-session: fix aux channels links
AUX channels can link to any other channel but when AUX channels are
linked, they must match exactly.

Fixes some issues with split devices with aux channels.
2021-10-11 11:35:29 +02:00
Pauli Virtanen 4b831021fb bluez5: add a dummy AVRCP player as a workaround
Some devices (Bose Mini Soundlink II, Air 1 Plus, ...) don't enable
AVRCP volume control, or fail to enable it before a hardware button is
pressed.  However, these devices appear to enable it, if an AVRCP player
is present.

As a workaround, register a dummy AVRCP player for each adapter. It only
displays the current transport acquisition state as playing/stopped, but
just its presence appears to be enough to make devices behave.

Multiple AVRCP players interfere with each other, as BlueZ uses the one
registered earliest as the default player. So add also a config option
for disabling this. (It's not common to have mpris-proxy etc. running,
so defaulting to true should be OK.)

See pipewire#1157
2021-10-10 16:24:41 +03:00
Pauli Virtanen 98a0e54d5f doc: link examples to Doxygen docs
Include examples to the documentation, using Doxygen's example system.
2021-10-10 00:35:46 +03:00
Wim Taymans ffc5c49508 impl-link: cancel link operations in work_queue in destroy
Fixes #1705
2021-10-09 15:18:20 +02:00
columbarius 2aabc4610b gst: Don't reconnect gstpipewiresrc
Clients connecting via the gstreamer plugin can stall a stream when
reconnecting to it. Disable reconnection until the gstreamer plugin
has improved.
2021-10-09 13:12:06 +00:00
Wim Taymans 5f7c4dec34 meson: make it possible to compile without dbus
Make an option to disable dbus and all the code that depends on
it.

Fixes #1685
2021-10-09 15:00:04 +02:00
Peter Hutterer 82de0613d6 doc: document pw_map
Take some parts out of the public documentation, add a lot of internal
documentation to make it easier for the next person to figure out how
this works.

The use of static inline prevents doxygen from generating docs, put a
note in to link to the header file directly.
2021-10-08 12:55:34 +10:00
Peter Hutterer 626d30e4bd map: fix free_list corruption when re-using removed ids
Re-using an id after removing it is a bug in the caller but there are
two cases where we corrupt the free list without warning:

Removing an object twice:

   id = pw_map_insert_new(object);
   pw_map_remove(map, id);
   pw_map_remove(map, id);

And inserting an element at an index previously removed:

   id = pw_map_insert_new(object);
   pw_map_remove(map, id);
   pw_map_insert_at(map, id, new_object);

The latter is arguably valid code, or at least it'll look like it's
valid code.

For both cases, check if the id to remove/insert at is a free item and
handle that accordingly.
2021-10-08 12:40:23 +10:00
Björn Daase 492abccfe6 filter-chain: fix incorrect codespell fix
Fixes cf38b7bdc4
2021-10-07 21:31:01 +02:00
Björn Daase cf38b7bdc4 fix codespell issues 2021-10-07 15:26:18 +00:00
Nicolai Syvertsen dea1755b68 pulse-tunnel: follow pulseaudio for default format 2021-10-07 15:39:11 +02:00
Nicolai Syvertsen 28c2e8ca56 pulse-tunnel: use format, channels and rate props 2021-10-07 13:00:24 +02:00
Peter Hutterer e36183d3cf array: re-initialize the array in pw_array_clear()
Leaving the data nonzero is a use-after-free bug waiting to happen.
2021-10-07 15:08:57 +10:00
Wim Taymans 28744fc5ed work-queue: share one work queue for links and nodes 2021-10-06 19:59:15 +02:00
Pauli Virtanen 49901f2d61 doc: add brief explanations for all groups 2021-10-04 20:55:04 +03:00
Pauli Virtanen 125051a700 doc: reorganize some \pages, and fix some group names
Move \pages having to do with the API usage to the API section.
Better group names for some groups.
2021-10-04 20:39:56 +03:00
Wim Taymans 26c7d48f0a impl-metadata: implement exposed method 2021-10-04 13:49:35 +02:00
Pauli Virtanen c620121529 bluez5: add faststream quirks
For some devices FastStream causes problems. Add quirk for disabling it.
2021-10-03 20:55:02 +03:00
Pauli Virtanen 8159797f89 doc: reorganize Doxygen groups/modules to make more sense
The Doxygen "Modules" page is not very illuminative, as different parts
of the API are mixed together and not all parts are included.

Try to address this:

Put all parts of the public API to some Doxygen group, usually one group
per header file. Use short, systematic names.

Make these groups sub-groups of a few top-level groups, roughly
corresponding to the different logical parts of the API (core, impl,
stream, filter, spa, utilities).
2021-10-03 15:39:27 +03:00
Wim Taymans a95937dfdb log: remove NAME as log prefix, topic is enough 2021-10-03 12:03:45 +02:00
Wim Taymans f275e3baaa jack: add jack log topic 2021-10-03 08:52:27 +02:00
Wim Taymans 786cfc44fb log: add work-queue topic 2021-10-03 08:30:46 +02:00
Wim Taymans d43fdf9f5b log: add mem topic 2021-10-03 07:55:00 +02:00
Wim Taymans 1ba805ac7e log: add stream and filter topics 2021-10-02 14:02:23 +02:00
Wim Taymans 5522e9cb1c log: add loop and mainloop topics 2021-10-02 13:54:22 +02:00
Wim Taymans e1b38e6dd4 impl-link: add link topic 2021-10-02 13:50:08 +02:00
Wim Taymans e9af0e4ef8 log: add topic for data and thread loop 2021-10-02 13:44:50 +02:00
Wim Taymans f0085b383e impl-port: remove NAME prefix 2021-10-02 12:52:42 +02:00
Wim Taymans 9cc34cfe99 buffers: add log topic 2021-10-02 12:46:48 +02:00
Gleb Popov 42d8b2b167 Remove legacy FreeBSD compatibility code 2021-10-01 18:09:44 +03:00
Wim Taymans b418b876e4 media-session: don't try to remap to unpositioned formats
check if a node has AUX channels and mark it as unpositioned in that
case.

If the peer node we need to link to has unpositioned channels, don't try
to configure the node for the unpositioned layout but instead configure
it to its default format and link the ports one by one, as many as there
are.

This is mostly for Pro-audio devices. It does not make sense to
try to remix a stereo stream to 18 channels. Most likely the pro-audio
card does not have 18 speakers connected and we would not known how to
remix anyway because the channels don't have a position. So, just take
the 2 channels and link them to the 2 first AUX inputs, which is usually
more correct and mimics what other players do when outputting to JACK.

If a specific remapping needs to be done for the pro-audio card, it
needs to be configured with a virtual device.
2021-10-01 16:17:24 +02:00
Wim Taymans 0caafffa12 media-session: link AUX nodes as well
Anything can link to an AUX node if nothing else is available, just
like the UNKNOWN and MONO ports.
2021-10-01 16:16:10 +02:00
Wim Taymans 3dde9fef9c client-node: send the right peer_id
Output ports share the same buffers on all mix outputs and the buffers
are stored in a special mix area with id SPA_ID_INVALID.

The special mix area does not have the peer_id of the link, we need to
get that from the non-shared mix area.

This fixes some invalid peer port-id values in the set_mix_info event.
2021-10-01 09:33:19 +02:00
Pauli Virtanen d6509a243d bluez5: fix device.profile setting
Only keys with names starting with "bluez" are passed on to device
settings dict. Rename device.profile to match this.

Also add some debug.
2021-09-30 22:39:34 +03:00
Peter Hutterer 8352e47878 media-session: warn if WirePlumber is running on startup
Matches WirePlumber commit 2bc999594 but here we merely print an error
messages instead of failing to start.
2021-09-30 08:30:55 +00:00
Peter Hutterer 0aa09ec801 media-session: rename mod_topic to ms_topic for clarity 2021-09-30 08:29:06 +00:00
Peter Hutterer bb99f9c71e media-session: exit with status 1, not -1
The EXIT_FAILURE define is 1 and besides, it's more common anyway.
2021-09-30 08:29:06 +00:00
Wim Taymans 5026645e93 pulse-server: add latency_msec parameter 2021-09-30 09:49:09 +02:00
Wim Taymans 696dbf7cd6 pulse-tunnel: pass latency as msec 2021-09-30 09:49:00 +02:00
Peter Hutterer abd5f9fbe8 Remove remaining tabs from meson.build files
No changes, just tab-to-space replacement and a little bit of manual
twiddling.
2021-09-30 00:08:27 +00:00
Wim Taymans d6469e5437 filter-chain: make it possible to suggest a samplerate
Make it possible to let a plugin suggest a samplerate for the filter.
Make the convolver suggest the samplerate of the IR file anf use that
if nothing else is specified in the config.

Fixes #1659
2021-09-29 16:53:18 +02:00
Wim Taymans 275dfed92a filter-chain: handle unaligned sum_simd
Fall back to slow path if the input is not aligned, which can happen
after resampling.

Fixes #1659
2021-09-29 16:30:59 +02:00
Barnabás Pőcze d2f0573369 pipewire: module-zeroconf-discover: handle module destroy events
module-zeroconf-discover loads module-pulse-tunnel for each entity
exposed on the network. Previously, however, the destroy event
of the loaded pulse-tunnel modules were not handled.

This resulted in a use-after-free because both `pw_context_destroy()`
and `module-zeroconf-discover.c:impl_free()` tried to destroy
the pulse-tunnel modules. The reason for that is that since
1de16afc40 the modules
are prepended to the module list of the context, not appended,
therefore modules are destroyed in LIFO order, thus the pulse-tunnel
modules were destroyed before the zeroconf-discover module that
loaded them.

Fix that by handling the destroy event of the loaded pulse-tunnel
modules.

Fixes #1653
2021-09-29 10:35:16 +02:00
Peter Hutterer 4ea8fa8180 systemd: make pipewire-pulse require one of the session managers
Where pipewire and friends are started via socket activation,
a PA client connection to the pulse socket triggers
pipewire-pulse.service. That in turn triggers pipewire.service through
Wants/After and once that is started up, pipewire-pulse actually
starts up.

At the same time, pipewire-media-session or wireplumber are started
through WantedBy/after in the respective service files.

Depending on which leg the race condition got out of bed with today,
pipewire-pulse may be finished before the session manager has set up the
graph and the PA client doesn't see any devices.

Fix this by adding a dependency on the session manager in
pipewire-pulse, installed via an Alias so media-session and wireplumber
can install the same alias. Wants is a light dependency, so for the case
where it doesn't exist we fall back to the current behavior anyway.

This doesn't remove the race condition since systemd may deem the
session manager to have started before the graph is set up, but it
should reduce the occurances.

The disadvantage here: only one Alias will be installed by systemd, so
first-come, first-serve in the case of both media-session and
wireplumber being installed.

See #1553
2021-09-29 07:18:13 +00:00
Peter Hutterer 90cbcb6c05 systemd: add PipeWire to the systemd service file descriptions
Without this, a journal entry merely looks like this:
 Stopping Multimedia Service ...

Which is obviously terrible from a branding perspective but also makes
it harder for users to figure out what process was responsible for this
entry.
2021-09-29 07:17:35 +00:00
Peter Hutterer e3b216c026 media-session: add log topics to all modules
Media-session itself uses ms.core, there are only two files that could
have a sub-topic but right now they don't use it (match-rules and
metadata).

The modules use the ms.mod.* namespace, so it's trivial to filter on
those.
2021-09-28 09:35:39 +02:00
Peter Hutterer 52a96bb602 modules: add log topics to module-protocol-pulse
This ends up using a nested namespace: mod.protocol-pulse for the module
itself, mod.protocol-pulse.foo for the various submodules and
extensions.
2021-09-28 09:35:39 +02:00
Peter Hutterer 96f8a7597e modules: switch protocol-native to the new logging system
This is more complicated than a normal module because we have two
logging topics: mod.protocol-native and conn.protocol-native for wire
messages. Because the latter use spa_debug (through spa_debug_pod) we
need to #define our way around so those too use the right topics.

Note that this removes the previous "connection" category, it is now
"conn.protocol-native" instead.
2021-09-28 09:35:39 +02:00
Peter Hutterer 14112fd168 modules: use the new topic-based logging from various pipewire modules 2021-09-28 09:35:39 +02:00
Peter Hutterer a6e66d9180 pipewire: use the internal log topics 2021-09-28 09:35:38 +02:00
Peter Hutterer 52bd80aaa4 log: add topic loggers and a default topic
pw_log_log/logv now go through the topic-based logger using the
"default" topic. Log topics themselves can be allocated by the call
sites. The simplest way to use a topic from e.g. a module:

    PW_LOG_TOPIC_STATIC(mod_topic, "mod.foo");
    #define PW_LOG_TOPIC_DEFAULT mod_topic
    ...
    void pipewire__module_init() {
  	  PW_LOG_TOPIC_INIT(mod_topic);
  	  ...
    }

With the #define all pw_log_foo() are now routed through the custom
topic. For the cases where the log topic must be specified, a
pw_logt_foo() set of macros is available.

Log topics are enabled through the PIPEWIRE_DEBUG environment variable
which now supports globs, e.g. PIPEWIRE_DEBUG="*:I;mod.access:D"
to enable global INFO but DEBUG for the access module.

Namespaces documented are "pw", "mod" and "conn", for pipewire-internal
stuff, modules and connection dumping. The latter is special-cased to
avoid spamming the log files, it requires an expcit "conn.<glob>"
pattern to enable.

The "default" topic always exists and is the fallback for any
pw_log_foo() invocation that does not use a topic.
2021-09-28 09:35:38 +02:00
Peter Hutterer b58282353b pipewire: pass the PIPEWIRE_DEBUG config down to the logger
Convert the PIPEWIRE_DEBUG environment variable to the json format
specified by the log interface and pass it on.
2021-09-28 09:35:38 +02:00
Peter Hutterer 26cfdc95cc pipewire: use the spa_log_logv macro instead of a direct interface call
This checks the log level of global_log.level again which is always the
same as the global pw_log_level.
2021-09-28 09:35:38 +02:00
Peter Hutterer 264141b31b media-session: add a doc blurb for the restore-stream module 2021-09-28 07:24:41 +00:00
Peter Hutterer 92c7c8354d pipewire: don't log the location if PIPEWIRE_LOG_LINE=false
Default remains enabled, but sometimes it's easier to not have this.
2021-09-28 07:24:23 +00:00
Peter Hutterer bbe9059ed3 pipewire: re-use info dict for the journal logger
All the config options we pass in are standardised in spa/support/log.h, so the
journal logger should be (and it is) able to handle or ignore them.
2021-09-28 07:24:23 +00:00
Peter Hutterer ae59185f6f pw-cli: use readline() in interactive mode
With history and a simple command completion hook this makes the
interactive mode a lot easier to deal with.
2021-09-28 07:19:13 +00:00
Peter Hutterer 7d58ce9e24 pw-cli: add a 'quit' command to exit
Slightly less confusing for new users if we have at least one
help-listed command to exit.
2021-09-28 07:19:13 +00:00
Peter Hutterer 40487e485d daemon: only call pw_log_set_level() if -v is actually given
Previous commit 69e935e unconditionally called pw_log_set_level() after
the option parsing. If pw_init() changed the logging level based on
PIPEWIRE_DEBUG, we'd now overwrite that change.

Call pw_log_set_level() only if -v is actually given on the commandline.
This means a commandline option will override PIPEWIRE_DEBUG if set but
that is intended.

Fixes 69e935e8a4
2021-09-25 07:21:01 +10:00
Peter Hutterer 69e935e8a4 daemon: allow for a -v, -vv, -vvv argument to increase verbosity
Sometimes that's faster than having to play with PIPEWIRE_DEBUG.
Same for pipewire-media-session.
2021-09-24 10:49:42 +00:00
Wim Taymans cb474043fa pulse-tunnel: add pulse.latency option
Add a pulse.latency option to override the default 100ms latency.
2021-09-23 13:11:52 +02:00
Wim Taymans 88ba3014d6 pulse-tunnel: increase default latency to 100ms
20ms is too small and might be a typo from the pulseaudio 200ms default
latency.
2021-09-23 13:00:15 +02:00
Peter Hutterer f06741d6fc media-session: define NAME before including reserve.c
This ensures the log messages show up with the right module name prefix
2021-09-23 15:29:52 +10:00
Peter Hutterer 207c5796b6 pulse: print the strerror on metadata errors 2021-09-23 15:29:48 +10:00
Wim Taymans 884ecab425 add SPA_EXPORT for public functions
Fixes #1638
2021-09-22 15:14:21 +02:00
Wim Taymans 3f032ae464 build: fix session manager path 2021-09-22 09:04:15 +02:00
Peter Hutterer e46a30562f Promote media-session to its own subdirectory
media-session is past the point of being a mere example, let's promote
it out of the subdirectory.

pw-reserve is moved to tools/
2021-09-22 08:53:08 +02:00
Wim Taymans 6f519d4052 pulse-server: put the channel map in the loopback args
Fixes #1486
2021-09-21 18:33:29 +02:00
Wim Taymans c8f629a0a3 pulse-server: improve module args compatibility
Boolean switches can also be true with 'y', 'yes', 't' and 'on'
2021-09-21 17:39:11 +02:00
Wim Taymans d8aec1c7b4 pw-play: move dsdplay into pw-cat 2021-09-21 12:29:41 +02:00
Wim Taymans 0ec77ab09c dsd: show rate in bytes per seconds. 2021-09-21 12:25:42 +02:00
Wim Taymans 23edb9ab2a pipewire: release lock when clearing handle
The handle might want to unload plugins and we thus need to release the
lock.
2021-09-21 10:58:07 +02:00
Wim Taymans 275b8a0f9e dsdplay: make separate dsffile 2021-09-21 10:50:45 +02:00
Wim Taymans fb0c5f503f media-session: DSD is also a valid passthrough format 2021-09-21 10:50:45 +02:00
Wim Taymans ae9f90eccc dsdplay: implement data processing
Simplify channel layout management a little.
Use the bitorder and interleaving to read and format the DSD in the
buffer.
2021-09-21 10:50:45 +02:00
Wim Taymans 43b27002eb tools: add beginnings of DSD player 2021-09-21 10:50:44 +02:00
Wim Taymans 68f4dee2d9 pipewire: use lock for registry and init
Use a global lock to serialize concurrent pw_init calls.
Use a global lock to protect the global registry. With the alsa api,
multiple threads could open the device and create streams and
load/unload plugins.

See !942
2021-09-21 10:31:10 +02:00
Peter Hutterer e8e7e72b76 meson: require alsa for pipewire-alsa or media-session
The previous code had alsa optional if pipewire-alsa was on
auto/disabled bug failed later with missing alsa if media-session was in
the session manager array. Which it is by default.

Fixes #1632
2021-09-21 08:59:30 +10:00
Ivan 1129e90c4f conf: Fix format inconsistencies and beautify configs 2021-09-20 16:40:40 +00:00
Wim Taymans 8efe54a176 media-session: fall back to EnumRoute for availability check
If the device doesn't have an active Route, also check the EnumRoute to
see if there is something available. If nothing is available, also avoid
selecting this node.

Fixes #1624
2021-09-20 18:34:52 +02:00
Wim Taymans 2ae6ac2bcb media-session: skip route availability check for default nodes
For default nodes, that are explicitly configured, skip the route check.
This makes it possible for the user to select a non-available node
as the default still.

Fixes #1624
2021-09-20 18:33:08 +02:00
Wim Taymans 49a0250ecd impl-metadata: avoid infinite loop in cleat_items
When we need to remove all items, copy the storage to a temporary
array and clear the storage.

When one of the callbacks would add a new item to the storage it would
operate on the new empty storage and the loop to iteratively clear
subjects would be able to complete.

Fixes #1622
2021-09-20 15:06:05 +02:00
Wim Taymans afb37dd7fc pipewire: remove useless assignment 2021-09-20 15:05:37 +02:00
Peter Hutterer 335ad734de doc: fix example config for echo cancel
Fixes #1625
2021-09-20 15:56:13 +10:00
Pauli Virtanen 90b4efd98d bluez5: cleanup hfp/hsp backend handling + config file option
It seems not uncommon that people have not properly configured ofono
running, which results to loss of HFP/HSP functionality. It's less
surprising if the backend selection is fixed in the configuration file,
and (by default) does not depend on running services.

Add a configuration file option for selecting HFP/HSP backend, and set
the default value to the native backend. Emit warnings if conflicting
backend services are detected to be running.

Also cleanup hfp/hsp backend handling a bit, now that it's mostly
abstracted behind an interface.
2021-09-19 17:33:32 +00:00
Pauli Virtanen cae1554449 bluez5: move bluez-hardware.conf loading to the plugin
It's not really the responsibility of the session manager to load the
bluez5 device quirks, and it's easier for eg. Wireplumber if it doesn't
need to do it.

Move loading bluez-hardware.conf to be the responsibility of the bluez5
spa plugin, similarly as the alsa plugin deals with the ACP database.

Put the configuration to share/spa-0.2/bluez5, mirroring the plugin
directory structure in lib/spa-0.2/bluez5.
2021-09-19 17:28:17 +00:00
Leonardo Neumann 6168067cb2
fix missing limits.h include 2021-09-18 04:36:20 -03:00
Pauli Virtanen 39c8ed4f62 media-session: don't use-after-free if linking node removed
Should fix an ASAN crash.
2021-09-16 19:20:53 +03:00
Wim Taymans 803763ed01 gst: add 30 seconds timeout
Add a timeout to all blocking wait operations so that we don't wait
forever but error out after 30 seconds.
2021-09-16 10:05:58 +02:00
Wim Taymans a2202de679 gst: also stop waiting when we are flushing 2021-09-15 20:57:10 +02:00
Wim Taymans 077808b09a pipewiresrc: also notify waiters when start fails 2021-09-15 20:57:10 +02:00
Wim Taymans 97be5687ec remote-node: clear the node io areas when removing the memory
When the memory is removed, clear the node io areas so that it doesn't
accidentally get reused.

Fixes a crash in cheese when the node is stopped and then resumed.
2021-09-15 20:57:10 +02:00
Wim Taymans 21657ea2af remote-node: improve node io tag
Set the second tag field to INVALID to separate the node io areas from
the port io areas.
2021-09-15 20:57:10 +02:00
Peter Hutterer 14f0c6f9a6 modules: print the optional modules as part of the meson summary
This makes it easier to figure out if a particular module was missing
from the build. Example output:

  Optional Modules
    rt                        : YES
    rtkit                     : YES
    portal                    : YES
    pulse-tunnel              : YES
    zeroconf-discover         : YES
    roc-sink                  : NO
    roc-source                : NO
2021-09-15 11:24:09 +10:00
Wim Taymans bf29130f84 midifile: debug some more message types 2021-09-14 15:39:35 +02:00
Wim Taymans 36fe2e9b9e context: scale quantum values to default rate
The quantum values are relative to the default clock rate. When an
alternative rate is selected, scale the quantum values accordingly.
2021-09-14 13:34:06 +02:00
Wim Taymans 7543ad0766 impl-node: add node.transport.sync property
When the node support transport sync. That is, when it will clear the
pending_sync flag from its activation area when it completed a new
seek.

Before this patch, the pending sync was always automatically cleared,
which broke some applications that are time masters such as bitwig.

Fixes #1589
2021-09-14 11:06:19 +02:00
Wim Taymans 47a46e198f improve debug 2021-09-14 11:06:19 +02:00
Wim Taymans fda6e7b4af pulse-server: parse default.clock.rate from core info
Use the core.info clock rate as the default sample rate as soon as the
manager exposes the core object. Otherwise the default sample rate is 0
until someone calls GET_SERVER_INFO, which as a side effect sets the
default sample rate.

Fixes issues with sinks not appearing right away.

Fixes #1588
2021-09-13 10:50:01 +02:00
liberodark d2017ff540 Fix multiple module dir 2021-09-11 14:29:48 +00:00
Davide Beatrici fc9f7c1005 stream: declare pw_stream_get_control() in header
The function is defined and exported, but is not declared in the header.
2021-09-11 14:28:35 +00:00
Pauli Virtanen 966fbd5a21 bluez5: blocklist devices for sbc-xq 2021-09-10 17:57:21 +00:00
Wim Taymans 9faa006c1d media-session: try to not select nodes with unavailable route
Nodes that have the current route as unavailable should preferably not
be selected as defaults or targets.
2021-09-10 13:38:29 +02:00
Peter Hutterer e1672f9762 pipewire: allow for log level names in PIPEWIRE_DEBUG
Allow one of "XEWIDT" to refer to none, errors, warnings, info, debug
and trace, respectively because they're immediately recognizable. Well,
except maybe the X.

PIPEWIRE_DEBUG="I" is equivalent to PIPEWIRE_DEBUG="3" for example.
2021-09-10 07:38:20 +00:00
Pauli Virtanen 3f8fb6e4dc media-session: don't bluez-autoswitch for suspended/idle/errored streams
E.g. skypeforlinux makes its input streams idle but does not destroy
them, when no call is active.
2021-09-10 07:35:12 +00:00
Pauli Virtanen 4f8ff41a45 media-session: don't crash if obj->info is missing 2021-09-10 07:35:12 +00:00
Wim Taymans e6d7b1aa70 media-session: copy some device keys to the nodes
Chrome seems to want to use the device.bus
2021-09-09 18:05:20 +02:00
Wim Taymans 67be26aac7 media-session: only check passthrough when available
When none of the nodes have a valid passthrough format, don't check if
passthrough is possible.

Without the check, it is possible that a node has a common format with
the peer that is not a passthrough format, like a raw audio format.

Fixes #1587
2021-09-09 16:24:04 +02:00
Wim Taymans e4b030fafa jack: add option to disable process lock
Some applications might expect the process function to run concurrently
with the callbacks. PipeWire tries to avoid this by using a lock for the
duration of the process callback. Make an option to disable this.

See #1576
2021-09-08 13:02:04 +02:00
Wim Taymans 2071a14c82 context: only apply lock-quantum for unsuspended nodes
When the node is suspended, don't take into account the lock-quantum
settings or else the graph would not want to change to the requested
quantum of the node.

Say we have a jack node with node.lock-quantum = true and
node.latency=256/48000. When it joins the graph and is suspended, the
lock-quantum is ignored and the node.latency is set on the graph.
After that, the lock-quantum ensures the graph quantum doesn't change
anymore until the node is suspended.
2021-09-08 11:53:08 +02:00
Wim Taymans 9423e8d648 impl-node: move quantum and rate
When we move a node from one driver to another, move the quantum and
rate if the target driver was idle so that we can mostly continue
uninterupted until a quantum/rate change is calculated.
2021-09-08 11:51:09 +02:00
Wim Taymans a3fe226eac context: don't try to change the quantum when idle
When the driver is going to be idle or not running, avoid updating
the quantum.

This is mostly when a node is moved to another driver. Changing the
quantum of the old driver would have the clients briefly see the useless
quantum before being moved to the new driver.
2021-09-08 11:28:05 +02:00
Peter Hutterer 055643091f meson: drop default-session-manager, use the first session-manager instead
default-session-manager is only used in the pw-uninstalled.sh developer
script. c25cec230c added the ability to
use the system-installed wireplumber but other than that this option is
largely superfluous.

Drop it and pick whichever the first entry to session-manager is. For
the vast use-case of either MS or WP this will just work fine and for
the niche case of building both SMs one just needs to make sure the
order is as desired.

And in the case of no session manager, the config line to start the SM
is now commented out.
2021-09-08 07:50:48 +00:00
Peter Hutterer 71ee6ec669 daemon: split the session-manager and pipewire-pulse comments
Let them be enabled/disabled individually.
2021-09-08 07:50:48 +00:00
Peter Hutterer bc2d820b6d meson: make media_session_sources unconditional
The sources are used by the documentation, so rather than duplicating
the checks for whether to build it or not, just define it as
always-present empty array and fill it when needed.

Otherwise we get a meson error if media-session is disabled but
documentation is enabled.
2021-09-08 07:44:48 +00:00
Peter Hutterer 852d6fc4b6 media-session: remove a superfluous NULL check
spa_streq() checks for NULL and (through the same function) so does
pw_properties_parse_bool()
2021-09-08 07:44:48 +00:00
Wim Taymans 75f15accd5 filter-chain: add dirac pulse 2021-09-07 20:12:58 +02:00
Peter Hutterer c25cec230c meson: if WP is the default SM but not built, use the system one
If we're not building wireplumber but it is set as the default session
manager, search for one in $PATH and use that.
2021-09-07 14:09:35 +00:00
Peter Hutterer 05759e3bab meson: use 'auto' as default session manager
Right now, meson -Dsession-managers=wireplumber will fail the build
because the default session manager option is set to media-session - and
if that isn't being built we error out.

Use an 'auto' value instead, selecting the first session-manager in the
list as the default one.
2021-09-07 14:09:35 +00:00
Peter Hutterer 86362407c1 meson: improve an error message
We have -Dsession-managers and -Ddefault-session-manager, the latter is
currently only used for pw-uninstalled.sh. Let's adjust the error
message to use "default" so it's a bit easier to understand by this may
fail with -Dsession-managers=wireplumber.
2021-09-07 14:09:35 +00:00
Peter Hutterer 902444ae1a meson: if media-session is to be built but alsa is missing, error out
If -Dsession-managers includes media-session, we should error out if the
dependency is missing instead of just silently skipping the build.
2021-09-07 14:09:35 +00:00
Wim Taymans f0bc0d068e link: avoid multiple concurrent negotiations
When multiple links are created at the same time for the same port, we
get into a race where multiple links will try to set a format
asynchronously and eventually break the links. Avoid this by marking the
port as busy for as long as an async format or buffer is pending and
avoid starting new link negotiation when one of the ports is busy.

This problem was observed when ardour6 tries to link all device capture
ports to its single monitor port.
2021-09-07 15:48:44 +02:00
Wim Taymans 882f1aee6c media-session: turn some info in debug 2021-09-07 09:56:50 +02:00
Peter Hutterer 2306124f49 doc: fix listing of the new No DSP media-session module
And copy the text from the comment into the public documentation, better
than just having an empty page there.
2021-09-07 07:52:45 +00:00
Wim Taymans 7e4d5b142f pulse-server: don't leak format info 2021-09-07 09:51:58 +02:00
Peter Hutterer 8bb0e340c7 protocol-pulse: fix two -Wformat-nonliteral warnings
For the stream group, we break into the three components we write out
and print those.

For the IPv6 address printing inside [], we can make this a condition on
the printf statement.
2021-09-07 08:57:28 +10:00
Peter Hutterer 6a18272fed spa: mark the gettext wrappers with __attribute__((format_arg))
This removes the -Wformat-literal warnings for all _("some message")
calls. Remaining warnings are those where we pass in a custom buffer.
2021-09-07 08:26:10 +10:00
Pauli Virtanen b5ad37c7ac bluez5: make codec loading compatible with old conf files
Change codec factory names to api.codec.bluez5.*, so that they won't
conflict with old config file lib name rules for api.bluez5.*

Specify the fallback library name when loading the codecs, so that it
works without the rules in config files.
2021-09-06 18:04:35 +03:00
Wim Taymans 435de99428 Increase pod buffer size
The props of a 64 channel node are at least 2048 bytes long so make sure
we can build and filter them.

Fixes #1574
2021-09-06 15:09:28 +02:00
Peter Hutterer 8d741d6077 alsa-monitor: document this module in some detail 2021-09-06 07:29:28 +00:00
Peter Hutterer 7cb718833b alsa-monitor: reword the match rule comment in the config file
Each dictionary needs to fully match but out of the dicts we have, only
one needs to match to apply. Reword that for clarity.

Also document regex vs normal string comparison vs the magic null
string.
2021-09-06 07:29:28 +00:00
Peter Hutterer 6f9586bf54 media-session: use more descriptive names for parsing match rules
Easier to understand this way what is being passed around and where
we're at with the parsing.
2021-09-06 07:29:28 +00:00
Peter Hutterer 6b6f5f3659 doc: mention xdg-desktop-portal in the media-session access-portal module
Makes it slightly easier to connect the dots.
2021-09-06 07:29:28 +00:00
Peter Hutterer 55f01ae679 media-session: document the access-flatpak module 2021-09-06 07:29:28 +00:00
Peter Hutterer 08be841a9e doc: fix a doxygen undocumented parameter warning 2021-09-06 07:29:28 +00:00
Pauli Virtanen abc01083d4 context: fixup integer overflow 2021-09-05 06:26:58 +00:00
Pauli Virtanen f85d3907ef bluez5: add a device to hw-volume blocklist 2021-09-03 19:09:16 +00:00
Pauli Virtanen 68e8846096 bluez5: update kernel version blocklist
Patch fixing ALT1 mSBC is in Linux 5.10.62, 5.13.14, 5.14.1, 5.15-rc
2021-09-03 19:09:16 +00:00
Pauli Virtanen 59d572de09 bluez5: split A2DP codecs to separate SPA plugins
Make easier to package A2DP codecs separately, by splitting each to a
separate SPA plugin.  Adjust the code to not use a global variable for
the codec list.

The A2DP SPA interface API is in the bluez5 private headers, and not
exposed in installed SPA headers, as it's too close to the
implementation.
2021-09-03 20:40:30 +03:00
Pauli Virtanen 3115775c02 context: add SPA plugin loader interface to support plugins 2021-09-03 20:12:28 +03:00
Julian Bouzas 90371440b0 media-session: add alsa-no-dsp module
Instruct the policy to not configure audio adapter nodes in DSP mode. Instead,
Device nodes will always be configured in passthrough mode, and client nodes
will be configured in convert or passthrough mode depending on whether the
client format matches the device format or not.
2021-09-03 14:00:27 +00:00
Wim Taymans 91f1b44499 introspect: improve info updates
The current _info_update() methods will always reset the change_mask in
the new info structure.

This causes problems if multiple updates are applied to the info before
the rescan in the session manager of pulse-server is excuted. The first
update is cleared and this causes the session manager to sometimes miss
the state changes of nodes and fail to suspend them.

Add a new method to merge with optional reset of the various
introspection info structures. We can use this instead and simply
accumulate all changes until the rescan code has processed all changes.
2021-09-03 13:41:14 +02:00
Wim Taymans a5e37540ff impl-node: recalc graph when destroying a node with driver
When we destroy a node that still has another driver, recalculate the
graph so that the driver has a chance to idle.

This can happen when we add an inactive node to the driver and then
destroy the node, like for jack clients.
2021-09-03 11:12:51 +02:00
Wim Taymans 5fa1ae99ae media-session: implement passthrough for S/PDIF
Make sure we always suspend before reconfiguring a device.

Put the node and the device in passthrough mode when requested. Move
back to DSP mode after the node is unlinked.

Parse the exclusive flag of a stream once when the node info changes.

Use a new variable 'passthrough' to remember the current state of
a node and the peer.

Parse non-raw formats as well.

Check if two nodes can passthrough by intersecting the EnumFormat
params. If it is possible, configure the node for passthrough.

Don't try to reconnect nodes in passthrough.

Fail if we can't find a node compatible with passthrough.

See #629
2021-09-02 16:12:03 +02:00
Wim Taymans ef795cc2e3 pulse-server: add quirk for skypeforlinux
Or else it refuses to show the output devices in some cases for some
reason.
2021-09-02 15:22:27 +02:00
Wim Taymans 9052b1be33 media-session: add option to restore bluetooth profile
Add default-profile.restore-bluetooth option to restore the BT
profile.

See #1567
2021-09-02 11:39:17 +02:00
Wim Taymans f277487887 media-session: save and restore IEC958 Codecs 2021-09-02 10:27:59 +02:00
Wim Taymans 80628f38e7 alsa: move codec config to acp-device
Just like the latency, move the codecs to the device Route param.
This way, it is easier for the session manager to save and restore
the codecs as part of the Route settings.
2021-09-02 10:27:59 +02:00
Julian Bouzas 1a93165e84 impl-port: use audiomixer for RAW media subtype when setting up mixer 2021-09-01 17:35:47 -04:00
Jonas Holmberg 28cf342bb8 media-session: Change some warnings to info
If a program using pipewire-alsa calls snd_pcm_close() immediately after
snd_pcm_prepare() without reading or writing any data the client node
may be removed before the session manager can link it, which would
result in the following log warnings:

can't link 35:40 -> 43:48: link-factory: unknown input port 48
error id:25 seq:11467 res:-22 (Invalid argument): link-factory: unknown input port 48
can't link 35:41 -> 43:46: link-factory: unknown input port 46
error id:16 seq:11468 res:-22 (Invalid argument): link-factory: unknown input port 46
2021-09-01 15:15:51 +00:00
Wim Taymans eafef40430 pulse-server: remove pod debug 2021-09-01 13:25:52 +02:00
Wim Taymans ea7a731106 pulse-server: set the SINK_SET_FORMATS flag
When we have an iec958Codecs property on the node, we can use it to
configure the codecs on the sink.
2021-09-01 13:24:50 +02:00
Wim Taymans 49eb31f670 pulse-server: add device-restore extension
This is mostly to read and set the supported formats of a sink.
2021-09-01 13:23:10 +02:00
Wim Taymans a25396c1eb pulse-server: filter out iec958 PCM formats
Convert the iec958 PCM formats differently when enumerating the sink
formats. This way we can still convert the param to a format_info.
2021-09-01 13:23:05 +02:00
Wim Taymans 592163fb0a stream: rename a variable 2021-08-31 16:04:34 +02:00
Wim Taymans e7a43f6d91 filter-chain: add 7.1 virtual sink example 2021-08-31 13:52:52 +02:00
Wim Taymans dce6f30954 filter-chain: rename sink-convolver
Rename to what it actually does.
2021-08-31 13:46:36 +02:00
Wim Taymans 3300f5ddc4 context: activate loopback to drivers
We start with setting the visitied flag on the driver. Still follow the
links to other visited nodes because it might make them active. for
example, adding a link between two midi ports should make the midi
driver running so that data flows between the ports.

See #1559
2021-08-31 11:45:14 +02:00
Konstantin Kharlamov a4f3a23095 tools/pw-dump: add support for --color-always 2021-08-31 08:42:15 +00:00