Commit graph

6266 commits

Author SHA1 Message Date
Volker Rümelin
92a41ba21f pipewire-pulse: generate silence on underflow correctly
Filling a buffer with zeros to produce silence is wrong for
unsigned sample formats and compressed sample formats. This is
silence with an offset. A silent stream with unsigned or
compressed samples mixed with another stream produces a clipped
stream. To hear the problem start QEMU with

qemu-system-x86_64 -accel kvm -smp 4 -m 4096 \
 -audiodev pa,id=audio0,out.mixing-engine=off \
 -machine pc,pcspk-audiodev=audio0 \
 -device ich9-intel-hda -device hda-duplex,audiodev=audio0 \
 -boot d -cdrom Fedora-Workstation-Live-x86_64-37-1.7.iso

on a host configured to use PipeWire and start audio playback on
the guest HDA device.

PA_SAMPLE_U8 is the only unsigned PulseAudio sample format.
There is no need to care about unsigned multi-byte formats.

Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
2023-03-24 19:53:26 +01:00
Wim Taymans
7b6680ba57 plugins: simplify target_ handling
Drivers should only read the target_ values in the timeout, update the
timeout with the new duration and then update the position.

For the position we simply need to add the previous duration to the
position and then set the new duration + rate.

Otherwise, everything else should read the duration/rate and not use
the target_ values.
2023-03-24 11:36:15 +01:00
Wim Taymans
f309543810 context: update the duration/rate directly when node idle
When the node is not running, update the duration/rate directly
so that followers can see the current duration/rate when they start.
2023-03-23 18:50:24 +01:00
Wim Taymans
6e8625cf96 node: update the duration/rate from the target
Before scheduling the graph from the driver, update the duration and
rate with the new targets.
2023-03-23 18:39:27 +01:00
Wim Taymans
2adf8d38d5 node: add target_rate and target_duration in io_clock
Place the target rate and duration in the io clock area.

The driver is meant to read these new values at the start of the cycle
and update the position rate and duration.

This used to be done by the pipewire server when it received the ready
callback from the driver but this is in fact too late. Most driver would
start processing and set the next timeout based on the old rate/duration
instead of the new pending ones.

There is still a fallback for the old behaviour (with a warning) when
the driver doesn't yet update the position.
2023-03-23 17:57:16 +01:00
Wim Taymans
87d64f5cad context: rename current_quantum/rate to target_*
They are really the target rate and quantum that we would like to
have and are only current after target_pending is false.
2023-03-23 17:20:01 +01:00
Wim Taymans
d78bea5e32 module-combine-stream: improve docs 2023-03-23 11:47:27 +01:00
Wim Taymans
d3cd900d06 context: restore driver rate when no longer forced
Keep track of when a rate was forced on a driver and restore the
best rate again when no longer forced.

This handles:

- paplay playing a file at 44100Hz
  --> driver openeing the device at 44100
- PIPEWIRE_PROPS='{ node.force-rate=48000 }' jack_simple_client
  --> driver being forced to a new rate of 48000
- Stop jack_simple_client
  --> Driver reverting back to 44100

Previously the driver would stay in 48000Hz until it idles.

This also works with pw-metadata -n settings 0 clock.force-rate 0.

Fixes #2133
2023-03-23 11:35:50 +01:00
Wim Taymans
8ddb6d711f context: don't reconfigure when already pending
When we already have a pending rate/quantum change, don't reconfigure
the driver.

This avoids going into an endless loop when:

1- paplay plays with 44100Hz on device1
2- jack_simple_client starts and attaches to device1
3- jack_simple_client links to device2
4- jack_simple_client is moved from device1 to device2, rate from
   device1 is moved to device2 (44100Hz)
5- device2 becomes schedulable and sees the rate should be 48000Hz (the
   default) it does a rate switch to 48KHz
6- jack_simple_client is suspended, links are back to init
7- jack_simple_client is moved back to device1
8- jack_simple_client links are activated and cycle restarts at 4

The cycle is broken because at 6 we avoid doing the suspend.
2023-03-23 10:26:21 +01:00
Wim Taymans
07e6f44e58 modules: clean up USAGE arguments
use () to mark optional arguments to avoid confusion with arrays.
Add some more optional arguments.
2023-03-22 16:35:55 +01:00
Wim Taymans
d07e1b5641 audioconvert: disable upmix by default again
But instead ship config override files to enable it again.

The idea is that distros can make extra packages that can than be
installed to enable the upmixing.

Also ship a config file to enable more samplerates.

Fixes #3081
2023-03-22 15:21:55 +01:00
jdavidsson
0d0af4c9d8 module-echo-cancel: null check playback stream
Protect against segfault when monitor.mode = true and playback stream
isn't created.
2023-03-22 11:07:17 +00:00
Wim Taymans
943f40fd3a filter-chain: add docs
Add docs for sofa and improve docs for the convolver.
2023-03-22 11:52:02 +01:00
Wim Taymans
5af265ed22 protocol-native: emit bound_id and bound_props from protocol
Emit both the bound_id and bound_props events from the protocol on
the core_resource.

Doing the dispatching of the bound_id/bound_props in the core to the
proxy doesn't handle the case where the client has a listener directly
on the core_resource.

Fixes #3109
2023-03-22 10:20:14 +01:00
Wim Taymans
fb8709716c core: add bound_props event
this event extends the bound_id event and sends the global properties as
well.

This can be used to get the object.serial, for example.

It can also be used in the future to let the server generate unique
property values, like the node.name, and let the client know about the
new property value.
2023-03-21 17:22:27 +01:00
Wim Taymans
59cd5670d7 impl-core: store hello version in core resource
So that we can later get the client core version from the resource.
2023-03-21 17:20:18 +01:00
Wim Taymans
60718c4b4f stream: don't allow _connect twice
Check if we already are connected and return -EBUSY to avoid
crashing.

Fixes #3091
2023-03-17 11:02:36 +01:00
Wim Taymans
8a9e7dc1c7 module-filter-chain: use pw_split_walk correctly 2023-03-16 16:27:12 +01:00
Wim Taymans
cb46c8c5f9 module-raop: fix compilation 2023-03-16 14:50:22 +01:00
Wim Taymans
5333c969a4 module-adapter: remove dead code 2023-03-16 13:05:53 +01:00
Wim Taymans
e1aedbab5b pw-cli: avoid property leak 2023-03-16 12:55:27 +01:00
Wim Taymans
37ac2e148e module-avb: free the right source object 2023-03-16 12:55:10 +01:00
Wim Taymans
a0717a1981 module-avb: handle NULL string 2023-03-16 12:54:50 +01:00
Wim Taymans
98a214891d handle some uninitialized variables 2023-03-16 12:29:15 +01:00
Wim Taymans
167681104b module-rtp: fix fd leak in error case 2023-03-16 12:28:51 +01:00
Wim Taymans
1c18e8aa69 handle some error cases 2023-03-16 12:28:29 +01:00
Wim Taymans
2ce722e740 pulse-server: handle NULL args in load-module 2023-03-16 11:53:59 +01:00
Wim Taymans
79b6dab5f9 modules: avoid some leaks in error paths 2023-03-16 11:44:56 +01:00
Wim Taymans
1985eb3549 module-combine-stream: make sure str is != NULL 2023-03-16 11:44:28 +01:00
Wim Taymans
026c55c0ce module-rtp: don't deref io_position when NULL 2023-03-16 11:26:20 +01:00
Wim Taymans
a3875c38ac modules-raop-sink: improve error handling 2023-03-16 11:22:35 +01:00
Wim Taymans
b4ef9fa333 pulse-tunnel: improve rate matching
Add the current fill level to the last known latency measurement right
before de do the rate matching. This improves accuracy of the matching.
2023-03-16 11:20:31 +01:00
Wim Taymans
b757638000 module-pulse-tunnel: fix rate correction sign for capture
The capture delay calculation had the wrong sign, making the resampler
go in the wrong direction and causing pitch changes.

Fixes #3093
2023-03-16 09:48:47 +01:00
Wim Taymans
106836f7d6 module-raop: add audio rate in SDP 2023-03-15 18:32:12 +01:00
Wim Taymans
d13099b9ff docs: add rtp-sap and rtp-session modules to docs 2023-03-15 18:01:15 +01:00
Gleb Popov
2a02479877 Fix rtp modules build on FreeBSD. 2023-03-15 16:53:41 +00:00
Gleb Popov
1217dee35d Fix module-zeroconf-publish.c build on FreeBSD. 2023-03-15 16:53:41 +00:00
Gleb Popov
b9c86f337d Add IPTOS_DSCP definition for !Linux platforms. 2023-03-15 16:53:41 +00:00
Gleb Popov
91250f8012 Fix rt-module.c build on FreeBSD. 2023-03-15 16:53:41 +00:00
Gleb Popov
a83d3e56c6 Move ENODATA definition into the utils.h header for more visibility. 2023-03-15 16:53:41 +00:00
Wim Taymans
114e678243 module-raop: fix compilation 2023-03-15 17:50:49 +01:00
Wim Taymans
8167e1b9be module-raop: add match rules for discover
Useful for selecting only ip4 streams or for setting up the password.
2023-03-15 17:23:41 +01:00
Wim Taymans
9e56fae236 module-raop: use newer openssl API when we can 2023-03-15 15:57:26 +01:00
Wim Taymans
deda8a10d1 module-raop: fix memory leak
Don't leak the pending messages.
2023-03-15 15:56:45 +01:00
Wim Taymans
af9d8072a3 module-raop: remove unused include 2023-03-15 12:50:27 +01:00
Wim Taymans
9a4a4fe9c4 module-raop: Use new openssl methods
Fix Digest, we need to use the method to generate a new Digest for each
request.
Use newer openssl methods instead of deprecated ones. The RSA sign still
need to be ported.
2023-03-15 10:29:35 +01:00
Wim Taymans
98222ab2ae module-raop: improve properties
Try to make a better NODE_NAME and NODE_DESCRIPTION using the
hostname and ip version.
2023-03-14 10:34:45 +01:00
Wim Taymans
51a970f5b7 module-rtp: fix writing of audio samples
Always write samples according to the current write position, only use
the graph timestamp to align.
2023-03-13 15:14:41 +01:00
Wim Taymans
6230154677 module-rtp: include config.h to get HAVE_OPUS 2023-03-13 12:50:32 +01:00
Wim Taymans
d2f7d5efe7 module-rtp: add opus to mDNS 2023-03-13 12:48:13 +01:00