Commit graph

116 commits

Author SHA1 Message Date
Wim Taymans
136fc028a5 prefer S24 over S16 formats
Prefer the higher quality over performance.

Fixes #457
2020-12-06 10:37:40 +01:00
Wim Taymans
79fb95bf90 stream: implement Flush
Flush out pending samples in the resampler
Set the io area status to _OK so that buffers are recycled and
new buffers produced.
2020-11-17 17:15:26 +01:00
Jan Grulich
743cf58fb7 Define SPA_FALLTHROUGH to make fall-through annotations work for all compilers
This is needed for example for Clang compiler which uses different
annotations than GCC. It will make WebRTC to happily use PipeWire
since the spa library is header-only and WebRTC defaults to use
Clang with -Wimplicit-fallthrough.
2020-10-22 13:31:19 +02:00
Wim Taymans
479bf3c803 fmtconvert: fix debug line 2020-09-28 11:47:16 +02:00
Wim Taymans
8825a21e86 fmtconvert: improve channel debug names 2020-09-15 13:22:41 +02:00
Wim Taymans
e59c4675a7 audioconvert: send the command to the children
Send the command on the converter to all children as well.
Reset the resampler when we are paused so that we don't end up
with old data.

Fixes #288
2020-09-14 16:39:42 +02:00
Wim Taymans
320e63fe48 fmtconvert: place unknown channels at end
Sort the unknown channels to the end of the remap array.
2020-09-14 11:03:52 +02:00
Wim Taymans
5f4fd14a40 audioconvert: optimize prefered formats
First planar, then packed, then packed other endian formats.
First F32, S32, S24_32, S16, S24, U8 because of quality and
optimizations.
2020-08-19 13:45:57 +02:00
Wim Taymans
6e03b4005d increase amount of datas in a buffer 2020-07-01 11:43:22 +02:00
Wim Taymans
aafd1e7298 improve debug
Improve log so that debug level 3 gives a reasonably readable overview
of what is going on.
2020-04-22 12:47:18 +02:00
Wim Taymans
b18dacde9a spa: improve draining
Make a new DRAINED status.
Place the DRAINED status on an input IO when a stream is out of
buffers and draining.
All nodes that don't have HAVE_DATA on the input io need to copy
it to the output io and return the status. This makes sure the
DRAINED is forwarded and nodes return DRAINED from _process()
DRAINED on the resampler flushes out the last queued samples and then
forwards the DRAINED in the next iteration.
Emit a new drained signal from the context when a node returns
DRAINED. Use this to trigger the drained signal in the stream.
2020-04-07 17:58:43 +02:00
Wim Taymans
a880012e72 fmtconvert: order formats better
Place float and higher resolution formats first so that they are
selected first.
2020-03-24 11:47:41 +01:00
Wim Taymans
8a2af908a7 small optimizations
Add some SPA_LIKELY
Enable FASTPATH by default
2020-03-18 15:43:29 +01:00
Wim Taymans
d8bac82e72 improve logging
Remove some harmless warnings from the log
Remove some excessive info logging
2020-02-21 11:09:34 +01:00
Wim Taymans
192fee98a4 fmtconvert: suggest 2 buffers by default
When running pw_stream with async process, we need an extra buffer
to compensate for the thread switch.
2020-02-13 09:47:19 +01:00
Wim Taymans
1cce9a69c8 pw-cat: add channel-map option and option to delay connect
If the target node is set to 0, remove the autoconnect flag. This makes
the session manager disable stream autoconnect and some other program
needs to connect the stream to a sink or node.

Use the channelmap from the file, if available.

Add option to specify/override the channel map for playback.
2020-02-04 11:45:45 +01:00
Wim Taymans
c14881fbe2 Respect the rate from the position as the default 2020-01-09 16:43:08 +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
9ffec214b8 fix includes 2019-10-25 15:01:02 +02:00
Wim Taymans
af73585948 Increase max buffer size 2019-10-24 15:26:59 +02:00
Wim Taymans
2fa97daa24 add some constants for max samples 2019-10-24 12:35:00 +02:00
Wim Taymans
2e3608a34f Improve some debug 2019-10-18 21:54:44 +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
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
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
fa792a91a0 fmtconvert: always prefer just 1 buffer 2019-08-13 18:42:40 +02:00
Wim Taymans
f41720e7db Add PortConfig parameter
Add a new PortConfig parameter to configure ports of elements that
are marked with the SPA_NODE_FLAG_*_PORT_CONFIG. This is used to
configure the operation of the audioconver/audioadapter nodes and
how it should convert the internal format. We want to use the
Profile parameter only for cases where there is an enumeration of
values, like with device configuration.

Add unit tests for audioconvert and adapter to check if they handle
PortConfig correctly.

Make the media session use the PortConfig to dynamically configure
the device nodes.

Remove audio-dsp, it is not used anymore and can/should be implemented
with a simple audioconvert spa node now and some PortConfig.
2019-08-06 12:45:20 +02:00
George Kiagiadakis
30576fcff8 audioconvert/fmtconvert: assume F32 on the other port when listing formats
This allows picking F32LE as the default format on links that have
no restriction and it avoids failing negotiation when the restricted
end cannot handle S16/F32/F32P

For instance this pipeline would previously fail:

  audio-dsp mode=merge ! audio-dsp mode=convert ! alsa-sink
old negotiation:     S16LE                   S24_32LE
new negotiation:     F32LE                   S24_32LE

The link between the audio-dsp nodes has no restriction, so previously
it would negotiate S16LE, which would then fail to negotiate with alsa-sink
because fmtconvert does not know how to convert S16LE to S24_32LE directly.

With this change, the middle link negotiates to F32LE, which can be
converted to anything.
2019-07-30 11:11:57 +02:00
Wim Taymans
deb6c52f76 node: remove port_alloc_buffers
Remove the now obsolete port_alloc_buffer, rework to use the
port_use_buffers with the ALLOC flag.
2019-07-25 14:08:43 +02:00
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
453e75a23e improve some debug 2019-07-15 17:09:44 +02:00
Wim Taymans
0726a608df Improve debug and small cleanups 2019-07-02 17:11:45 +02:00
Wim Taymans
6720ded529 names: add standard factory name definitions
Define a set of standard factory names and document what they
contain. This makes it possible to change the implementation by
mapping the factory-name to a different shared library.
2019-06-21 13:31:34 +02: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
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
eb6481efb3 fmtconvert: also return all formats when not negotiated
Also return all possible formats if the other port was not
negotiated.
2019-05-23 10:27:54 +02:00
Wim Taymans
e009fead09 io: remove unused range 2019-05-16 16:42:49 +02:00
Wim Taymans
a70fd80c2d fmtconvert: fix format enumeration
Rework the format enumeration so that it also return the other
rate/channels, even when using a canonical format.
2019-05-10 11:39:51 +02:00
Wim Taymans
1a7fcaf9c6 Fix cleanup 2019-05-10 11:15:48 +02:00
Wim Taymans
41ab051b68 fmtconvert: fix format enumeration
Even if the other pad is already negotiated, we can convert all
formats to F32.
2019-05-09 09:35:03 +02:00
Wim Taymans
2912d2506f audioconvert: improve resampler
Also emit port info the the merger monitor ports.
Proxy params and buffers to the right monitor ports.
fmtconvert does not always have dsp ports
Increase resampler output buffer sizes so that we can up and downsample.
Fix little off by one in native resampler.
Fix passthrough in speex resampler.
2019-04-23 17:34:27 +02:00
Wim Taymans
092a0c660d make bitfields unsigned
Remove driver property from client-node of client-stream.
2019-04-10 17:52:42 +02:00
Wim Taymans
d8e399dee9 audioconvert: pass state to functions
Pass some state to convert and channelmix functions. This makes it
possible to select per channel optimized convert functions but
also makes it possible to implement noise shaping later.
Pass the channelmix matrix and volume in the state.
Handle specialized 2 channel s16 -> f32 conversion
2019-03-29 17:39:59 +01:00
Wim Taymans
5a2ccee1ff Add FASTPATH trace log
Add a trace_fp that can be optimized away when FASTPATH is defined.
2019-03-21 11:31:53 +01:00
Wim Taymans
036ca89c0e audioconvert: mark ports and buffers as DYNAMIC
Only passthrough buffer data when the buffer and ports are
marked as DYNAMIC.
Use extra buffer for nodes that keep a ref on buffers (resample).
2019-03-21 10:45:24 +01:00
Wim Taymans
0505f2dc98 audioconvert: implement passthrough
Add some const and SPA_RESTRICT to methods
When the input and output is the same, work in passthrough mode
where we simply copy place the input pointer onto the output buffer
without doing a memcpy.
Do memcpy when the resampler is not active.
2019-03-20 19:29:14 +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
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