Commit graph

416 commits

Author SHA1 Message Date
Wim Taymans
47bf30d734 pulse-server: create pid file only once
Only try to create the pid file once, not for every socket
we listen to.
2021-04-10 11:06:18 +02:00
Wim Taymans
33ddd5f760 pulse-server: implement module-native-protocol-tcp
The module creates a tcp server on the given ip/port pair.
2021-04-09 18:27:30 +02:00
Wim Taymans
5d20f50df8 pulse-server: use the right config property 2021-04-09 11:45:06 +02:00
Wim Taymans
44e6e7f5c8 pulse-server: use PipeWire format and channel names
Use the PipeWire format and channel names in the config to avoid
confusion.
2021-04-09 11:30:57 +02:00
Wim Taymans
b305f57e4d pulse-server: make sample format and channel_map configurable
Add an entry in the config file for default format and channel map.
Use the defaults in the server_info request
Use the defaults for the default channels and map in the modules.
2021-04-09 11:12:13 +02:00
Wim Taymans
09243d55ae pulse-server: fix leak in flatpak detection 2021-04-06 11:26:02 +02:00
Wim Taymans
bdbd3e3f2e pulse-server: Make sure we don't send null name and description
We can't send a null name or description because that makes clients
crash.
2021-04-05 17:36:38 +02:00
Wim Taymans
7bd6b725dc Fix some warnings
When memfd and systemd are disabled.

See #987
2021-04-04 21:09:39 +02:00
Wim Taymans
8cf6da467f pulse-server: use the name of the default sink
When setting a new default sink/source, use the name of the object
instead of the name used for selecting the sink/source. This makes
it possible to use the id to search for the device but still have
the device name in the metadata as is expected.

Fixes #1004
2021-04-02 10:07:39 +02:00
Arun Raghavan
e7b04bca2c pulse-server: Implement module-loopback
Implements all modargs other than rate adjustment and max latency
related ones, which do not make sense in our context.

Fixes: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/543
2021-03-31 18:19:36 -04:00
Pauli Virtanen
7b9792ffab pulse-server: fix brace in wrong place 2021-03-31 11:13:07 +00:00
Wim Taymans
dd6a18d576 pulse-server: handle 0 id as default sink/source as well
Also handle 0 id as the default sink/source

See #756
2021-03-30 10:15:36 +02:00
Wim Taymans
3878ad921a pulse-server: handle 0 sink/source name or index as default
Some apps use 0 to get some sort of sink/source info. PulseAudio
likely has a source/sink at index 0 but PipeWire certainly does not.

Asking for 0 source/sink is always because of some hardcoded values
in the app and we can return the default source/sink without causing
any problems for other apps.

See #756
2021-03-29 13:50:37 +02:00
Pauli Virtanen
2681b8236b media-session/pulse-server: more error checks + minor fixes 2021-03-27 19:16:19 +02:00
Wim Taymans
e3323f7bca pulse-server: actually handle clearing of metadata
Make sure we also set the metadata back to NULL when the object is
removed.
2021-03-26 16:28:41 +01:00
Wim Taymans
98585e092c pulse-server: handle metadata remove
Also handle the case where metadata is removed. Set the pointer to
the object to NULL. This can happen when the session manager restarts.
2021-03-26 16:04:45 +01:00
Wim Taymans
4112b34f4d pulse-server: also release and free the dbus name 2021-03-26 15:14:53 +01:00
Wim Taymans
0af8c0c045 pulse-server: check message size 2021-03-25 19:07:13 +01:00
Wim Taymans
78da72ce30 pulse-server: take length of the right string
We need to take the length of the desc, not name, to construct the
extended 'Monitor of <desc>" string.
2021-03-25 17:02:10 +01:00
Wim Taymans
5d88e072a8 pulse-server: handle NULL proxy
The proxy could be removed before we get the global remove so we need
to handle the case where we access an object without a proxy and
avoid a crash.
2021-03-25 09:08:13 +01:00
Wim Taymans
fa1350b0cf pulse-server: make sure we are active when draining
When we start draining, set ourselves active so that the process
function is called where the draining is completed.

This avoids a corked stream from waiting forever to drain the stream.

Fixes #946
2021-03-22 10:31:09 +01:00
Wim Taymans
80a6583271 pulse-server: send any STREAM_KILLED command last
Mark the stream as killed and then only send the STREAM_KILLED
command after we send the other pending commands.
2021-03-22 10:29:45 +01:00
Wim Taymans
6b6bf1e1d0 pulse-server: always reply to pending drain operation
When we destroy a stream but there is still a pending drain operation,
send an error for the drain tag first.
2021-03-22 10:16:48 +01:00
Pauli Virtanen
132786c202 pulse-server: implement send_object_message
Use it for providing Bluez codec listing/switching interface.  It
currently works by just switching device profiles.
2021-03-20 23:30:38 +02:00
Pauli Virtanen
942ead7d90 pulse-server: fix route profile numbering
Route profile numbers refer to profile ids, not indices.
2021-03-20 15:32:26 +02:00
Pauli Virtanen
7be7b258cb pulse-server: don't send invalid port profile arrays
libpulse assumes in introspect.c:fill_card_port_info that port profile
array size <= card profile array size, and may crash otherwise.

Enforce this in fill_card_info. It can happen, if EnumRoute and
EnumProfile info is not in sync.
2021-03-20 15:15:37 +02:00
Joakim Tjernlund
d983c51469 pulse-server: Emulate PA driver name as blueman looks for it 2021-03-18 16:20:30 +01:00
Wim Taymans
8d7c5732db pulse-server: remove .monitor suffix when set as default source
We place the sink name in the metadata when it is used as a default
source.
2021-03-18 10:28:47 +01:00
Wim Taymans
bc47378abc pulse-server: support moving capture streams to monitors
Also resolve the monitor ids to the sink with the monitor ports.
2021-03-17 17:02:28 +01:00
Wim Taymans
24d795e9a4 pulse-server: don't free stream map in disconnect
The cleanup handler might still run and try to iterate the streams
so make sure the map is not freed yet.

See #901
2021-03-17 16:28:21 +01:00
Jan Alexander Steffens (heftig)
c6aa48548e
pulse-server: Use fprintf to write the pid file
This simplifies the code and also avoids a warning with _FORTIFY_SOURCE:

    ../pipewire/src/modules/module-protocol-pulse/pulse-server.c: In function ‘create_pid_file’:
    ../pipewire/src/modules/module-protocol-pulse/pulse-server.c:6028:2: warning: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
     6028 |  write(fd, pid_str, strlen(pid_str) + 1);
          |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-03-13 20:09:31 +01:00
Jan Alexander Steffens (heftig)
ac9bcdee31
pulse-server: Error out if pid file name would be too long 2021-03-13 20:09:03 +01:00
Albert Chang
2ae6851698 pulse-server: create pid file on start up
Some PulseAudio clients, such as QEMU, check that the pid file exists
prior to initialization.
2021-03-13 14:47:45 +00:00
Wim Taymans
a5922a9c0a pulse-server: use async reply for set_default_sink/source
Because we set the default sink/source before calling the metadata,
we don't send out updates about the new sink and this confuses
pavucontrol.

Instead, use the new async reply to reply once the new metadata has
been configured and the defaults have been updated.
2021-03-11 15:39:19 +01:00
Wim Taymans
e334c5862e pulse-server: fill in the format info 2021-03-10 17:27:11 +01:00
Wim Taymans
d5fc67cf06 pulse-server: Prefer the formats of the extended format API
Fix enumerate the formats from the extended API and then append
the old API formats.

See #876
2021-03-10 16:55:01 +01:00
Wim Taymans
c237ccfbda pulse-server: use the manager sync method for async replies
Use the manager sync method to wait until all pending queries are
finished. It is the manager that will query the new parameters so
we need to wait until that completes.

See #868
2021-03-09 12:09:05 +01:00
Wim Taymans
d29bdf64ee pulse-server: reply async to some requests
Trigger a roundtrip before we send the reply to the client for many
methods like set_volume/set_mute etc.

this ensure that we get the updated information from the server before
we reply so that a subsequent query returns the up-to-data information.

Fixes #868
2021-03-09 09:55:48 +01:00
Wim Taymans
d9b80fda37 pulse-server: set our default sink/source immediately
In COMMAND_SET_DEFAULT_SINK/SOURCE, set our default source and sink
immediately instead of waiting for the metadata update. This makes
it possible to check for the new default sink immediately in other
modules.
2021-03-06 20:06:06 +01:00
Wim Taymans
dbebbe2f33 pulse-server: support NULL set-default-sink/source
It is allowed to set a NULL value for the default source/sink, which
then simply clears any configured value.
2021-03-06 19:58:52 +01:00
Wim Taymans
662fd8a1f9 pulse-server: avoid crashing when clearing metadata
The key will be NULL so we can't strdup it.

Fixes #845
2021-03-05 20:16:29 +01:00
Wim Taymans
c8fd34a41d metadata: store default-nodes as JSON
Don't just store the id in the metadata but a JSON object with
the node name. This makes it possible to easily introspect the
metadata and also extend the metadata with more fields later.

Instead of matching the metadata id to the global ids we now
have to match it against the name.
2021-03-05 17:37:12 +01:00
Wim Taymans
e19263140a pulse-server: improve module handling
Make a registry of modules
Assign an unique number to each module with the MODULE_FLAG bit set
so that we can also enumerate them
Implement enumerating our internally loaded modules
Implement unloading of the module using the module id
Move module-null-sink into a separate file
Use Audio/Sink if no other media.class was given, so that it works
just like the pulseaudio module
Enable linger=true in all cases.
2021-03-01 14:57:28 +01:00
Gleb Popov
dbc9a520ef Check for sys/mount.h and sys/vfs.h headers and include them conditionally 2021-02-24 19:29:57 +00:00
Wim Taymans
72acd752f6 pulse-server: don't use the pending_sample after free
Destroying the sample_play will free the user_data, which is the
pending_sample info. So don't try to use the pending_sample anymore
after destroy.
2021-02-24 12:55:34 +01:00
Wim Taymans
43f8f39d3a pulse-server: move some config params to config file
Also make the minreq/fragsize larger by default.
2021-02-23 14:57:45 +01:00
Wim Taymans
8712cfb6a1 pulse-server: remove MIN_BLOCK
It is not really used and minreq is good enough
2021-02-23 12:29:39 +01:00
Wim Taymans
8414092763 Rework profile/route handling
Add save property to Profile and Route params to notify the session
manager that they should be saved. Let the session manager only save
the Profile and Routes with the save flag.
Make pulse-server set the save flag on Profile and Route changes.
The result is that we can make a difference between user requested
changes and automatical changes and only remember the user preferences.
When a port changes availability, first check if we need to perform
a profile switch, if not select the new best port.
2021-02-22 16:51:59 +01:00
Wim Taymans
1c3a17362e pulse-server: fix weird property handling
There is no need to copy the properties, just pass ownership.
Make sure to always have properties for the server. Ensure we
clean up properties on error.
2021-02-21 09:43:02 +01:00
Wim Taymans
fcf00b3d35 pulse-server: handle unsupported formats
We can only handle PCM encodings for now, fail conversion otherwise.
If we have no supported formats, return an error code.

VLC first try to send AC3 or EAC3 passthrough and then tries again
with decoded data. If we accept the encoded data we are just playing
noise.

Fixes #428
2021-02-19 15:25:32 +01:00