Commit graph

1030 commits

Author SHA1 Message Date
Barnabás Pőcze
6d2e6fde75 pulse-server: move parts of client creation
Move some portions of the client creation logic into client.c
so that it is easier to keep it in sync with `client_free()`, etc.
2021-12-26 19:37:41 +00:00
Barnabás Pőcze
9c218b2d08 pulse-server: remove unnecessary NULL checks
`free()` and `pw_properties_free()` already include a NULL
check before proceeding.
2021-12-26 19:37:41 +00:00
Wim Taymans
08b18b9da4 pulse-server: use partial data as missing/played for
When we can't fill a complete block, report the amount of data that we
used in missing/played instead of the complete missing part.

Fixes audio breaking up when looping in mpv.

Fixes #1132
2021-12-23 11:38:54 +01:00
Wim Taymans
3de9d3df3b pulse-server: use safer spa_scnprintf
This clamps to the max size of the input buffer so that we don't write
the next item past the allocated space.
2021-12-22 21:34:29 +01:00
Wim Taymans
2905635de3 pulse-server: increase channel name length
, and AUX11 and the \0 need at least 8 chars, 6 chars will truncate
after AUX1 and leave an invalid channel map.
2021-12-22 21:15:46 +01:00
Wim Taymans
3c66d46007 pulse-server: recalculate tlength on quantum change
Always reevaluate the tlength or total buffered samples when the
quantum changes, even for the first sample because it is possible that
we completely miscalculated the length when we started, like when the
quantum is force high and the requested latency is low.

Also only increase the calculated tlength, for smaller sizes we don't
need to do anything, we can keep the latency as is it.

See #1930
2021-12-20 17:33:55 +01:00
Wim Taymans
512a52d9c6 pulse-server: fix the number of enum values
Set the right number of enum values or else we might crash.

Fixes #1928
2021-12-20 09:13:37 +01:00
Wim Taymans
d2f676f9a6 pulser-server: push data instead of silence
When we are draining or underrunning, read whatever we have in the
ringbuffer instead of silence. This places the last samples before
the drain into the sink, padded with 0.

Fixes #1549
2021-12-18 12:32:44 +01:00
Wim Taymans
b223261240 pulse-server: flush after we push the last buffer 2021-12-18 12:32:20 +01:00
Wim Taymans
c8fc79bad2 Revert "pulse-server: only try to increase the tlength"
This reverts commit 7f0255f4ce.

Doesn't work with small quant for some reason.
2021-12-16 17:10:38 +01:00
Wim Taymans
7f0255f4ce pulse-server: only try to increase the tlength
PulseAudio only tries to increase tlength, never decrease so let's
do the same.
2021-12-16 17:08:23 +01:00
Wim Taymans
de12e8dd2c pulse-server: improve fix_* handling
When we have a fix_* flag set, make an extra format description with the
wildcards. This makes it possible for the session manager to fall back
to something when selecting a target and format.

Also only advertize the valid pulseaudio formats for the wildcards.

Fixes #1912
2021-12-16 12:56:19 +01:00
Wim Taymans
12cc3b34b1 pulse-server: implement fix_* fields
Use wildcards for the format/rate/channels when the fix flags are
set in the client.

See #1912
2021-12-16 12:24:59 +01:00
Wim Taymans
1f4254b344 pulse-server: track quantum and update tlength
Keep track of the current quantum and recalculate the tlength in the
same way that pulseaudio does.

Send a bufferattr changed message to a client when we change the
parameters.

This fixes the case where the quantum is increased and there needs to be
more buffering to keep the stream going.
2021-12-14 15:48:54 +01:00
Wim Taymans
6b81be5ac3 pulse-server: update the in_prebuf state
Move out of prebuf when we reach the prebuf amount of data. Go back to
prebuf when we run empty.
2021-12-14 15:47:19 +01:00
Wim Taymans
fd4ea442d9 pulse-server: increase buffer size
Because we keep everything in a ringbuffer and provide exactly the
required amount of data, we can use 1/4 buffers.
Also increase the buffer size. We don't want to limit the buffer size
to the negotiated tlength because it can be increased later. Instead
scale it to the max quantum size (8192) with a max resample rate of 32.
2021-12-14 15:42:19 +01:00
Wim Taymans
8caab44782 Revert "pulse-server: always ask for more data when underrun"
This reverts commit e1576c53d4.

This is not quite right, it seems to break orca and qemu audio.

See #1900
2021-12-14 10:27:01 +01:00
Wim Taymans
e1576c53d4 pulse-server: always ask for more data when underrun
Ask for more data when we are in underrun and not corked.

Fixes paplay and changing the quantum to something large.
2021-12-09 23:10:08 +01:00
Wim Taymans
7e5a0849f6 Revert "pulse-server: always asks for more data when underrun"
This reverts commit 1b94b66924.

It causes problems with qemu.

Without this patch, paplay --latency-msec=1 /some.wav hangs when
forcing the quantum to 8192. A different fix will be needed.
2021-12-09 16:54:47 +01:00
Wim Taymans
a8139b7acf pulse-server: handle prebuf state better
When we have a prebuf value, we start in the prebuf state.
We go back to prebuf when we have a prebuf value and an empty
ringbuffer.
2021-12-03 17:49:59 +01:00
Wim Taymans
16665d74d2 pulse-server: don't clamp missing bytes to tlength
When we increase the quantum past the tlength, we need to be able to
ask for more bytes than the tlength or else we will never exit this
underrun state. Look at the last required bytes and use that if it's
larger then tlength.
2021-12-03 16:43:16 +01:00
Wim Taymans
1b94b66924 pulse-server: always asks for more data when underrun
Even when prebuffer is active, we need to ask for more data to
resolve the underrun.
2021-12-03 16:41:41 +01:00
Wim Taymans
cc9fbe4375 pulse-server: add some debug 2021-11-30 09:22:58 +01:00
Wim Taymans
700a22b7f7 pulse-server: recover for underrun better
If we are underrun, don't update the read pointer and let the write
pointer catch up.
If we don't have enough data to fill a buffer, skip all the available
data and wait for the new request to arrive.

Fixes #1857
2021-11-29 20:22:05 +01:00
Wim Taymans
a0d7fb01ba pulse-server: add size check when reading strings 2021-11-25 10:14:30 +01:00
Wim Taymans
5d20e3028a pulse-server: avoid reading past the message size
We can't really get into this situation but it is a good idea to check
that we don't try to read past the message length.
2021-11-25 09:48:34 +01:00
Wim Taymans
ac4ec20b01 pulse-server: free pending client message
If the client is destroyed before it could completely read the message,
free the pending message as well.

See #1840
2021-11-23 18:13:35 +01:00
Wim Taymans
9feecb36d0 pulse-server: don't add large blocks to cache
See #1840
2021-11-23 17:44:01 +01:00
Wim Taymans
418c6fbe96 pulse-server: limit the max cache to 16MB
Don't recycle messages when we have too many allocated already.

See #1840
2021-11-23 17:24:24 +01:00
Wim Taymans
5ae75e1d2a pulse-server: use STREAM_CAPTURE_SINK for monitor capture
Make the pulseaudio layer set the PW_KEY_STREAM_CAPTURE_SINK property
when a monitor device is selected as a source to make it easier for the
session manager to find the right source.
2021-11-19 20:24:58 +01:00
Wim Taymans
af2e7b630a pulse-server: turn error into info
Receiving a message from an already removed stream should not result in
an error message.

See #1812
2021-11-16 12:33:23 +01:00
Wim Taymans
6ce9260980 pulse-server: implement module-raop-discover 2021-11-12 17:53:24 +01:00
Nicolai Syvertsen
a84cfac28a Only handle -EPIPE eerrors. 2021-11-10 19:26:03 +00:00
Nicolai Syvertsen
7b773433f4 pipewire-pulse: add manager disconnect event
Drop client connections when pipewire goes away. pipewire-pulse daemon can remain running and pulseaudio clients will be able to connect again once pipewire is up and running.
2021-11-10 19:26:03 +00:00
Wim Taymans
c9fc3d7f42 pulse-server: don't process while the stream is created
When the stream is still being created, avoid doing any processing
because some things might not be configured yet.
2021-11-09 16:29:46 +01:00
Wim Taymans
743f699193 pulse-server: try to not put pointers in info messages
It's not very helpful, prefer to use human readable strings and move the
more techincal stuff in debug messages.
2021-11-05 16:22:22 +01:00
Wim Taymans
2f3e65c049 pulse-server: leave the draining state
Use pw_stream_set_active() to leave the draining state so that our
process methods are called again and we can resume.
2021-11-05 15:47:49 +01:00
Wim Taymans
0cccff517b pulse-server: send the drained event only once
Only send the drained command once. pw-stream keeps on emitting drained
events as longs as the stream is drained.
2021-11-05 15:42:33 +01:00
Wim Taymans
6ca297797f pulse-server: ensure latency is multiple of frame_size 2021-11-05 13:31:09 +01:00
Wim Taymans
b96f15d2fe pulse-server: improve latency setup a little
Reorganize the latency setup in one place, return a desired device
latency for use as quantum.

PulseAudio assigns half of the (tlength - minreq) latency to the sink
but we can't do that because our sinks have a max-quantum of latency.
Fix this by clamping our calculated sink latency to the quantum

PulseAudio subtracts the sink latency from the tlength in adjust latency
mode, so we need to do the same.

This makes PULSE_LATENCY_MSEC values bahave more like pulseaudio.

See #1769
2021-11-04 18:07:30 +01:00
Wim Taymans
86ca0f8466 acp: improve debug of channel map
Increase the size of the channel_map debug printf buffer.
Use a safer version of the snprintf that avoids buffer overruns.

See #1781
2021-11-04 16:41:32 +01:00
Wim Taymans
efd8ac25e3 pulse-server: don't emit _removed without havine emitted _added
Don't emit _removed for objects that are still being created because
we did not emit an _added signal for them yet.
2021-11-04 12:50:18 +01:00
Wim Taymans
f70fdf5605 pulse-server: also remove creating objects
When an object is created, it is marked creating until all roundtrips
complete. If the object is removed in between, we don't remove it
because find_object does not return creating objects.

Make find_object also return the creating objects to fix this.
2021-11-03 16:57:41 +01:00
Wim Taymans
a2f06be199 pulse-server: Improve combine sink properties
Make streams and sink have the same description so that they show
up as the same node in catia.
2021-10-26 10:50:28 +02:00
Wim Taymans
33653cbabf protocol-pulse: flush streams on pause
To remove any lingering data
2021-10-26 10:49:50 +02:00
Barnabás Pőcze
4c27c3fd43 pulse-server: use for-each loop
Use `SPA_FOR_EACH_ELEMENT` to enumate the elements
in the array instead of an "indexed" loop.
2021-10-18 15:36:22 +02:00
Barnabás Pőcze
3fefb55ef2 pulse-server: return NULL instead of 0
... to be consistent with the vast majority of the
existing source code.
2021-10-18 15:36:22 +02:00
Barnabás Pőcze
ee7b82ac9e pulse-server: remove unnecessary NULL check
`spa_streq()` already checks for NULL pointers, so the
pointer does not need to be checked before calling it.
2021-10-18 15:36:22 +02:00
Barnabás Pőcze
80ae688cc6 pulse-server: compile extensions separately
Avoid including other C source files. Compile them separately.
2021-10-18 15:36:17 +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