Commit graph

985 commits

Author SHA1 Message Date
Gleb Popov
6ea24a7db5 Don't call getsockopt with SO_PEERCRED and SO_PEERSEC parameters on FreeBSD. 2019-11-19 13:41:40 +01:00
Wim Taymans
68e94a2e7e system: use spa_system functions for fds 2019-11-19 13:41:40 +01:00
Wim Taymans
4ad7ce3aa2 session-manager: split policy and monitor
Separate the session manager in a monitor and policy part.

The monitor manages the devices and endpoints.

The policy watches the nodes/ports/clients and applies the policy
of linking them.

Because both now have a separate connection, we can remove some
hacks in the protocol. When a remote was both the implementer and
user of an object we could get in a deadlock when the user was
blocked waiting and the implementator was blocked sending a reply.
We used to un-busy a client when it was expecting a reply from a
ping or sync for this reason.

Add and use some more keys for the endpoints and streams.
2019-11-07 16:03:00 +01:00
Wim Taymans
9df6efcd8d properties: copy_keys -> update_keys
Change copy_keys to update_keys and make it more powerful by taking
a spa_dict as the source.
Copy some more properties in the session.
2019-11-05 16:35:15 +01:00
Wim Taymans
6397db9d68 protocol: init spa_dict properly
Or else the flags might be wrong.
2019-11-04 17:30:33 +01:00
Wim Taymans
085f1822b9 session-manager: fix protocol
Add separate types for interfaces and implementation
Fix some bugs in the protocol
Add some introspection support in cli
2019-11-04 17:30:33 +01:00
George Kiagiadakis
1e14206c71 extensions: implement new session manager extension
This extension, implemented in module-session-manager, implements
a set of objects that are useful for session managers.
2019-11-04 17:30:33 +01:00
Wim Taymans
0a81a982f7 metadata: Add metadata API
Metadata allows apps to attach properties to objects that can be
read by other apps.
Not complete yet, properties should be removed when the object is
removed.
2019-11-03 10:31:14 +01:00
Wim Taymans
8ddf579cc0 protocol: add flags to protocol marshal
Allows us to to select marshallers for implementation and binding.
2019-11-03 10:21:57 +01:00
Wim Taymans
ebb5ed94a2 add some docs 2019-10-25 15:01:27 +02:00
Wim Taymans
9ffec214b8 fix includes 2019-10-25 15:01:02 +02:00
Wim Taymans
38bc80a3b8 remote-node: implement suspend 2019-10-23 17:20:46 +02:00
Wim Taymans
e18ca6e9c8 protocol-native: don't try to flush when the source is gone
When the connection is broken, we destroy the source avoid trying
to flush when the source is gone.
2019-10-08 23:47:02 +02:00
Wim Taymans
082463efd0 protocol: add v0 compatibility
For flatpaks we need to be able to support older v0 protocol clients.
To handle this we have:

- the connection detects an old client when it receives the first
  message. It can do this by checking the sequence number, on old
  versions it contains the message size and is never 0, on new
  clients the sequence number is 0.

- We add a new signal at the start of the connection with the detected
  version number. This installs the right version of the core proxy.
  We also move the binding of the client until the hello message is
  received. This way we can have a new client connect (portal),
  hand over the connection to an old client, which then removes the
  client binding again in the hello request with a v0 version.
  There are some changes to the passing of fds in v0 vs v3 which need
  to investigated some more.

- bump version of our interfaces to 3. This makes it possible to
  have v0 and v3 protocol marshal functions.

- Add version number in the proxy. This is mostly automatically done
  internally based on the version numbers the library is compiled
  with. Where the version number was in the API before, it is now
  actually used to look up the right protocol marshal functions. For
  Proxies there is usually just 1 version, the current one. It is the
  server that will support different versions.

- Add v0 compat marshal functions to convert from and to v0 format.
  This has some complications. v0 has a type map it keeps in sync
  with the server. For this we have a static type map with mappings
  to our own v3 types. Pods are mostly the same except for objects
  that used to have arbitrary pods in v0 vs spa_pod_prop in v3. Also
  convert between v0 spa_pod_prop and v3 spa_pod_choice.
  Formats and commands are also slightly different so handle those
  mappings as well.
  We only have marshal functions for the server side (resource)
  v0 functions.

- Add v0 compatible client-node again. It's a bit tricky to map, v0
  client-node basically lets the server to the mixing and teeing
  and just does the processing of the internal node.
2019-10-08 23:20:18 +02:00
Wim Taymans
117db11f7e Remove some unused fields 2019-10-08 22:44:56 +02:00
Wim Taymans
6e0c279bc1 improve properties on objects 2019-10-02 20:16:12 +02:00
Wim Taymans
5cfb6634f4 port: select a mixer when we set a format
When the port receives a format, look if we can find a mixer for it
and configure it.

Use the float32 mono mixer when possible.

Use the new pw_buffers in the link.

Let the port allocate buffers between the mixer and node when
requested.

The client-node doesn't need a mixer because mixing is done on the
client.

Remove all mixer and buffer negotiation code from adapter because
it is now done at the port level.
2019-10-02 18:07:10 +02:00
Wim Taymans
6e0ffb0c47 flags: change flag macros
SPA_FLAG_CHECK -> SPA_FLAG_IS_SET
SPA_FLAG_UNSET -> SPA_FLAG_CLEAR
Add SPA_FLAG_UPDATE
2019-10-02 18:00:42 +02:00
Wim Taymans
cc8e992cd1 protocol: improve flushing
Use the IO_OUT flag to schedule flushing instead of a flush_event.

Handle EGAIN and wait for IO_OUT to try again.

Fixes #111
2019-10-01 12:53:56 +02:00
Wim Taymans
3d48ba8394 connection: move remaining data and fds
If we can't send all of the data, move the remaining data to the
start of the buffer so that we can send it again later.

See #111
2019-10-01 10:45:20 +02:00
Wim Taymans
68fc530d9c remote: take ownership of properties in _export()
pw_remote_export() takes ownership of the properties so implement
this in the device and spa_node export functions.

Fixes #187
2019-09-27 10:06:25 +02:00
Wim Taymans
efe3aba608 adapter: put port channel in port name if possible 2019-09-25 10:44:40 +02:00
Wim Taymans
db341a6450 improve properties on node and port
Rename some alsa filenames.
2019-09-23 20:51:34 +02:00
Wim Taymans
77e07e1948 improve properties on globals and ports 2019-09-20 13:28:06 +02:00
Wim Taymans
6756a3c8fc monitor: remove monitor API and use device
Remove the monitor API, we can use the device API for it. Make sure
we support creating devices (like alsa) from another device (udev).

Use new object.id to store the object id in the object properties. Use
the port.id/node.id etc to make relations to other objects.
2019-09-20 13:04:14 +02:00
Wim Taymans
8b85cc225e rename HAVE/NEED_BUFFER -> HAVE/NEED_DATA
It is more generic and works with control-only ports as well
2019-09-16 12:55:23 +02:00
Wim Taymans
9c9bff8fe9 data-loop: add _wait function
Add function to wait for one iteration of the loop. This can be used
by specialized implementations of the data loop, like jack.
2019-09-09 17:17:03 +02:00
Wim Taymans
faaf84286b node: improve position and transport
Reorganize some things, let the clients update the segment info
in their own activation, then let the server merge it. This avoids
clients stepping on eachother. When looping through the clients,
copy the segment info when we encounter its owner.

Remove the list of segment owners to the activation. This is better
than in the activation because we can then just keep one list of
owners.

Remove the NONBLOCK flag from the eventfd so that we can do blocking
reads as well.

Just keep a reposition owner in the driver activation. This points
to the node that has the reposition info. This avoid complicated
synchronization to keep multiple nodes from stepping on eachother.
Now they can just prepare the reposition info in their activation and
set themselves as the reposition owner. The last one who succeeds
wins.
2019-09-02 12:05:05 +02:00
Wim Taymans
ca34a75173 protocol-native: attempt to remove socket
After we grab the lockfile we should remove the socket when it
exists so that we can bind again. This should solve startup
problems after a crash, which left the socket around and caused
bind failures.
2019-08-30 18:08:00 +02:00
Wim Taymans
7c865f5db0 io: add support for segment
Move fields from the io_position to io_segment. The segment contains
the mapping between raw clock time and stream time in various
formats. We keep an array of pending segments available in the
io_position field so clients can anticipate changes.

Make looping a flag in the segment instead of a state.

Prepare for segment masters. These will be registered clients that
are responsible for updating parts of the extended segment info.

Add namespace to some defines.
2019-08-27 21:36:15 +02:00
Wim Taymans
ae457625d3 client-node: also don't remove our own activation
.. because we don't add it.
2019-08-22 18:14:57 +02:00
Wim Taymans
f86ca63597 client-node: refuse params on the wrong side of our mixers 2019-08-22 18:00:55 +02:00
Wim Taymans
6ad4adc194 node: add xrun callback
Let alsa emit xrun callbacks.
Write the xrun stats to the activation area of the node so all
clients can read it.
2019-08-22 13:25:38 +02:00
Wim Taymans
9351b14bf4 remote-node: avoid map and unmap for our own node 2019-08-21 20:35:28 +02:00
Wim Taymans
d00c641559 protocol: we need to read Fd into int64_t 2019-08-20 10:51:58 +02:00
George Kiagiadakis
f1d60d6009 protocol-native: downgrade getsockopt SO_PEERSEC error to warning
Getting SO_PEERSEC on distributions that do not use a LSM by default,
results always in a "protocol error", which is just annoying and not
a real problem for pipewire's operation.
2019-08-19 16:34:18 +02:00
Wim Taymans
d9050fcb72 connection: use right size 2019-08-16 22:57:24 +02:00
Wim Taymans
8db4a797aa core: remove parent_id from the global event
Remove the parent_id from the global event. Remove the parent
and owner from the global object.

Use properties instead to mark parents and owners of objects.

Properties are easier to control for client exported objects and
usually a simple parent/child is not enough. For example, a client
exported node has the client as a parent but also the factory that
created the node.
2019-08-16 22:11:42 +02:00
Wim Taymans
84ec90da2d proxy: add refcount to keep the proxy alive in demarshal
We need to keep the proxy alive during demarshal because the callbacks
might decide to destroy the proxy.
2019-08-16 15:19:19 +02:00
Wim Taymans
7ad111de47 connection: return INVALID for invalid fds 2019-08-16 15:12:30 +02:00
Wim Taymans
2f28e59c63 protocol: use Fd pod for fd indexes for easier debugging 2019-08-16 15:11:04 +02:00
Wim Taymans
8da7222c7e protocol-native: avoid NULL pointer access 2019-08-16 15:09:16 +02:00
Wim Taymans
aa2e2f192b client-node: dont' send peer_added with our own node
.. because it's just ignored in the client anyway.
2019-08-16 15:08:21 +02:00
Wim Taymans
0af87d2685 client-node: keep port buffers in special location
Keep the output port buffers in a special mix info. They should
stay there even when the mix is removed and should only be cleared
explicitly with a NULL Format or 0 use_buffers.
2019-08-15 11:49:32 +02:00
Wim Taymans
96ba0fbdeb client-node: only clear buffers when format cleared
.. like we don on the client.
2019-08-14 17:07:22 +02:00
Wim Taymans
35f617157f proxy: improve proxy cleanup
When we destroy a proxy, mark it as zombie until the server removes
the id. This way we can still keep the id locked with a valid entry
and remove it later.
2019-08-14 11:52:59 +02:00
Wim Taymans
d86e462dca client-node: clean up buffers and other memory 2019-08-14 11:45:28 +02:00
Wim Taymans
6a8fe43a0c improve debug 2019-08-14 11:44:16 +02:00
Wim Taymans
f6fca48459 client-node: always remove the previous io memory 2019-08-13 18:43:22 +02:00
Wim Taymans
935de18aa5 port: return async result from use_buffers if any 2019-08-12 16:50:10 +02:00