Commit graph

386 commits

Author SHA1 Message Date
Wim Taymans
96d98c7955 pulse-server: express latency in samples in all cases 2021-01-24 20:33:30 +01:00
Pauli Virtanen
59452a0904 pulse-server: send server change events when default nodes change
Send server change events to subscribers, when default nodes change due
to some nodes being added/removed/changed, also if there is no metadata
change.  Make sure the event is consistent with the result from
find_device at the time.

Previously, these were not necessarily sent, or information from
find_device immediately after the event might not reflect the change
yet.
2021-01-23 07:17:19 +01:00
Wim Taymans
14dcfb8a28 pulse-server: find the target device in play_sample
Use the regular logic to find the target device for play sample so
that it supports @DEFAULT_SINK@ etc.

See #612
2021-01-22 19:53:46 +01:00
Wim Taymans
652a4ae26d pulse-server: use stream flags to tune latency
Use the early_requests and adjust_latency flags to choose the right
latency values, just like what pulseaudio does.
2021-01-22 11:39:47 +01:00
Wim Taymans
d9af97899c pulse-server: don't destroy clients playing a sample
When a sample is playing a cached sample and it disconnects we should
wait until all the pending samples are finished otherwise we stop
their playback and get a chopped or broken sample.

See #595
2021-01-21 11:53:06 +01:00
Wim Taymans
dcc5779cd6 pulse-server: put valid volume in sample info 2021-01-21 09:42:04 +01:00
Wim Taymans
44cad2d533 pulse-server: implement suspend 2021-01-20 20:33:16 +01:00
Wim Taymans
384b8a4593 pulse-server: Only allow one memblock in the queue
Allow only one memblock in the output queue. Otherwise, if the
client is for some reason not reading from the socket, we would queue
an unlimited amount of messages until we get killed by OOM.

Change some warn to debug in the process function for things we
handle from the non-rt thread.

Fixes #488
2021-01-20 10:41:34 +01:00
Wim Taymans
96a2a2b4e2 pulse-server: Use the spa json implementation 2021-01-19 16:57:33 +01:00
Wim Taymans
89641785c3 pulse-server: keep global free message pool 2021-01-19 11:06:00 +01:00
Wim Taymans
7e5441fbb3 pulse-server: implement stats 2021-01-19 10:52:29 +01:00
Pauli Virtanen
d46c58e958 pulse-server: behave like PA when moving streams to default
Pulseaudio unsets the preferred sink/source when stream is moved to a
default target. Emulate this behavior by setting + unsetting
target.node, which informs policy-node to move it accordingly.
2021-01-18 22:40:27 +02:00
Wim Taymans
02931df835 pulse-server: start with underrun_for = -1
PulseAudio starts with underrun_for equal to -1, sets it to 0 when
something was played and increments it from then on with the number
of bytes played.
2021-01-18 17:16:37 +01:00
Wim Taymans
55915f420e pulse-server: on underrun, pretend we read from the ringbuffer
Also update the ringbuffer read pointer on underrun.
2021-01-18 16:24:46 +01:00
Wim Taymans
235d25316c pulse-server: make sure we never try to ask more than tlength 2021-01-18 16:23:24 +01:00
Wim Taymans
76aff7640f pulse-server: improve variable name 2021-01-18 16:22:30 +01:00
Wim Taymans
be9c2f9757 pulse-server: account for underrun
Not quite sure, it needs more investigation but It seems the time
needs to increase when underrunning.

See #510
2021-01-17 21:07:31 +01:00
Wim Taymans
bf25fc1388 pulse-server: always use rate_match value when available
The minreq is just a fallback for when we don't know the exact
amount of required samples to consume from the ringbuffer.
2021-01-16 17:16:02 +01:00
Wim Taymans
4cba8fc7e9 pulse-server: implement set_sample_rate 2021-01-12 13:14:05 +01:00
Wim Taymans
f94d2e7da5 pulse-server: use rate match to read from ringbuffer
Use the rate match io are to read the exact amount of samples we
need for this cycle from the ringbuffer. We can then request lower
latency.

There will also be less buffering in the audioconverter, which makes
our timestamps more accurate.
2021-01-08 17:22:15 +01:00
Pauli Virtanen
b76bcdc70d pulse-server: NULL means default only if id==INVALID
The default values also only apply for sources/sinks which have
defaults.
2021-01-04 23:54:48 +02:00
Wim Taymans
0bf7b07d91 pulse-server: improve warning 2021-01-02 20:37:44 +01:00
Wim Taymans
d2a5f5c1ae pulse-server: also cleanup sample when error
Remove the separate error event and merge with the done event with
error code. This then also marks the sample as done when in error
so that it gets cleaned up properly.

Fixes #486
2020-12-18 09:50:12 +01:00
Wim Taymans
1a690a0cbb pulse-server: limit writes to ringbuffer
We can't write more to the ringbuffer than its maxsize. Some clients
send more than the negotiated maxsize and cause a crash if we don't
clamp.

See #440
2020-12-17 19:39:12 +01:00
Wim Taymans
e0580fedc1 pulse-server: handle seek flags and offset
Fixes #485
2020-12-17 16:49:17 +01:00
Wim Taymans
00295b64b5 pulse-server: don't write too small buffers
Fixes #399
2020-12-11 18:09:21 +01:00
Wim Taymans
bcf6c0986e pulse-server: read in chunks of minreq from the ringbuffer
Don't read too large chunks from the ringbuffer but in minreq
increments. This is more what pulseaudio does.

Fixes #463
2020-12-11 12:45:01 +01:00
Wim Taymans
d3db703f77 pulse-server: improve some debug 2020-12-11 12:39:46 +01:00
Wim Taymans
4ef0ef464e pulse-server: warn for unsupported seek flags 2020-12-11 10:39:15 +01:00
Wim Taymans
203679f27e pulse-server: support lookup of monitor names
Support setting a monitor as default source.
2020-12-05 19:16:04 +01:00
Wim Taymans
cfe43cbea7 pulse-server: handle NULL as default sink/source
Fixes #444
2020-12-05 13:30:02 +01:00
Wim Taymans
8c4145291e pulse-server: name and id can't be both set in volume/mute 2020-12-05 13:27:42 +01:00
Wim Taymans
0fba936b06 pulse-server: use defines for default sink/source 2020-12-05 13:26:59 +01:00
Wim Taymans
c6663b6a18 pulse-server: fix set-port
Parse the name as a string
Pass the device id and port_id in the right properties
Return an error when unknown port was specified.

Fixes #443
2020-12-04 15:41:11 +01:00
Wim Taymans
745b7ee900 pulse-server: tweak some parameters to get lower latency 2020-12-04 15:11:35 +01:00
Wim Taymans
ecc975d089 pulse-server: make sure our buffers are large enough
Allocate the buffers a bit larger so that we can handle a client that
sends a bit more data and we don't underrun.
2020-12-04 12:16:07 +01:00
Wim Taymans
3c2ab98a2a Add support for virtual source
A virtual source is usually implemented with a null-sink, it looks
like a source to pulseaudio clients but just forwards what it gets
as input.

Make sure the port names make sense.

You can use the null sink now as:

pactl load-module module-null-sink sink_name=source object.linger=1
     media.class=Audio/Source/Virtual channel_map=FL,FR,RL,RR

     This creates a node with "input" and "capture" ports and looks
     like a virtual source for pulseaudio clients.

pactl load-module module-null-sink sink_name=source object.linger=1
     media.class=Audio/Sink channel_map=FL,FR,RL,RR

     This creates a node with "playback" and "monitor" ports and looks
     like a virtual sink for pulseaudio clients.

pactl load-module module-null-sink sink_name=source object.linger=1
     media.class=Audio/Duplex channel_map=FL,FR,RL,RR

     This creates a node with "playback" and "capture" ports and looks
     like a virtual source and sink for pulseaudio clients.
2020-12-02 15:42:56 +01:00
Wim Taymans
d6127a4745 handle Duplex media class
Audio/Duplex is both a source and a sink. Name the ports as input/output
and make sure we list them in the source and sink lists in pulse-server.
2020-12-02 11:44:19 +01:00
Wim Taymans
b0a717c95e pulse-server: use right prefix for object check 2020-12-02 10:59:25 +01:00
Wim Taymans
8b048279f1 pulse-server: handle error during create
Use the create-tag in the error when the stream fails. This way the
client can know when something failed during create.

See #430
2020-12-01 09:37:40 +01:00
Wim Taymans
b8300c663b improve some errors
Silence some -ENOENT warnings, they can happen when the object we
are introspecting is destroyed
2020-11-29 16:22:50 +01:00
Wim Taymans
3b20e0f9e7 pulse-server: fix lookup of module 2020-11-26 09:49:16 +01:00
Wim Taymans
0fe77d39ce pulse-server: fallback to name if no description is set 2020-11-26 09:27:19 +01:00
Wim Taymans
cc7f91db19 pulse-server: actually wait for sync to complete
Wait for sync to complete before we start emiting new objects.
Add some more debug
2020-11-24 11:28:29 +01:00
Wim Taymans
2cd59fdf8b pulse-server: don't send invalid format and channels 2020-11-24 10:18:17 +01:00
Wim Taymans
0c66b5677b pulse-server: init volume/channelmap correctly in stream-restore 2020-11-24 09:54:42 +01:00
Wim Taymans
2d71d02f40 pulse-server: only debug packets, not data messages
See #405
2020-11-24 09:10:32 +01:00
Haochen Tong
648dfc0250
pulse-server: end the statement with semicolon 2020-11-23 23:27:53 +01:00
Wim Taymans
d56e759166 pulse-server: don't send NULL profile name in port info 2020-11-23 17:11:43 +01:00
Elliott Sales de Andrade
6224068586 Fix some possible leaks. 2020-11-23 15:36:08 +00:00