Commit graph

297 commits

Author SHA1 Message Date
Wim Taymans
aba02806cf mainloop: do better wallclock to rttime conversion
The mainloop time_new is supposed to be called with wallclock time
but some apps use rttime instead. Handle the case better so that we
never end up disabling the timer.
2020-10-23 16:33:05 +02:00
Wim Taymans
2a0828e7a2 pulse: emit sink/source changes when pending
After we get the Route update, schedule subscription events when
there are changes pending. When we scheduled a volume change ourselves,
it is likely that nothing got changed by the route update but
we still have to emit the subscription event to notify the new volume.

Fixes #298
2020-10-23 10:09:40 +02:00
Wim Taymans
ec40702427 pulse: handle NULL timespec 2020-10-23 09:52:30 +02:00
Jan Tojnar
2e3556fa12
pulse: Add libpulse path to rpath
We are linking against PulseAudio’s libpulse,
which adds its soname to DT_NEEDED but we are expecting
to actually use our shim with the same soname from LIBPULSE_PATH
(forced by adding the path to LD_LIBRARY_PATH).

Package managers like Nix will detect that we are linking against
PulseAudio’s libpulse and mark it as a runtime dependency by adding
its path to DT_RUNPATH entry so that it can be easily found
by the loader. LD_LIBRARY_PATH will take precedence but it will still
pull PulseAudio into the system’s closure.
2020-10-23 05:36:47 +02:00
Wim Taymans
f3dda8e57b pulse: Use the right conversion functions for volumes
PulseAudio uses cubic volumes and PipeWire uses linear volumes
so use the right conversion functions from one to the other.
2020-10-22 19:34:47 +02:00
Wim Taymans
9c0ff170f9 pulse: add volume change example 2020-10-22 16:47:24 +02:00
Wim Taymans
413c233b9a mainloop: convert from wallclock to rtclock
This is needed for the mainloop timeouts
2020-10-22 16:46:29 +02:00
Jan Grulich
743cf58fb7 Define SPA_FALLTHROUGH to make fall-through annotations work for all compilers
This is needed for example for Clang compiler which uses different
annotations than GCC. It will make WebRTC to happily use PipeWire
since the spa library is header-only and WebRTC defaults to use
Clang with -Wimplicit-fallthrough.
2020-10-22 13:31:19 +02:00
Max Jöhnk
406b99c4c5 context: fix @DEFAULT_SOURCE@ wildcard 2020-10-22 11:23:17 +00:00
Wim Taymans
4450ddadcf pulse: mark the global changed when volume/mute changed
When we change the volume/mute of a sink/source, mark the source
as changed so that when we get the update from the server we
emit a CHANGE event. We don't do this otherwise because the server
volume update and our local volume is the same.

Fixes #298
2020-10-22 13:18:09 +02:00
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