Commit graph

62 commits

Author SHA1 Message Date
Wim Taymans
a532c2abdb acp: add support for hiding profiles and ports
api.acp.hidden-ports and api.acp.hidden-profiles can be used to pass
a json array of ports and profiles to hide. They will not show and
will not be selectable.
2023-11-30 17:40:48 +01:00
Wim Taymans
7a0b400c18 spa: use dynamic builder where we can
With the spa_auto support this becomes feasable and avoids problems when
the pod size is unknown and ends up larger than our stack buffer.
2023-10-11 18:04:17 +02: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
6207d98ff1 spa: add debug log context
Make a real debug context with a log function and move it to a new file.
This way we don't need to redefine a macro.
Make a new context for debugging to a log file. Make new functions to
debug to a log file.
Move the stringbuffer to string utils.
Integrate file/line/func and topics into the debug log.
We can remove some more things from the pipewire log_object function and
also add support for topics.
2023-01-18 17:51:16 +01:00
Wim Taymans
3c67821c4a spa: add context to debug functions
Add new spa_debugc_ funnctions that take a context. The user should also
redefine the spa_debugc macro to handle the context.

Use this to let some plugins log the pod and format to the log without
using the global logger.

Also use this to remove our custom pod logger function by reusing the
spa one with a custom context.
2023-01-18 13:12:16 +01:00
Wim Taymans
f472fd736d fix includes
Only include debug we need. We usually only need the debug types.
2023-01-18 13:12:16 +01:00
Wim Taymans
d22feab92a spa: add macro to simplify array iterations some more
uint32_t i;
	for (i = 0; i < SPA_N_ELEMENTS(some_array); i++)
		.. stuff with some_array[i].foo ...

   becomes:

	SPA_FOR_EACH_ELEMENT_VAR(some_array, p)
		.. stuff with p->foo ..
2022-09-30 16:24:26 +02:00
Wim Taymans
dfdd9a6b3b alsa: don't prefix NAME, log topics are enough 2021-10-03 08:05:40 +02:00
Peter Hutterer
e9d869b46f spa: implement a log topic for alsa 2021-09-28 09:35:39 +02:00
Wim Taymans
80628f38e7 alsa: move codec config to acp-device
Just like the latency, move the codecs to the device Route param.
This way, it is easier for the session manager to save and restore
the codecs as part of the Route settings.
2021-09-02 10:27:59 +02:00
Wim Taymans
c39d374ca8 alsa: hook up latencyOffsetNsec in ALSA sink/source
This property is exposed on the device Route and forwarded to the
nodes. It then configured the process_latency.ns field, which
influences the reported port latency.

This makes it possible to change the internal port latency on the
sink and source with pavucontrol and tweak the synchronization to
compensate for internal latencies in the device.
2021-08-17 11:57:12 +02:00
Wim Taymans
d88e8edd11 avoid shadowing arguments 2021-07-06 17:55:16 +02:00
Barnabás Pőcze
f5d51162c4 treewide: mark things static and const
Mark some structures, arrays static/const at various places.
In some cases this prevents unnecessary initialization
when a function is entered.

All in all, the text segments across all shared
libraries are reduced by about 2 KiB. However,
the total size increases by about 2 KiB as well.
2021-06-30 14:44:08 +02:00
Wim Taymans
4c64afc4ff acp: add hw-mute and hw-volume as properties 2021-06-09 09:41:49 +02:00
Wim Taymans
35e81fbfdc alsa: rework UCM open
Use _alibpref to check if a device needs a UCM local config. Mark
the device as such and use this to set the OPEN_UCM property on
the device.
Open the UCM for a card when the device has the property set. Use the
same logic for loading the UCM as the acp code.

See #1251
2021-06-02 17:25:21 +02: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
4dd886188a alsa: fix scan-build errors for unused variables
All cases of value stored but never read
2021-05-26 07:51:27 +00:00
Peter Hutterer
71c6a175c4 Drop double semicolons 2021-05-20 07:24:22 +00:00
Peter Hutterer
cdfd50e166 spa: add spa_atob() to convert a string to a boolean
This replaces the manual check for "true" and some (inconsistent) return value
of atoi. All those instances now require either "true" or "1" to parse as
true, any other value (including NULL) is boolean false.
2021-05-18 22:18:56 +10: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
Wim Taymans
3af6e248da acp: emit softMute values, not monitorMute
We don't want to influence the monitor mute, just the
real mute and softMute.
2021-04-29 17:18:25 +02:00
Wim Taymans
5bf2144438 spa: improve volume handling
Make a new softVolume property that contains only the soft volume
to apply.

In the case of HW/SW volume, we pass the real volume in the
channelVolume and the leftover volume in softVolume. We don't
use the monitorVolume for this anymore because it is a completely
separate volume handled by the merger node.

This way, channelVolume always represents the effective volume
set on routes, channelmix and merger and only the softVolume (when
available) is applied as software volume by channelmix.

This makes things map a bit better to what is actually happening with
the real volume and leftover software volumes after applying the
hardware volumes in the device.

With this change, the volume on the monitor is not affected by the
sink volume anymore and we can use the monitorVolume for this later.

This also means that the monitor volume in pavucontrol of the sinks
does not change when the sink volume changes. PulseAudio is inconsistent
here: If the volume is HW, the monitor volume is not affected, if the
volume is SW, it is. In PipeWire there is an option in merger to
let the volume affect the monitor with monitor.channel-volumes = true.
2021-04-29 12:46:29 +02:00
Wim Taymans
3babedec9c acp: get i18n interface from support and use it
Save the i18n interface in a global variable. Make acp use the support
interface when translating strings.
2021-04-14 18:03:46 +02:00
Wim Taymans
fc44013d17 device: place the number of routes in the nodes
So that we can know if this node has routes or not.
Nodes without routes might need their volumes restored directly
with the node properties, like streams. Nodes with a route need their
volumes set on the device managing the node.
2021-03-22 16:43:54 +01:00
Wim Taymans
5cddd61c6c acp: remove the soft volume/mute events
Remove the soft mute/volume events, add a new method to get the soft
volume and use the volume_changed event to emit the changed soft and
monitor (real) volumes event for the node.

Make sure the monitor ports always uses the monitor volume, which is the
real volume unaffected by the mixer volumes.

This configures the soft and real volume on the sink/source in all
cases and makes the monitor port follow the real volume of the sink.

See #897
2021-03-21 16:19:57 +01:00
Wim Taymans
9e09461113 alsa: gracefully handle NULL params 2021-02-23 18:20:37 +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
2b44f42845 pass the complete buffer size to snprintf
There is no reason to pass size-1, snprintf will always put a \0
at the end.
2021-02-02 12:09:29 +01:00
Wim Taymans
ab5059cd07 alsa: add array of devices in EnumProfile
So that we can enumerate the possible Routes per device for
this profile as well.
2021-01-29 15:27:25 +01:00
Wim Taymans
fbb5dad6d1 alsa: bundle param changes
Only poll events and set_param can cause a param changed events.
Keep track of all the changes in the param user data and at the
end of the poll/set_param emit one notification for all changed
params.
2021-01-25 17:06:54 +01:00
Wim Taymans
1ca3998b41 alsa: remove unused field 2021-01-07 17:27:36 +01:00
Arnaud Ferraris
0d6ba3a032 alsa-acp-device: make sure EnumRoute is updated on profile change
When using UCM profiles, ports can have different priorities between 
profiles, meaning EnumRoute should be updated too.
2021-01-05 14:34:43 +00:00
Wim Taymans
c84646b66f acp: add channel to string function
Add a function to convert the channel to a string and use that
instead of the unsafe one.

Fixes #519
2020-12-28 13:27:34 +01:00
Wim Taymans
a8937413e6 acp: add options to disable profile and port switching
See #498
2020-12-22 13:08:14 +01:00
Wim Taymans
a25f1a6a1d acp: pass channelmap around
so that we can use it as a default in channelmix
2020-12-18 17:18:53 +01:00
Wim Taymans
c3973fd9ec pod: add a HINT_DICT flag
We can use this to mark the ROUTE_info property and hopefully improve
the debugging output later.
2020-12-18 16:40:35 +01:00
Wim Taymans
9fb1b02352 acp: when we have a device with no port, go to the next device
Fixes an issue where a device have no ports and then it would
stop enumerating the ports of the other devices.
2020-12-18 16:28:56 +01:00
Wim Taymans
67d10ad3c7 alsa-acp: collect channelmap from volume update
It's not used yet but would ideally need to be used to remap the
volumes.
2020-12-18 16:22:00 +01:00
Wim Taymans
b05dcacc99 alsa-acp: add channel map with soft volume 2020-12-18 16:21:18 +01:00
Wim Taymans
abaf63dfe6 acp: put channelmap in properties 2020-11-23 15:31:51 +01:00
Wim Taymans
42dd52c7fe acp: clean up card object
Fixes #369
2020-11-09 15:01:07 +01:00
George Kiagiadakis
5c749cf7c3 alsa-acp: bind the acp log func to the spa_log object directly
When the acp-device impl struct is passed to the log func, it is
possible that when this device is removed, another device using acp
is going to crash while logging a message
2020-11-02 08:10:29 +00:00
Wim Taymans
38276d126c acp: improve debug 2020-10-01 13:23:16 +02:00
Wim Taymans
62b882c13d acp: improve debug 2020-10-01 11:32:28 +02:00
Wim Taymans
08438903e5 acp: reset soft volume
When we have accurate enough hardware volume, set the software volume to
1.0. Also fixes the issue of going to 0 volume and then staying silent
until we raise the volume above 1.0.
2020-09-28 12:40:16 +02:00
Wim Taymans
d456893f31 acp-device: just always select the best port/profile for now 2020-09-09 14:12:00 +02:00
Wim Taymans
4a35fcaf09 acp: update Route and Profile param on availability change 2020-09-09 14:10:17 +02:00
Wim Taymans
a956c265a2 acp: also act on new available ports 2020-09-08 16:49:07 +02:00
Wim Taymans
5e368b1ad6 acp: add option to switch profile and ports
Enable an option to switch to the next best profile and port when
the current one becomes unavailable.
2020-09-08 16:39:47 +02:00
Wim Taymans
185a3d4c36 alsa: update route param when profile changed
When the profile changes, also update the route param.
Use defines to index the parameters
2020-09-07 14:32:56 +02:00