Commit graph

209 commits

Author SHA1 Message Date
Pauli Virtanen
e784de3933 spa: use log topics everywhere
Use log topics properly everywhere, convert from "#define NAME".
2024-03-11 18:45:21 +02:00
Wim Taymans
6e8625cf96 node: update the duration/rate from the target
Before scheduling the graph from the driver, update the duration and
rate with the new targets.
2023-03-23 18:39:27 +01:00
Barnabás Pőcze
934ab3036e treewide: use SPDX tags to specify copyright information
SPDX tags make the licensing information easy to understand and clear,
and they are machine parseable.

See https://spdx.dev for more information.
2023-02-16 10:54:48 +00:00
Wim Taymans
97aafe2234 fix use_buffers checks
We can set 0 buffers even if there is no format.
Return -ENOSPC when too many buffers are set.
2023-01-10 12:30:25 +01:00
Wim Taymans
f44d55f6c2 handle read from timerfd correctly
When reading the timerfd gives an error, we should return right away
because the timeout did not happen.

If we change the timerfd timeout before reading it, we can get -EAGAIN.
Don't log an error in that case but wait for the new timeout.
2022-12-09 17:30:31 +01:00
Wim Taymans
74447acedb Add some more format checks
The format parse functions don't really check if the parsed values
make any sense so we need to to this ourselves.
2022-11-03 13:10:32 +01:00
Wim Taymans
7b432aec88 spa: make default samplerate 48000
Remove some 44100 default rates and use 48000 instead.
2022-09-05 12:21:20 +02:00
Wim Taymans
2fa1b4384b spa: don't warn for NULL io
The io is set to NULL when the port becomes unnegotiated.
2022-09-01 15:31:14 +02:00
Wim Taymans
9071678643 spa: set port flags on port info 2022-05-26 10:39:31 +02:00
Wim Taymans
2f5bba112f spa: Improve PropInfo fields
The PropInfo either has a registered id (and then also a name from the
type-info) or a custom name as a string.
In all cases, the description contains a free form text that clarifies
the property.

Use the description in the stream controls name.
2022-03-30 17:09:08 +02:00
Barnabás Pőcze
60b9d9081b spa: only remove embedded source from data loop from within the loop
Use `spa_loop_invoke()` to invoke a callback on the data loop
to remove an embedded `spa_source` from the data loop.

Embedded `spa_source` objects cannot be safely removed
while the loop is polling without risking potential
use-after-frees.
2022-03-06 18:40:43 +00:00
Wim Taymans
776b52749f Use configured quantum_limit instead of hardcoded value
Parse the quantum_limit parameters and use this to scale the buffers so
that they can contain the maximum allowed samples instead of the
hardcoded 8192 value.

See #1931
2022-01-12 17:50:12 +01:00
Wim Taymans
35cbe4e939 buffers: make alignment optional
Make the alignment parameter optional when negotiating buffers.
Default to a 16 bytes alignment and adjust for the max cpu
alignment.
Remove the useless align buffer parameter in plugins, we always
set it to 16 anyway.
2022-01-03 12:32:26 +01:00
Konstantin Kharlamov
dea1a0bee2 audiotestsrc: convert sizes to const size_t
`sizes` members participate in multiplication and subsequent assignment
into port->bpf, which has size_t. So LGTM rightfully complains, there's
a chance the multiplication will overflow before the assignment happens.

Should have no influence on performance since 64 bit multiplication is
as fast, and since the struct is constified, a wise compiler should make
sure it doesn't take excess space either.

Fixes LGTM warning:

    Multiplication result may overflow 'unsigned int' before it is converted to 'size_t'.
2021-07-05 23:30:45 +03:00
George Kiagiadakis
36c7e820d8 test nodes: make the timerfd non-blocking
Relates to #1377
2021-07-01 11:52:35 +03:00
Wim Taymans
46ef88e520 spa: save the old change_mask and restore when emitting full
When we add a new listener to an object, it will emit the full state
of the object. For this it temporarily sets the change_mask to all
changes. Restore the previous state after this or else we might not
emit the right change_mask for the next listener.

Consider the case where one there are two listeners on an object.
The object emits a change and the first listener wants to enumerate the
changed params. For this is adds a new listener and then triggers the
enumeration. If we set the change_mask to 0 after adding the listener,
the second listener would get a 0 change_mask and fail to update
its state.
2021-05-27 15:21:44 +02:00
Peter Hutterer
7697ed0757 treewide: replace strcmp() == 0 with spa_streq()
This change is only done in source files for now, header files will be done
separately.
2021-05-18 22:10:27 +10:00
Peter Hutterer
2405f0942b spa/buffer: rename SPA_MEMBER to SPA_PTROFF
SPA_MEMBER is misleading, all we're doing here is pointer+offset and a
type-casting the result. Rename to SPA_PTROFF which is more expressive (and
has the same number of characters so we don't need to re-indent).
2021-05-06 09:39:39 +00:00
Wim Taymans
8d5571fa4c audiotestsrc: fix function signature 2020-05-12 17:23:35 +02:00
Pantelis Antoniou
4db9a1e96d audiotestsrc: Make audiotestsrc work
This small patch makes audiotestsrc work.

You will need to uncomment the following lines in pipewire.conf

	add-spa-lib audiotestsrc audiotestsrc/libspa-audiotestsrc
	create-object adapter node.name=my-test factory.name=audiotestsrc

If you use pw-record, use --list-targets to find the target id and
record using --target=<n>

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
2020-03-05 18:41:53 +01:00
Wim Taymans
8096984b7e testsrc: remove checks in suspend and pause
We don't need to have a format or buffers to be able to pause.
2020-03-03 13:17:28 +01:00
Wim Taymans
90968bbb40 testsrc: implement suspend 2020-02-21 16:24:41 +01:00
Wim Taymans
50ce87df32 node: we are supposed to produce data when != HAVE_DATA
We can produce data whenever the io area status != HAVE_DATA. We
don't need to look for NEED_DATA.
Also recycling buffer happens whenever the status != HAVE_DATA.
2020-02-04 12:59:16 +01:00
Wim Taymans
f9d6a42f63 audiotestsrc: set stride correctly 2020-02-04 12:41:43 +01:00
Wim Taymans
f391353c7f Make interface types a string
This is more in line with wayland and it allows us to create new
interfaces in modules without having to add anything to the type
enum. It also removes some lookups to map type_id to readable
name in debug.
2019-12-19 13:36:04 +01:00
Wim Taymans
8d512822cf fix the build 2019-10-25 15:54:42 +02:00
Wim Taymans
af73585948 Increase max buffer size 2019-10-24 15:26:59 +02:00
Wim Taymans
c8ffcaaefe plugins: just check the data pointer
We don't need to look at the data type, we just just be happy when
the data pointer is filled in.
2019-10-16 12:23:42 +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
29d73e3437 fix compilation 2019-08-01 15:28:54 +02:00
Wim Taymans
db88e9f954 System: More work on making system functions pluggable
Move the epoll functions to the system functions and make the loop
use those. Use simple mask for events instead of enum.
Add the used system api in pw_loop.
Add System API to spa_support and use it where possible.
Pass the system API used in the realtime loops in spa_support as
well and use this in the realtime paths.
Improve bootstrapping, load only the log and cpu interfaces because
those can/need to be shared between instances. Let the core load
the other interfaces.
Add keys to configure the System and Loop implementations used in
pw_loop.
2019-06-06 15:31:53 +02:00
Wim Taymans
49ef8f9b5f spa: add keys for properties
Define and document property keys
2019-06-03 16:48:01 +02:00
Wim Taymans
1f250046a3 plugins: fix compilation of optional plugins 2019-06-03 16:08:42 +02:00
Wim Taymans
ff946e3d4b interface: add an interface struct
The interface struct has the type,version and methods of the
interface.
Make spa interfaces extend from spa_interface and make a
separate structure for the methods.
Pass a generic void* as the first argument of methods, like
we don in PipeWire.
Bundle the methods + implementation in a versioned inteface
and use that to invoke methods. This way we can do version
checks on the methods.
Make resource and proxy interfaces that we can can call. We
can then make the core interfaces independent on proxy/resource and
hide them in the lower layers.
Add add_listener method to methods of core interfaces, just
like SPA.
2019-05-23 12:59:24 +02:00
Wim Taymans
a564d9f3f1 Move implementation helpers to utils 2019-05-20 10:14:00 +02:00
Wim Taymans
e009fead09 io: remove unused range 2019-05-16 16:42:49 +02:00
Wim Taymans
448c1937ad hook: separate spa_callbacks from the hook
Make a spa_callbacks with just the functions and data and use this
in the hook and objects.
2019-05-15 12:17:52 +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
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
499dd3ff22 node: add port and node params
Add a new struct spa_param_info that lists the available params on
a node/port and if they are readable/writable/updated. We can use
this to replace and improve the PARAM_List and also to notify
property change and updates.

Update elements and code to deal with this new param stuff. Add
port and node info to most elements and signal changes.

Use async enum_params in -inspect and use the param info to know
which ones to enumerate.

Use the port info to know what parameters to update in the
remote-node.
2019-02-27 16:43:01 +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
b743518f78 node: add props to add_port 2019-02-18 13:22:46 +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
7a1bd163f7 node: remove port_send_command
We don't want to do this, we use a sequence to change things
at runtime.
2019-02-13 12:43:15 +01:00
Wim Taymans
04f1046113 node: pass struct to info callback to make it more extensible 2019-02-13 11:44:58 +01:00
Wim Taymans
f45e0b8966 reorganize some struct members to remove holes 2019-02-08 12:01:50 +01:00