Commit graph

97 commits

Author SHA1 Message Date
Wim Taymans
8ac9ce7947 pulse: avoid node lookup when connecting
We can use the node name directly if we strip the .monitor suffix
or remove the MONITOR flag form the name/id.
2020-10-24 16:58:01 +02:00
Wim Taymans
ec860d64cf Revert "pulse: we can pass the device name directly in NODE_TARGET now"
This reverts commit fc6a729c57.

Pulse passes either the monitor id or the sink.monitor name, which
are not known to the session manager.
2020-10-24 16:27:31 +02:00
Wim Taymans
fc6a729c57 pulse: we can pass the device name directly in NODE_TARGET now 2020-10-24 16:09:28 +02:00
Wim Taymans
732bf4b58c context: protect against bad context state
Avoid crash in firefox when daemon is stopped.
2020-10-23 17:10:19 +02:00
Wim Taymans
42e60b66f3 pulse: uncork stream when draining 2020-10-23 16:34:52 +02:00
Wim Taymans
67fb792d91 pulse: only call started in READY and when not corked 2020-10-23 16:34:33 +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
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
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
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
c91afe2525 pulse: increase period size when !ADJUST_LATENCY 2020-09-29 17:58:59 +02: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
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
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
e142e40cfe stream: set latency variable correctly 2020-09-15 13:22:41 +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
Wim Taymans
6eb4b552ad stream: unmark Not Implemented methods
_prebuf and _trigger are not implemented but should not really cause
any trouble, so just debug them without warning.
2020-09-11 11:41:29 +02:00
Wim Taymans
3b7f2c527c stream: call _done after operation callback 2020-09-11 11:40:57 +02:00
Wim Taymans
af64666716 pulse: call operation_done at end of callback 2020-09-09 13:48:01 +02:00
Wim Taymans
289a8e86ca stream: move some debug to trace 2020-09-03 13:19:55 +02:00
Wim Taymans
157b15d643 pulse: implement load_module of null-sink
Implement load_module of the null sink
Keep track of sink_input/source_output linked sink/source in a
better way.
Associate the global with our streams and the streams with the
global.
Don't emit the sink_input/source_output before there is a linked device
and before our stream is READY.
Improve server info to make it more look like pulse.
2020-08-20 18:00:00 +02:00
Wim Taymans
cde6b99890 stream: call latency_update callback 2020-08-19 16:49:30 +02:00
Wim Taymans
5037a97690 stream: call started callback when started
.. instead of the suspended callback
2020-08-19 16:49:02 +02:00
Wim Taymans
bb323a82a7 stream: call the moved_callback when moved 2020-08-19 16:48:25 +02:00
Wim Taymans
4e17d4cdf8 pulse: don't leak device_name
Small cleanups
2020-08-19 16:47:52 +02:00
Wim Taymans
1f298cb5bf stream: guard against old timestamps 2020-08-19 16:02:52 +02:00
Wim Taymans
6aa6b4eac7 pulse: improve debug 2020-08-18 12:12:49 +02:00
Wim Taymans
9290137931 pulse: handle NULL pw_stream
The pipewire stream might have been destroyed when the pulse stream
is freed.
2020-08-04 18:20:20 +02:00
Wim Taymans
653465a1b1 pulse: handle device_name of NULL as error 2020-08-04 18:15:19 +02:00
Wim Taymans
979fec288e stream: let the operation emit the TERMINATED state
When we disconnect, let the operation emit the TERMINATED state
because some apps expect this state to be emited asynchronously.

Makes GStreamer pulsesink work.

Fixes #210
2020-08-04 18:13:37 +02:00
Wim Taymans
94c23b7ed1 pulse: handle memory user_data of NULL 2020-08-04 18:11:58 +02:00
Wim Taymans
007c50df56 stream: clear user data on flush
Or else we might add the memory to the free list again when
we free the buffers. Fixes audacity using the pulseaudio backend
in portaudio.
2020-08-03 21:53:51 +02:00
Wim Taymans
2d76a00e20 stream: fix printf modifier 2020-08-03 09:56:37 +02:00