Commit graph

243 commits

Author SHA1 Message Date
Takashi Iwai
7d6673cc13 alsactl: Manage both save and restore in a single unit
With RemainAfterExit=true, we can manage both save and restore of the
card state in a single unit file.  This will fix also the case where
systemd reloads the service; with two individual units, it will
restore the previous state before saving, and may lead to inconsistent
state suddenly.

Also fix alsa-state.service as well to make both start and stop
working in a simpler way.

Bugzilla: https://bugzilla.novell.com/show_bug.cgi?id=929619
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-29 17:54:17 +02:00
Takashi Iwai
0e864e1a3a alsactl: Add path condition to alsa-store and alsa-restore services
With alsa-restore.service and alsa-store.service, systemd invokes
alsactl at boot and shutdown times.  When this is invoked on a system
without sound cards, it results in an ugly error message from alsact

  /usr/sbin/alsactl: save_state:1590: No soundcards found...
  return code is "19"

Add ConditionPathExistsGlob checks of /dev/snd/control* devices for
avoiding unnecessary invocations of alsactl on such a system.

Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=940950
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-08-10 14:42:24 +02:00
Tobias Stoeckmann
13c8269414 alsactl: terminate readlink result string
readlink does not guarantee that its result string is nul-terminated.
Instead, increase the buffer by one byte to make sure that we can
add '\0' at the end.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-07-13 16:37:28 +02:00
David Henningsson
e1745a69fe alsactl/init: Add "Line Out" to list of outputs to initialize
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-12 17:01:06 +01:00
David Henningsson
d522b45508 alsactl/init: Change the "basic rules" description
We now enable more outputs than just the main speaker, so update
the basic rules to reflect the actual situation.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-12 17:00:56 +01:00
Jaroslav Kysela
55d41b7fe3 alsactl: add missing state_unlock() call 2014-12-24 20:15:26 +01:00
Jaroslav Kysela
89a4f490bd alsactl: coverity - missing_va_end – va_end was not called for "ap" 2014-09-24 10:52:17 +02:00
Jaroslav Kysela
17d4a5dd35 monitor: fix clang warning - Declared variable-length array (VLA) has zero size 2014-09-24 10:50:54 +02:00
Jaroslav Kysela
74e5d57c99 alsactl: aded missing monitor() prototype 2014-09-24 10:46:02 +02:00
Jaroslav Kysela
1363f852e9 alsactl: Fix the file locking routines (for the state management) 2014-09-24 10:35:53 +02:00
Jaroslav Kysela
03a652e18d alsactl: save state - do not call rename for stdio
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2014-06-25 10:54:26 +02:00
David Henningsson
3a7c1c59ec alsactl: Fixup test for mydatadir/sbindir
Use the "mydatadir" name consistently.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2014-06-13 11:54:45 +02:00
David Henningsson
be4565c841 alsactl: Do not run udev rule before datadir/sbindir are both mounted
Sometimes 90-alsa-restore.rules is run before /usr is mounted,
and alsactl restore depends on /usr/share/alsa being present.

If /usr/share/alsa is not present, we're so early in the boot
process that alsa-restore.service (or upstart equivalent) will
run later on.

BugLink: https://bugs.launchpad.net/bugs/1289730
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2014-06-13 11:10:03 +02:00
Jaroslav Kysela
158a67f6f5 alsactl: add -L (no-lock) and change -D (lock-dir) to -O (state-lock-file)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2014-05-07 11:20:16 +02:00
Jaroslav Kysela
24a7b2fec2 configure: add --with-lock-dir option
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2014-05-07 10:55:58 +02:00
Julian Scheel
2607d8deee alsactl: Store lockfile in /var/lock, add -D option to specify the lock dir
It can not be generally assumed that the directories in which asound.state
resides are writable. Use /var/lock and allow users to alter this path.

Signed-off-by: Julian Scheel <julian@jusst.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2014-05-07 10:55:51 +02:00
Dave Reisner
ef0e588c76 alsa-restore.rules: refer to correct attr
$attr{number} in the RUN rule is an empty expansion. This makes sense,
because the path doesn't exist -- i.e., it refers to the path:

/sys/devices/pci0000:00/foo/bar/sound/card0/controlC0/number

Instead, refer to $attr{device/number}, which does exist.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-01-13 11:30:43 +01:00
Jaroslav Kysela
f4be3f88b6 alsactl: Fix the va_list initialization in cerror_() and dbg_()
The <ap> argument for syslog_() was uninitialized.

From: Alan Hamilton <alanh@arizonaroads.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-12-29 20:06:53 +01:00
Takashi Iwai
5dfc232a9d alsactl: monitor all cards as default
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-11-26 14:27:30 +01:00
Takashi Iwai
bb3293c76e alsactl: Fix REMOVE event handling in monitor command
SND_CTL_EVENT_MASK_REMOVE has to be checked at first and ignore the
rest if it matches.  Suggested by Clemens.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-11-26 13:59:19 +01:00
Takashi Iwai
d2d9b6fc8d alsactl: Add monitor command
With monitor command, you can monitor the events received from the
given control device.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-11-26 11:45:34 +01:00
Jaroslav Kysela
dda4392cd5 alsactl: alsa-state.service - fix typo (rkill -> kill)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-07-19 14:36:52 +02:00
Jaroslav Kysela
c0f70a0b8e alsactl: return back the udevrules_DATA rule for 90-alsa-restore.rules
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-05-27 09:26:39 +02:00
Gabriel M. Beddingfield
121df36949 alsactl init: ca0106 file was omitted
The file alsactl/init/00main includes the line:

CARDINFO{driver}=="CA0106", INCLUDE="ca0106", GOTO="init_end"

However, the file alsactl/init/ca0106 is not making it into the
release tarballs (nor to user installations).

This patch adds the ca0106 file to the build.

Signed-off-by: Gabriel M. Beddingfield <gabrbedd@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-05-27 09:09:14 +02:00
Jaroslav Kysela
4485590096 alsactl: remove 90-alsa-restore.rules from the tar ball
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-05-21 10:27:25 +02:00
Jordi Mallach
f2f5f7a7d3 Fix a build failure due to a misused format string.
This fixes builds with -Werror=format-security.

Signed-off-by: Jordi Mallach <jordi@debian.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-05-16 10:38:25 +02:00
Doug Goldstein
888275e66c alsactl: sprintf to snprintf prevent buffer overflow
sprintf() is a bit dangerous unless you explicitly know your type size
and want to keep it in sync always. Its safer to just use snprintf() and
ensure your string doesn't overflow and is NULL terminated.

Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-05-06 10:55:07 +02:00
Jaroslav Kysela
95788fea25 alsactl: Fix the string size for the lock file contents
The string length is 10 characters + LF + '\0' = 12 characters.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-15 14:44:13 +02:00
Takashi Iwai
3616b1fe3c alsactl: Fix a typo in systemd alsa-restore.service
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-04-15 11:21:13 +02:00
Jaroslav Kysela
c3a31afe14 alsactl: add --with-alsactl-daemonswitch=FILE to the global configure.in
It may be useful to have the file location configurable.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-10 11:08:47 +02:00
Jaroslav Kysela
8b34bf25c0 alsactl: revert back old systemd static units with the /etc/alsa/state-daemon.conf switch
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-10 10:29:19 +02:00
Jaroslav Kysela
611249ae26 alsactl: add --nice and --sched-idle options
The state management can run at low priority, add --nice and --sched-idle
options to set the scheduler.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-10 09:42:40 +02:00
Jaroslav Kysela
9cb5e5bee7 alsactl: daemon mode - remove disconnected cards
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-09 18:10:22 +02:00
Jaroslav Kysela
e05b903b1f alsactl: move systemd config to the daemon mode
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-08 14:51:39 +02:00
Jaroslav Kysela
ffaff06849 alsactl: add event filter and cache for the daemon mode
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-08 11:31:45 +02:00
Jaroslav Kysela
067f4f3256 alsactl: Improved command line argument handling...
Improve command line argument handling for future extensions.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-05 13:47:21 +02:00
Jaroslav Kysela
cc5c3357cf alsactl: add the daemon mode
For the plug-and-play hardware, like USB devices, it may be helpful
to manage the sound state periodically, before the devices are removed.

This change implements new commands 'daemon' and 'rdaemon' to save
the sound state in defined intervals when the sound controls are changed.

The udev rules can notify the daemon using the 'kill' or 'nrestore'
commands to rescan available cards in the system.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-05 13:47:18 +02:00
Jaroslav Kysela
b95dd7ef46 alsactl: small code reorder to avoid memory leaks
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-03 11:57:52 +02:00
Jaroslav Kysela
e3e85a851c alsactl: safe state store and memory allocation cleanups
- store new configuration to file + ".new" extension, rename later
- free the configuration tree on exit from load_state()/save_state()
- call snd_config_update_free_global() at the end of command blocks

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-03 11:16:46 +02:00
Takashi Iwai
c3111571dc alsactl: Add reference to alsactl_init(7) in alsactl man page
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-06-14 16:14:29 +02:00
Takashi Iwai
c68a3d02d1 alsactl: Read only *.conf files when a directory is passed via INCLUDE
When alsactl init is invoked and a directory path is passed to INCLUDE
command in the config file, read only *.conf files in that directory.
This will avoid reading backup files or invalid files that have been
created accidentally.

Also by using scandir() with alphasort(), alsactl reads the files in
alphabetical order.  Thus it's highly recommended to use some number
prefix to the file name for assuring the order.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-06-14 16:06:42 +02:00
Jaroslav Kysela
f7eb87ddc7 alsactl: Do not access other cards than specified for init
When the global state does not exist, alsactl tries to
initialize all soundcards. It is not good when alsactl
is called multiple times from udev. Also, selinux can deny
access to non-existent devices.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2012-05-09 08:45:47 +02:00
David Henningsson
7d33af86c8 Alsa-utils: Fix typo causing some volumes not to be initialized
When I was reading the source code, I stumbled over this typo causing
Center, LFE, and Surround speakers not to be initialized.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-01-13 10:03:07 +01:00
Takashi Iwai
9fa7cd2176 alsactl: Initialize Front Speaker, etc
Add missing initialization of surround and CLFE playback volumes and
switches.  Ditto for "Front Speaker", etc.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-04 17:01:57 +01:00
Clemens Ladisch
5a6ca47cb9 alsactl: add support for recreating enumerated user controls
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2011-10-07 23:40:08 +02:00
Michał Górny
e80b015689 fix use of $(SED)
The alsactl Makefile used 'sed $(SED)' which is going to failed when SED
is actually set. Replaced that with '$(SED)', and a few 'sed' calls in
alsaconf Makefile as well. Added AC_PROG_SED to configure to have it
set.

Fixes: https://bugtrack.alsa-project.org/alsa-bug/view.php?id=5363
Fixes: http://bugs.gentoo.org/show_bug.cgi?id=366587
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2011-08-31 22:31:55 +02:00
Jaroslav Kysela
5ee6a67075 Revert "alsactl - Display help for names command"
This reverts commit 6d32e055d7.

From: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2011-04-28 08:13:54 +02:00
David Henningsson
70451054e0 alsactl init: Mute CD Playback volume by default
The CD analog playback line is seldom used these days, as all
modern players rip the CD and use the DAC on the sound card.
In addition, it causes background hum on some machines.
Therefore keep it muted by default.

BugLink: http://bugs.launchpad.net/bugs/747184
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-04-04 12:48:21 +02:00
Colin Guthrie
a97bcd19dc alsactl: Add a --with-udev-rules-dir configure option.
After the previous patch to install udev rules it is impossible to do a
non-root, custom-prefix make install. This is generally not a problem
when building official packages but it can be a pain for developers
and debuggers etc.

This is essentially the same patch as was already made in PulseAudio
in commit e8a5746f2fcae59bfd18d39b621509b3ef130453.

Signed-off-by: Colin Guthrie <gmane@colin.guthr.ie>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-11-26 10:27:14 +01:00
Lennart Poettering
81f015f5ab alsactl: Move asound.state location to /var/lib/alsa
.... and add configure switch for it.

/etc might be on a read-only partition which is not suitable for dynamic
data such as the mixer settings. Hence move the location of asound.state
to /var/lib.

This is based on a patch from Ubuntu/Debian which hardcoded the pah in
/var/lib.

Signed-off-by: Lennart Poettering <mznyfn@0pointer.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-11-23 15:48:50 +01:00