Commit graph

183 commits

Author SHA1 Message Date
Wim Taymans
8590ac158b node: add flags to port_use_buffer
Remove the CAN_USE_BUFFERS flag, it is redundant. We can know this
because of the IO params and buffer params.

Add flags to the port_use_buffer call. We also want this call to
replace port_alloc_buffer. Together with a new result event we can
ask the node to (a)synchronously fill up the buffer data for us. This
is part of a plan to let remote nodes provide buffer data.
2019-07-25 13:19:39 +02:00
Wim Taymans
18776b155b mem: Add tag to memmap
Add a tag field when creating a memmap so that we can do lookup on it.
This makes it easier to implement the tracking of mappings for io areas.
Remove custom io memory tracking and use the tags.

Add flags to spa_chunk to make data corrupted. The flags on the buffer
stay constant for the life of the buffer. Add flags to mark memory
readable and writable. Mark memory readonly in v4l2-source.

Pass the daemon activation area to the client in the transport event.
This never changes and need to be handled differently from the other
activation areas.

Use the right flags when importing memory.

Add the (desired) memory type to mempool_alloc.

improve some debug.
2019-07-25 12:10:05 +02:00
Wim Taymans
bee88e5279 v4l2: handle and recover from control failure
When we fail to construct the labels of a control, reset and
continue without labels.
2019-06-26 07:23:34 -04:00
Wim Taymans
15b6c7ef7e v4l2: warn when control fails 2019-06-26 06:13:25 -04:00
Wim Taymans
857b2a0cfb spa: add result type
We need this to know the type of result, especially when serializing.
2019-05-28 13:59:48 +02:00
Wim Taymans
c44d655516 v4l2: use 32 buffers max
We don't yet probe the number of available buffers and so we might claim
to support 64 buffers but then fail to allocate that many buffers in
_use_buffers().
2019-05-27 15:35:20 +02:00
Wim Taymans
6ee192dff5 hooks: use hook to implement the callbacks
This way we get the version check implemented and save some
code.
2019-05-15 11:19:23 +02:00
Wim Taymans
787900e8bf v4l2: map all jpeg formats to video/mjpeg 2019-04-10 17:10:34 +02:00
Wim Taymans
8daff4ce50 v4l2: make custom properties for unknown ones 2019-03-19 16:19:12 +01:00
Wim Taymans
306f0dd964 v4l2: set result param id 2019-03-14 16:38:36 +01:00
Wim Taymans
7a05a35f8e v4l2: don't error when we finish the enumeration 2019-03-11 20:59:43 +01:00
Wim Taymans
3777d9612e v4l2: only emit port info once 2019-03-06 09:43:24 +01:00
Wim Taymans
0390969228 node: make add_listener method
Make struct spa_node_events for events emited from the main thread
and keep the spa_node_callbacks for the data thread callbacks.

The add_listener method installs the events and it's possible to
install multiple handles. Adding a listener first emits the info
and port_info events when installed, similar to how the PipeWire
proxy bind works.

This removes the need for the spa_pending_queue and makes it easier
to implement the _sync versions.

Add some helpers to make it easier for plugins to emit all the info
to new listeners.

Use the listeners for devices as well.
2019-03-01 12:00:42 +01:00
Wim Taymans
aab2b5594f utils: don't remove pending after first callback
Let the caller remove the pending result when finished.
Use non _sync verions to enum_params in node/port/device.
Set result.id in alsa and v4l2 correctly.
2019-02-25 20:19:33 +01:00
Wim Taymans
d2c18c7b1a Improve async handling
Don't use special callback in node to receive the results. Instead,
use a generic result callback to receive the result. This makes things
a bit more symetric and generic again because then you can choose how
to match the result to the request and you have a generic way to handle
both the sync and async case. We can then also remove the wait method.
This also makes the remote interface and spa interface to objects very
similar.

Make a helper object to receive and dispatch results. Use this in the
helper for enum_params.

Make device use the same result callbacks.
2019-02-25 12:29:57 +01:00
Wim Taymans
98463b689b node: improve pending results
Make a special function for pending results to make it clear that it
is different from normal results. Don't pass result code to result
function, it is not useful because since the callback is called, all
must be fine.

The spa_pending is removed from the list right before the callback
and can thus be freed in the callback. Pass the spa_pending in
the pending callback so that extra data can be added that way.

Reuse spa_pending objects in link and nodes instead of allocating. We
always only have one pending operation and we can cancel any pending
previous operation by removing the pending.
2019-02-21 12:14:25 +01:00
Wim Taymans
7b12212eeb node: improve async handling
Remove the done and error callbacks. The error callback is in an
error message. The done callback is replace with spa_pending.

Make enum_params take a callback and data for the results. This allows
us to push the results one after another to the app and avoids ownership
issues of the passed data. We can then extend this to handle the async
case by doing a _wait call with a spa_pending+callback+data that will
be called when the _enum_params returns and async result.
Add a sync method.

All methods can now return SPA_RESULT_IS_ASYNC return values and you
can use spa_node_wait() to register a callback when they complete
with optional extra parameters. This makes it easier to sync and
handle the reply.

Make helper methods to simulate the sync enum_params behaviour for
sync nodes.

Let the transport generate the sequence number for pw_resource_sync()
and pw_proxy_sync(). That way we don't need to keep track of numbers
ourselves and we can match the reply to the request easily.
2019-02-21 09:40:12 +01:00
Wim Taymans
e9bedae5fa node: add max_ports to node info 2019-02-14 17:40:01 +01:00
Wim Taymans
21957e9e8d node: Add port_info event
Add a port_info event. With this, we get updates to ports pushed to
us, which is more convenient and also allows for better dynamic
add/remove of ports.
We don't need to the PortChanged event anymore
We can remove the get_port_ids/get_n_ports/port_get_info methods.
Update plugins
2019-02-14 17:08:46 +01:00
Wim Taymans
3c78036a97 node: process -> ready
Change the process callback to ready to avoid confusion with the
process method and it also describes better what happened.
2019-02-14 17:04:59 +01:00
Wim Taymans
5de7898808 node: implement activation
Make an eventfd for each node and listen for events when the node
is activated.
Reorganize some graphs links to make it possible to activiate nodes
by signaling the eventfd
Pass the peer node to each remote node and let the remote node
directly activate the peer when needed.
Let each node signal the driver node when finished.
With this we don't need to go through the daemon to schedule the
graph, nodes will simply activate eachother. We only go to the
server when there is a server node to schedule.
Keep stats about the state of each node and the time it was
triggered, running and finished.
2019-02-12 17:42:33 +01:00
Wim Taymans
351fb9ce29 pod: improve parser and builder
Remove the spa_pod_iter helpers
Remove builder/parser vararg recurse option, you have to
manually recurse into structures when needed. This simplifies
things a lot.
Pass spa_pod_frames to builder and parser explicitly, we don't
have to keep an internal stack anymore.
The parser is now almost a mirror image of the builder.
Make the parser safer when iterating over objects, add functions
to check and get pod contents in a safe way.
Make the builder return errno style results on errors
Improve performance of object properties when they are stored and
retrieved in the same order.
Add many more tests for the builder and parser
Add some benchmarks
2019-01-22 17:38:23 +01:00
Wim Taymans
80cfda89c1 pod: improve the vararg pod builder and parser
Automatically parse and build key/value when in objects without having
to prefix the key with ":"
Automatically build control/value when in sequence without the "."
prefix.
Remove the builder with key/pod, taking a reference to the stack built
temporary pods is not allowed in c++. We can use the varargs version
with the same convenient syntax.
Remove the parser "*" option, it is unused.
Improve spa_pod_builder_add_* and spa_pod_parser_get_* and make them
look similar.
2019-01-16 11:05:12 +01:00
Wim Taymans
62672f4d23 v4l2: set buffer id correctly 2019-01-10 10:20:08 +01:00
Wim Taymans
5b7ddb0105 buffer: remove buffer id
The buffer id is not needed/used, we use the index of the buffer in the
buffer array when configuring the port.
2019-01-07 17:57:03 +01:00
Wim Taymans
e918f9f77c fix sign confusion 2019-01-07 15:52:42 +01:00
Wim Taymans
e1bd12e599 device: add device object
Make a device object, let the v4l2 monitor create device objects
The device object is responsible for dynamically creating nodes.
2018-11-23 12:43:47 +01:00
Wim Taymans
088ee9f09e Improve TIMESPEC_TO_TIME
Add explicit TO_NSEC and TO_USEC versions to make it clearer and to
allow for some optimizations.
2018-11-07 09:56:24 +01:00
Wim Taymans
85f2e93c54 Relicense as MIT/X11
Remove some obsolete files
2018-11-05 17:48:52 +01:00
Wim Taymans
9a969ac756 v4l2: we set clock and position on the node now 2018-10-27 10:11:27 +01:00
Wim Taymans
ec88101004 v4l2: move log to instance 2018-10-01 10:55:35 +02:00
Wim Taymans
cc842cbdc8 Type changes
Only allow properties inside objects, this makes it easier to
iterate the object, which is needed for efficiently processing
control streams.
Add a choice type to mark variable properties.
SPA_TYPE_Enum -> SPA_TYPE_Id to avoid confusion with choice enum
Make it easier to allocate and initialize properties on the stack
Make more efficient methods to make objects.
2018-09-05 16:41:07 +02:00
Wim Taymans
ff6a244d8f Make media type and subtype properties
This is easier to debug and we only want properties in objects
in the future.
2018-08-29 18:08:52 +02:00
Wim Taymans
80de83f38a format: make helper function to parse media type 2018-08-29 14:50:58 +02:00
Wim Taymans
90c1a95eef More type cleanups
SPA_ID_* -> SPA_TYPE_*. We use 'type' for all registered types.
ID refers to either a registered type or an enum.
Improve introspection of object ids. Make 0 an invalid enum and
use it to look up the object id type.
Move some type-info files together.
Swap type and id of the object, we first specify the type and then
the id because the meaning of the id depends on the object type.
2018-08-27 15:03:11 +02:00
Wim Taymans
d26aecfef2 More type fixes
Param ids and IO ids are now simple enums.
Move some type info in one place, delete some type-info files
Fix type debug
Make audio layout an enum
Mark more enums as enums in types so they show us with their names in
the debug.
2018-08-25 12:08:29 +02:00
Wim Taymans
805e3bb6c1 types: work on types
Move static pod types to type system
work on type info for types
Move the event and command ids to an enum to make it easier to extend
later.
2018-08-24 10:53:09 +02:00
Wim Taymans
fca3e1d85d Remove dynamic types
Do not use dynamic types anymore. The reason is that it's difficult:

- to maintain a shared type database over a network.
- the extra overhead when translating between processes and for
  maintaining the translation tables.
- race conditions in translating in RT-threads, this is a problem
  because we want to make event streams.

We now have simple enums with types and extension points for all
types. This is also nicer to use in general.
We don't need the mapper anymore or pass strings around as types.
There is a parallel type info system to get more info about ids and
enums and their hierarchy. It can also be used for debugging.
2018-08-23 17:47:57 +02:00
Wim Taymans
b31832dac9 v4l2: set pts correctly
The pts is supposed to be go in sync with the clock. Our clock is based
on sequence numbers so translate the PTS to this as well.
2018-08-15 21:33:58 +02:00
Wim Taymans
26fa9eae39 clock: set rate correctly
The ticks multiplied by the rate should give the time in seconds.
2018-08-15 21:31:59 +02:00
Wim Taymans
d3c203b744 spa: use clock info
Use the port clock io area to get timing info and use this as
the time in the graph when we wake up.
2018-07-17 17:37:55 +02:00
Wim Taymans
c98fbfe0a9 meta: make safer find_meta_data function 2018-07-09 12:04:23 +02:00
Wim Taymans
91a10d7c9e v4l2: Check device node
Check the device node on init.
Only remove the source once
2018-06-18 11:33:06 +02:00
Wim Taymans
e02b3181da audio-session - >media-session
Also implement video in the media session
Small cleanups
Improve exclusive mode
2018-05-14 13:07:01 +02:00
Wim Taymans
33a322b96e graph: new scheduling model
Make explicit links between elements that are used to activate the
next element in the graph.
Make subgraphs a special regular node. Make a link from the
subgraph children to the parent so that the subgraph completes when
all the children completed.
Implement a single process function in plugins
Remove many messages in the client node
2018-04-03 16:29:36 +02:00
Wim Taymans
9b0a880afb simplify things with just 1 process function
Make just one process function in spa node. With the io area states
we can do more complicated io patterns.
2018-04-03 16:29:36 +02:00
Giovanni Campagna
07f12c9713 v4l2: fix enumerating frame interval for continuous/step-wise devices
A device that supports continuous/step-wise frame interval will
report the correct frame intervals for index 0 and EINVAL for
every other index.
(https://linuxtv.org/downloads/v4l-dvb-apis/uapi/v4l/vidioc-enum-frameintervals.html)

Previously, the code would exit from the loop after successfully
reading index 0, without marking that the iteration of frame
interval completed. Therefore, the next time the function was
called the same frame intervals would be read, instead of advancing
to the next frame size or format type.
Instead, mark that we need to try and read the next format size.

Fixes #56
2018-04-03 16:28:23 +02:00
Philipp Zabel
e38cba4e13 v4l2: check device caps
If V4L2_CAP_DEVICE_CAPS is set, device_caps must be checked for the
V4L2_CAP_VIDEO_CAPTURE flag instead of capabilities.
2018-04-03 16:27:43 +02:00
Wim Taymans
7ffaaf66a7 v4l2: remove source on errors 2018-02-15 10:47:43 +01:00
Wim Taymans
f37f8ce70d v4l2: keep separate field for mapped fd
When mapping an input memfd, don't write the mapped pointer into the
buffer but keep a separate field for it.
2018-02-12 11:35:49 +01:00