Commit graph

8482 commits

Author SHA1 Message Date
Wim Taymans
5b3388e4ac audioconvert: add optional hilbert transform to rear channels
Add an option to do a hilbert transform on the generated rear channels
to do a 90 degree pahse shift on them. This can improve spacialization
of the rear channels.

See #861
2022-03-01 11:09:43 +01:00
Wim Taymans
5dd0a12875 channelmix: add option for stereo widen
When generating FC, add an option to subtract some of the generated
FC from the FL and FR channel to move the sound more to the center.

See #861
2022-03-01 10:28:11 +01:00
Wim Taymans
60b338d4cf channelmix: place L-R in rear channels
L-R is supposed to be the ambient sound, which should sound better in
the rear channels.
2022-03-01 10:14:07 +01:00
Wim Taymans
5a307c11e1 audioconvert: add delay to rear channels when upmixing
See #861
2022-03-01 09:56:12 +01:00
Wim Taymans
d62d2764e8 channelmix: improve corssover processing
Apply volume after crossover, optimize when disabled or silent.
2022-03-01 09:08:17 +01:00
Wim Taymans
168511c157 filter-chain: do some checks on the number of ports
Try to check that we don't overflow our port arrays.
2022-02-28 20:44:05 +01:00
Wim Taymans
5c44c6cd5c filter-chain: use MAX_CONTROLS for control ports
See #2179
2022-02-28 20:32:35 +01:00
Pauli Virtanen
fb04074335 pulse-server: set also metadata target.object when moving streams
Set also metadata target.object when moving streams, in case the session
manager supports that.
2022-02-28 18:36:26 +00:00
Tasos Sahanidis
daf85f1cd6 pw-top: Fix unicode character clipping
Instead of using snprintf to clip the node line to the terminal width,
causing multibyte characters to be split improperly, this lets curses
wrap the text as it normally would, and then overwrites the wrapped
text with the next line, simulating clipping.
2022-02-28 18:30:34 +00:00
Pauli Virtanen
ab353a8057 module-session-manager: set object.serial on session objects
Session, endpoint, link, and stream objects should also set
object.serial.
2022-02-28 20:11:01 +02:00
Pauli Virtanen
3b94345bbe module-metadata: set object.serial on new client metadata
Client-created metadata should also set object.serial.
2022-02-28 20:11:01 +02:00
Pauli Virtanen
09d005aa3e impl-client: add workaround for old pipewire-media-session compatibility
pipewire-media-session purposefully makes one of its cores to lag the
other, and then uses it to bind ids it obtained from the faster core.
This no longer works with the registry generation number checks.

It's possible to fix in p-m-s, but we can also add a specific workaround
for it.

This workaround is supposed to be eventually removed.  Workarounds for
other apps should not be added.
2022-02-27 15:04:23 +02:00
Pauli Virtanen
d71cf24183 global: update generation number also in clients without registry
Not all clients have an existing registry, and the registry generation
number will not be updated for them.  However, we would like to check
for stale globals also elsewhere, eg.  metadata, and it must work also
in this case.

To avoid failing to update client registry generation, on global
addition which the client would see if it had a registry, send done
message for the new global id instead.
2022-02-27 15:04:23 +02:00
Pauli Virtanen
a9accd1668 protocol-native: footer pre_demarshal must come first
Message footer should be handled before attempting to find the object
the main message is sent to / checking permissions, because it is not
aimed at a specific object.  E.g. the registry generation updates should
be handled regardless of whether the main message is valid or not,
because the updates will not be re-sent.

Fixes registry generation updates sometimes going missing.
2022-02-26 17:48:51 +00:00
Pauli Virtanen
b9b57d32d5 channelmix: set mix log earlier
Set mix.log already in impl_init, since it's not going to change.
Should fix null pointer access under some cases.
2022-02-25 20:32:48 +02:00
Wim Taymans
1cf869cea8 channelmix: fix lfe-cutoff parsing 2022-02-25 11:20:19 +01:00
Wim Taymans
bf52630153 pw-cli: fix print of pod debug 2022-02-25 11:14:34 +01:00
Wim Taymans
ab8f9be979 channelmix: recalc channelmix when param changed 2022-02-25 11:13:10 +01:00
Wim Taymans
7241bf3c54 channelmix: remove LFE when cutoff is <= 0.0 2022-02-25 11:13:04 +01:00
Julian Bouzas
6dbdb2eecb bluez5: only consider A2DP profiles if HSP/HFP backed is none
This allows BT device to connect instantly instead of waiting for profile
timeout when hsp/hfp backend is none, because all available profiles are
connected.
2022-02-24 15:17:19 +00:00
Wim Taymans
2e8e8938bc channelmix: add stereo to 7.1 upmix 2022-02-24 16:09:14 +01:00
Wim Taymans
b1ca470d99 channelmix: don't pass channels around
We have this info in the channelmix structure.
2022-02-24 13:09:25 +01:00
Wim Taymans
76aaae2034 pulse-server: get stream id in paused
We can get the stream id when going to PAUSED.
2022-02-24 13:08:50 +01:00
Wim Taymans
6ed60eb868 channelmix: Fix copy and paste error 2022-02-23 07:39:23 +01:00
Wim Taymans
ac25d126de channelmix: use the right channelmap
For merger setup (consuming a source) we want to expose the channelmap
of the remixed signal (to the application/sink).
For splitter setup (providing data) we want to expose the channelmap
of the original source (before remixing to sink).

Hide the merge channel props because they contain the channelmap before
mising and we want to expose the remixed signal in merger mode.

This fixes some weird volume issues when an input stream is linked
to a source and is remixing, like when a stereo stream is captured
from a mono source.
2022-02-22 18:20:07 +01:00
Wim Taymans
0b7da17083 channelmix: fix 5p1 -> 2 see channelmix
If was applying the volume of the front to all channels.
2022-02-22 18:06:48 +01:00
Wim Taymans
6769becac5 module-echo-cancel: fix leak on error
Don't leak the properties on error.
Use and log the error returned from the init function.
2022-02-22 17:27:33 +01:00
Wim Taymans
d06e13210d filter-chain: move node.name to the streams
The global node.name is not used anymore because the streams need unique
names.
2022-02-22 15:48:43 +01:00
Wim Taymans
2cd3427786 pulse-server: fix device.description
We now translate device.description to node.description when parsing
the properties so check for node.description and generate one when
it's not available.

Fixes #2166
2022-02-22 15:27:06 +01:00
Wim Taymans
580f499939 filter-chain: improve error reporting
Don't overwrite the errno from the plugin loader with 0 so that we can
actually report the right error.
2022-02-22 12:42:36 +01:00
Wim Taymans
bc8df52317 conf: return the error
Only return the loaded items when there is no error.
2022-02-22 12:41:58 +01:00
Wim Taymans
542b0acd73 context: set zero_denormals in data thread.
Use invoke to set the zero-denormals flag from the data thread when
explicitly set. The flag is per thread and should really only be set on
the data thread and only when explicitly enabled.

Fixes #2160
2022-02-22 11:31:06 +01:00
Wim Taymans
62ae9b7d30 filter-chain: avoid denormals in biquad
See #1681 #2160
2022-02-21 17:34:52 +01:00
Wim Taymans
820e282a14 context: don't touch denormals settings when left unset
We should not influence the denormals CPU flag unless explicitly
requested in the config.
2022-02-21 17:19:57 +01:00
Wim Taymans
edb5664017 pulse-server: fix IEC958 passthrough again
We need to create fake channels when parsing the IEC958 format or
else we get an invalid format and IEC958 passthrough doesn't work.

Ignore the IEC958 formats when collecting formats for the device or else
the fake channels mess with the real channels of the device.

See #1442
2022-02-21 16:53:03 +01:00
Wim Taymans
22ec01d5c0 pulse-server: improve fix_ flags handling
PulseAudio will convert the samplespec/channelmap to a format_info
and omits the input format/rate/channels when the fix flags are set. It
does not use the input values at all.

Do the same in pipewire-pulse, make a single format description without
the requested fields.

This also needs a session manager fix to make it deal with those missing
fields.

See #876
2022-02-21 15:19:08 +01:00
Wim Taymans
c0727e1efc audioadapter: improve fixation of the format
Keep track of the format as given in the PortConfig.

Instead of blindly fixating the negotiated format to whatever default,
use the PortConfig format to fixate to something better.

This makes the channels/position, rate or format match the PortConfig
format when this is possible and results in the least amount of conversions.

It mostly improves the handling of wildcard formats, were a stream only
specifies some fields and leaves the other free.

A concrete case is WINE that uses the pulseaudio FIX flags to omit the
number of channels and rate. With this change, the stream will negotiate
to the format of the linked sink and obtain the channelmap from it.

See #876
2022-02-21 15:18:20 +01:00
Wim Taymans
e420b9c93c pulse-server: place the final sample rate as property
Use the final negotiated sample rate as node.rate to suggest a rate for
the graph.
2022-02-21 14:54:21 +01:00
Wim Taymans
d6a2b21fbe pulse-server: don't deref freed pending_sample 2022-02-21 11:12:10 +01:00
Wim Taymans
0475adbd35 pulse-server: wait for pending_sample to complete
Wait the reply to be sent and the sample to complete playback before
freeing the sample. Otherwise it might have been possible that the
sample completes before the reply can be sent.
2022-02-21 08:57:15 +01:00
Wim Taymans
1d9be5b25a pulse-server: ref client while completing operations
So that an operation can't accidentally free the client.
2022-02-21 08:56:02 +01:00
Wim Taymans
90eb1c18e0 pulse-server: unlink operation before callback
To ensure that the callback can't accidentally find and free the
operation.
2022-02-21 08:54:50 +01:00
Wim Taymans
d7793501fd pulse-server: free pending sample reply
If the sample finished playing before we finished the roundtrip to
get the sink_index, it will be destroyed. When the roundtrip completes,
it will try to use invalid memoryy and crash.

Make sure we destroy all pending replies before destroying the sample
to avoid this problem.

Fixes #2151
2022-02-20 21:34:53 +01:00
Pauli Virtanen
bf9ef440c3 protocol-native: check invariant for marshaled data
There's an assumption that marshaled messages consist of a single POD,
since we now tag on a footer after it.  This is true for the
protocol-native implementations, which all wrap the message in a single
POD Struct.

To catch protocol-native implementation bugs here later, add assert that
marshaling produces a single POD.
2022-02-20 18:19:13 +02:00
Pauli Virtanen
d44bf0ffc0 impl-core/protocol-native: use generation counter for global registry
Some client messages have bare ids (as opposed to proxies/resources),
eg. as in pw_registry_bind/destroy.  If the client is processing
messages late, these may refer to an object that was already removed,
and the id may now refers to a differnt objects.  I.e. the following
race condition needs to be resolved:

server               client
Global 1 (gen. 1)
                     Global 1
Global 1 remove
Global 1 (gen. 2)
                     Bind/destroy 1

Where the client would bind/destroy the wrong global, since it did not
yet see the messages for the second one.

To keep track of which object the client means, the server keeps track of
the "generation number" of its global registry, and what generation
the client is at.

Each global remembers at what generation of registry they were
registered. When processing the messages that use bare ids, check the
registry generation of the client, to know whether the message refers to
a stale global that was already removed.

Messages where client sends bare ids to server are:

    pw_registry_bind, pw_registry_destroy, metadata_set_property

In pw_registry_* do the staleness check directly. Also add staleness
check in pw_impl_client_check_permissions, so that also the metadata
case is handled.

The generation numbers are passed around in message footers, but only if
they have changed.  When the generation number changes on server, we
send the updated value to the client in a message footer.  When client
has received an update value, it will send the value back in the footer
of the next message it sends to the server.

Based on: Wim Taymans <wtaymans@redhat.com> "impl-core: check serial number"
2022-02-20 16:59:25 +02:00
Pauli Virtanen
680c33d3eb protocol-native: extend v3 protocol with message footers
Extend version 3 protocol with message footers, which are for passing
around global state data that is not addressed to a specific object.

The extension is backward compatible with previous v3 clients, and won't
e.g. result to error spam in logs.

The footer is a single SPA POD, appended after the main message POD.
Because both the protocol message and the message POD record their
length, it's possible to append trailing data. Earlier clients will
ignore any data trailing the message POD.

The footer POD contains a sequence [Id opcode, Struct {...}]*,
so there is room to extend with new opcodes later as necessary.

There are separate marshal/demarshal routines for messages aimed at
resources and proxies.
2022-02-20 16:59:25 +02:00
Pauli Virtanen
c4997fc46d pipewire-pulse: moving DONT_MOVE streams should fail
Pulseaudio return EINVAL for attempts to move DONT_MOVE streams.
2022-02-20 01:30:48 +02:00
Barnabás Pőcze
d1f7e96f82 test: loop: add test for destroying source of thread loop
Add test which tries to destroy an active source precisely
after the loop has returned from polling but has not yet
acquired the thread loop lock.
2022-02-18 20:31:49 +01:00
Barnabás Pőcze
16f63a3c8f Revert "loop: remove destroy list"
This reverts commit c474846c42.
In addition, `s->loop` is also checked before dispatching a source.

The destroy list is needed in the presence of threads. The
issue is that a source may be destroyed between `epoll_wait()`
returning and thread loop lock being acquired. If this
source is active, then a use-after-free will be triggered
when the thread loop acquires the lock and starts dispatching
the sources.

  thread 1                       thread 2
 ----------                     ----------
                                loop_iterate
                                  spa_loop_control_hook_before
                                    // release lock

 pw_thread_loop_lock

                                  spa_system_pollfd_wait
                                    // assume it returns with source A

 pw_loop_destroy_source(..., A)
  // frees storage of A

 pw_thread_loop_unlock
                                  spa_loop_control_hook_after
                                    // acquire the lock

                                  for (...) {
                                    struct spa_source *s = ep[i].data;
                                    s->rmask = ep[i].events;
                                      // use-after-free if `s` refers to
                                      // the previously freed `A`

Fixes #2147
2022-02-18 20:31:14 +01:00
Wim Taymans
bb1cd23a1a modules: fix warning 2022-02-18 15:12:27 +01:00