Commit graph

275 commits

Author SHA1 Message Date
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
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
2f02928580 pulse: add more debug 2020-09-10 13:04:56 +02:00
Wim Taymans
c8700b2e4b pulse: keep track of availability of active port
Also emit a device change event when the availability of the
active port changes.
2020-09-09 13:51:42 +02:00
Wim Taymans
8638fd0411 pulse: improve operation handling
First move all completed operations to a new list, then complete
the operations and cancel the ones that are not completed correctly.
This ensures that new operations from the callbacks don't get
completed immediately as well.
2020-09-09 13:49:09 +02:00
Wim Taymans
af64666716 pulse: call operation_done at end of callback 2020-09-09 13:48:01 +02:00
Wim Taymans
a477e39de2 pulse: improve debug 2020-09-09 13:47:20 +02:00
Wim Taymans
734dc72bf2 context: don't leak device port info 2020-09-09 13:22:09 +02:00
Wim Taymans
0d1b01147f context: handle route changes better
Track the current route and the properties independently. Else we
might skip parsing the volumes/mute properties when the current
route didn't change.

Fixes #281
2020-09-07 16:54:21 +02:00
Wim Taymans
f541bf9037 pulse: implement custom mainloop poll function
Implement setting a custom poll function. When there is a custom
function, just poll the epoll fd in it.

Fixes #276
2020-09-07 15:50:58 +02:00
Wim Taymans
71441565fd pulse: rework sync
Use a global sync that both syncs the globals and completes the
operations.

In the case of a card profile change, first the nodes are removed
and added and then the Profile and Route info updated. We need to
be able to bind to the new node and get the device.profile.id
before we can find the active port of the node.

See #279
2020-09-07 14:36:25 +02:00
Wim Taymans
289a8e86ca stream: move some debug to trace 2020-09-03 13:19:55 +02:00