Commit graph

287 commits

Author SHA1 Message Date
Wim Taymans
55b4042512 context: support foreign mainloop_api
Detect if the mainloop_api is one of ours and use the loop directly in
that case. Otherwise, make a new loop and add the fd to the foreign
mainloop_api. Make sure we clean up as well.

Fixes #345
2020-10-22 12:26:27 +02:00
Wim Taymans
7782352e8d context: track changes more closely
Mark the global changes and only emit a change event when
something changed.
2020-10-22 11:03:27 +02:00
Wim Taymans
2dee35c216 context: improve debug 2020-10-22 11:02:57 +02:00
Wim Taymans
71c760de14 pulse: fix cleanup of the stream
When the pa_stream is destroyed we need to remove it from the
global, if any (and not when the pw_stream is destroyed).

Fixes crash in gnome-control-center when switching sinks.

See #343
2020-10-21 15:05:41 +02:00
Wim Taymans
5f482b287e pulse: first signal READY, then cork if still needed 2020-10-21 10:42:29 +02:00
Wim Taymans
1af41254af pulse: set state to READY after format
Always start ACTIVE so that negotiation can happen.
When we get a format, calculate and update the latency, cork if needed
and then go to the READY state.

This is more in line with what pulse does and should improve
compatibility.

See #341
2020-10-21 10:28:18 +02:00
Wim Taymans
42fde7e00d introspect: always have an active port 2020-10-19 17:59:53 +02:00
Wim Taymans
47680ffade pulse: disable rtkit in the client
It can cause SIGKILL and crash the compositor
2020-10-19 17:23:07 +02:00
Wim Taymans
aaffda9d17 pulse: small cleanup 2020-10-19 09:31:54 +02:00
Wim Taymans
56f84ce0e4 pulse: add more debug info 2020-10-15 16:08:25 +02:00
Wim Taymans
1bd31c1cf1 don't force a MEDIA_ROLE property
The application has to set a media role.
2020-10-14 12:11:35 +02:00
Wim Taymans
6469663265 pulse: only report suspended when not corked
We only want to be in the suspended state when we are paused bu didn't
cork ourselves.

See #300
2020-10-13 20:54:39 +02:00
Wim Taymans
421a15939d pulse: clear global on the stream when destroyed 2020-10-13 10:19:02 +02:00
Wim Taymans
1d95b5bb5b pulse: fix fragsize initialization 2020-10-07 12:00:31 +02:00
Wim Taymans
d027a02223 pulse: ask up to tlength bytes
pulseaudio does not ask more than this as well.
2020-10-05 17:13:42 +02:00
Wim Taymans
6f6dc8b63e pulse: set stream READY after it is linked
Wait until we have linked the stream to a device or stream before
we emit the READY state. This is what pulseaudio expects.

Remove stream_index from disconnecting stream so that we don't
accidentally use it again. It is possible that we already created a
new stream with the same id before the old stream could complete the
disconnect.
2020-10-05 12:16:49 +02:00
Wim Taymans
ac4d4582a4 pulse: set mask after completing the operation
This ensures we first finish all pending operations and then get
notifications of the new events. Brings pactl subscribe in line
with what it does on real PulseAudio.
2020-09-30 10:16:20 +02:00
Wim Taymans
19c9a55050 pulse: first sync globals, then try operations
First sync the globals and if no global created new pending operations,
run through the operations. This ensures no operation is run before
all globals have data.
2020-09-30 10:14:44 +02:00
Wim Taymans
60df925dfd pulse: set monitor as device.class for monitor sources 2020-09-30 10:14:04 +02:00
Wim Taymans
c91afe2525 pulse: increase period size when !ADJUST_LATENCY 2020-09-29 17:58:59 +02:00
Alexander Volkov
17b6dd40e8 pulse: fix build with pulseaudio < 13.0 2020-09-29 15:47:24 +00:00
Wim Taymans
30254977c6 pulse: improve support for !ADJUST_LATENCY streams
When a stream does not specify ADJUST_LATENCY, use some slightly
different metrics to implement the readable_size. We want the app
to fill as much space as possible. Makes mplayer work and paplay
use the right amount of buffering.
2020-09-29 17:42:11 +02:00
Wim Taymans
df3394a694 add some more debug 2020-09-29 12:02:25 +02:00
Wim Taymans
62ef0145c3 pulse: limit get_writable_size()
Try to limit the amount of data we can write. Fixes chrome playback.
2020-09-29 09:57:16 +02:00
Wim Taymans
5dedf483bb pulse: fix load_module 2020-09-28 16:05:10 +02:00
Wim Taymans
588a946311 pulse: don't use queued_bytes for queue fill level
The queued bytes are already included in the read/write index.
2020-09-28 13:09:47 +02:00
Wim Taymans
fffe94771f pulse: fix fragsize
Don't round up, we give to the app what we get and use the fragsize
always when recording.
2020-09-25 17:24:05 +02:00
Wim Taymans
a79d1fc866 pulse: tweak buffer attributes some more
Seems to work well with vlc and firefox other apps now.
paplay without ADJUST_LATENCY reports wrong latency still.
2020-09-25 17:06:46 +02:00
Wim Taymans
8bb4b91e74 stream: present less writable bufferspace
firefox likes that better
2020-09-24 19:25:37 +02:00
Wim Taymans
9d694b7b38 stream: tweak the timings and buffer attributes
Use tlength as the latency.
Round attributes to frame size
Only use the delay in get_time().
Tweak queued, writable and required bytes for callbacks.
2020-09-24 17:57:10 +02:00
Wim Taymans
abf268d168 stream: tweak the timings and buffer attributes
Use tlength as the latency.
Round attributes to frame size
Only use the delay in get_time().
Tweak queued, writable and required bytes for callbacks.
2020-09-24 17:28:30 +02:00
Wim Taymans
995cf66f92 pulse: don't go lower than 8 samples per minreq 2020-09-21 11:21:15 +02:00
Wim Taymans
7a50026a2c pulse: clear queued bytes on flush 2020-09-18 20:44:21 +02:00
Wim Taymans
7c5192bc31 stream: use more accurate queued bytes and maxsize
Make lower latency streams work better.
2020-09-18 17:59:01 +02:00
Wim Taymans
1e6615f79d pulse: use the EnumFormat param to set reasonable defaults
Before the node is started, we don't get a Format parameters and we
don't know the channelmap of the node. This forces us to invent a
channelmap that might be wrong. We can do better by using the
EnumFormat param to extract some defaults for the format, rate and
channelmap. Fixes wrong channels in gnome-control-center when testing
speakers.
2020-09-18 11:06:06 +02:00
Wim Taymans
644a35a559 pulse: fallback when default sink/source not set
When we ask for the default sink/source and it is not set,
take the highest priority sink/source as the default.
2020-09-17 20:12:25 +02:00
Wim Taymans
a01cf5eeda pulse: add missing format 2020-09-17 20:10:57 +02:00
Wim Taymans
023281fd0b pulse: parse and fill up the array of formats
A sink and source can have an array of pa_format_info structures
that contain the possible formats of the device. Parse them from
the EnumFormat and return them when introspecting.
2020-09-17 16:34:18 +02:00
Wim Taymans
8406ad8a4e pulse: small cleanup 2020-09-17 16:33:38 +02:00
Wim Taymans
1f9b0c75b7 pulse: always use the default pulse channel map
This causes the least surprises when the channelmap is not
propagated correctly from pipewire.
2020-09-17 12:37:57 +02:00
Wim Taymans
688041b083 pulse: fix drain
The drain operation does not complete with a sync from the server but
with an event from the stream. Set a flag in the operation that it
completes with a sync. Keep all operations without a sync around in
the list.
2020-09-17 11:48:21 +02:00
Wim Taymans
581d4521fd pulse: clean up build file 2020-09-16 12:19:13 +02:00
Wim Taymans
23e7a54340 pulse: destroy context immediately
The mainloop might not run anymore to actually destroy the context.
2020-09-15 20:31:09 +02:00
Wim Taymans
175cd43226 context: don't leak ports 2020-09-15 15:45:04 +02:00
Wim Taymans
a599e91c68 context: don't leak port info proplist 2020-09-15 14:04:57 +02:00
Wim Taymans
e142e40cfe stream: set latency variable correctly 2020-09-15 13:22:41 +02:00
Wim Taymans
310ed89aad context: match wildcards @DEFAULT_SINK/SOURCE/MONITOR@
See #291
2020-09-14 13:21:39 +02:00
Wim Taymans
67f4acaf1d pulse: try hard to always create a valid channel map
Unknown channel names are mapped to aux channels.
Add extra AUX channels when we don't know the channel layout.
This makes sure apps always receive valid channel layouts so they
don't abort (pactl).
2020-09-14 11:06:11 +02:00
Wim Taymans
38f8c9c6c8 pulse: always notify of available data
If we have some data available for capture, always report this
to get the lowest latency possible.
2020-09-11 15:34:30 +02:00
Wim Taymans
8f75056689 pulse: improve handling of buffer attributes
Repect minreq and fragsize for playback and capture.
Try to configure tlength at 2 seconds, minreq at around 25ms. Should
greatly improve compatibility with audacious and mpv.
Count since_underrun correctly.

Fixes #278
2020-09-11 13:08:20 +02:00