The inactive controls are stored, but they are not restored
when they are marked inactive in the state file or in the
driver.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Make the comment node a separate node in the state file (join=0), and
move it after the other fields of the respective control.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
When the range of a control has changed between driver versions, it is a
good idea to restore the same dB value of the control. However,
computing the dB value by interpolating betweem the min/max dB values
duplicates alsa-lib's TLV functions and does not even work for controls
with a linear dB range.
A simple conversion to dB and back can be done if we add the dB value(s)
to the saved state.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Reserving new space from the stack in every loop iteration is not
necessary, so move the call to snd_ctl_elem_id_alloca outside where it
is executed only once.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
To save a call to snd_config_set_xxx, replace the calls to
snd_config_make_xxx with snd_config_imake_xxx.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Also, make the initialization & restore logic for one card similar to
multiple card initialization & restore.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Fix check when driver contains more controls than state file. In this case,
initialization procedure should be run, too.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This way the compiler can assume more information about their
interface for optimisation.
Signed-off-by: Diego E. 'Flameeyes' Pettenò <flameeyes@gmail.com>
The initialization procedure consist from default initialization and
state restoration. When restore fails for a reason or the config file
contains inaccurate information, then init is called.
Also, if something fails (init or restore), a file specified using -r
option can be created with description what failed. It can be useful
when user space decides to notify user to set the sound driver properly.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Use snd_ctl_elem_type_name() to detect the value of the type comment
instead of using hardcoded strings.
The types list now also includes the BYTES type (Debian bug 481515).
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
When using alsactl to save or restore the card settings, it currently
skips over controls that don't have the appropriate read/write
permissions. It should also skip over inactive controls, otherwise it
will get an error when it tries to access that control, and will fail to
save the card state (or fully restore it.)
From: Dave Dillow <dave@thedillows.org>
When alsactl saved state has dB level information and an attribute
of a control element is changed after save (e.g. volume range is
changed), try to restore the values to keep the same dB level.
This change requires the new alsa-lib functions for TLV dB
conversion, so we check it in configure (until AM_PATH_ALSA(1.0.16)
works).
Make "alsactl restore" a bit more robust. Now it tries to parse the
compound items in the case that the number of channels was changed.
The former mono-value is expanded to all channels.