Commit graph

117 commits

Author SHA1 Message Date
Timo Teräs
ae035b7fe5 conf.c: use portable way to initialize recursive mutex
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP is not in POSIX, as _NP
(non-portable) suggests.

exposing such a symbol in musl libc would lock in the ABI for all
times and makes it impossible to do future changes to the under-
lying struct without hideous symbol versioning hacks.

use the portable way instead: pthread_once was designed for such
cases.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Tested-by: John Spencer <maillist-alsa@barfooze.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-11-08 14:55:58 +01:00
Jaroslav Kysela
b6eb0f9bfd all places: doxygen cleanups
I see no errors with these changes using doxygen 1.8.1.1 .

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-08 16:42:24 +02:00
Allan Wirth
7f2b2c8c16 conf: Fix a memory access violation resulting from improper error propogation
Fixes an issue where a variable is used undeclared, which can cause seg
faults on some systems if the configuration file is not formatted
properly.

Signed-off-by: Allan Wirth <allan@allanwirth.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-02-01 08:00:24 +01:00
Arun Raghavan
55abbc9fde build: Fallback to alphasort() if versionsort() isn't available
versionsort() is a GNU-ism and can't be relied on for non-GNU systems.

[modified to define SORTFUNC instead of copying lines by tiwai]

Signed-off-by: Arun Raghavan <arun.raghavan@collabora.co.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-07-17 14:56:14 +02:00
John Spencer
1d3f7975f9 Fix invalid long long format specifier
Per POSIX:

       L      Specifies that a following a, A, e, E, f, F, g, or G  conversion
              specifier applies to a long double argument.

L is only intended to be used with long doubles, not long long ints.

the proper way is to use "ll" instead.

Signed-off-by: John Spencer <maillist-alsa@barfooze.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-04-24 15:38:45 +02:00
Colin Guthrie
7924500688 conf: Allow for a directory to be given as a config file.
When this is done, *.conf files can be placed in that directory and they
will be processed by as if they were included directly.

A directory (typically /usr/share/alsa/alsa.conf.d/) has been
added into the distribution.

v2: Used existing conf syntax rather than processing via autotools
v3: Split file loading into separate function and made error handling
more consistent.

Signed-off-by: Colin Guthrie <colin@mageia.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-09-20 09:28:46 +02:00
Sudarshan Bisht
808ce5deb3 alsa-lib: fixed coverity reported issues under "FORWARD_NULL" checker.
Coverity Static Analysis helps developers find hard-to-spot,
yet potentially crash-causing defects early in the development phase,
reducing the cost,time, and risk of software errors.

This patch has fix for situations where variable can be NULL
but not been checked beforehand

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-05-04 09:11:46 +02:00
Jaroslav Kysela
c6a81e21c0 config file processing: rewrite the locking - use one recursive mutex
Avoid configuration file processing races when multiple threads call
the *open() functions together (for example using alsaloop with
multiple -T jobs can reproduce this issue).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-10-11 10:34:12 +02:00
Rémi Denis-Courmont
8d80d5f344 Use thread-safe locale functions if available
setlocale() is not thread-safe. It can actually trigger a crash if
another thread uses locale informations at the same time in the process.
Library code should use POSIX newlocale/duplocale/uselocale/freelocale
instead. Those functions only change the locale data for the calling
thread.

Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-04-21 19:20:39 +02:00
Jaroslav Kysela
133819d420 Revert "Fix driver conf parsing in snd_config_hook_load_for_all_cards()"
This reverts commit 96da0c842d.

This way of fix brokes card-specific configuration loading.
See http://bugzilla.redhat.com bug#521988 for details.

Appropriate way to handle this problem is to fix the dmix configuration file.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2009-09-09 11:24:11 +02:00
Takashi Iwai
96da0c842d Fix driver conf parsing in snd_config_hook_load_for_all_cards()
Reported by Kevin Goodsell.

Summary: load_for_all_cards fails with existing configuration elements

In snd_config_hook_load_for_all_cards, the first call to
snd_config_search attempts to locate an existing configuration node with
the name of the driver.  Typically none is found, and everything is
good. However, if such a node is located, the next line assumes it is a
leaf node with type 'string' and calls snd_config_get_string to fetch
the string value. If this fails, the entire hook is abandoned.

Because of this, setting something like the following in asoundrc:

cards.<driver name>.foo 0

is sufficient to disable the entire card-specific configuration.

As a concrete example, I have a HDA-Intel sound card. dmix.conf includes
a way to set period_size, period_time, and periods by using
configuration elements of the form cards.<driver name>.pcm.dmix.<var>.
In ~/.asoundrc I add

cards.HDA-Intel.pcm.dmix.period_size 1024

This will cause HDA-Intel.conf to fail to load, and the pcm defined in
default.conf will fail to find the device-specific pcm
cards.HDA-Intel.pcm.default, and fall back on the default pcm using
plughw.  By attempting to configure dmix, I have disabled it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-08-10 14:14:10 +02:00
Clemens Ladisch
5fe83677b5 conf.c: more documentation
Expand the documentation for the snd_config_* functions.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2009-07-27 10:09:03 +02:00
Clemens Ladisch
930335668a conf.c: rename 'node' to 'config'
Just for consistency with the parameter names of all the other
functions.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2009-07-17 12:41:43 +02:00
Clemens Ladisch
9258e8c851 conf.c: rename 'leaf' to 'child'
Nodes that (might) have children are not leaves.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2009-07-17 12:41:17 +02:00
Clemens Ladisch
9bf79f43c5 conf.c: rename 'father' to 'parent'
I haven't found anything that would make compound nodes specifically
male ...

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2009-07-17 12:40:00 +02:00
Clemens Ladisch
5d56a11a8e conf.c: snd_config_add: prevent adopting a non-orphan
When adding a configuration node to another, check that the child node
does not already have a parent.  Otherwise, the old parent's children
list would become corrupted.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2009-07-15 11:20:29 +02:00
Clemens Ladisch
efda3e2bc7 conf.c: fix handling of NULL string values
Make sure that we do not crash when encountering configuration nodes
with a NULL string value, or that at least we run into an assert().

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2009-07-10 07:26:29 +02:00
Clemens Ladisch
e2317969e1 conf.c: snd_config_set_id: prevent duplicate ids
snd_config_add() checks for duplicate ids, but it was possible to create
duplicates by adding a note and changing the id afterwards with
snd_config_set_id(); so we have to add a check there, too.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2009-07-10 07:25:50 +02:00
Clemens Ladisch
2c4b3c7d09 conf.c: fix handling of NULL ids
Make sure that we do not crash when encountering configuration nodes
with a NULL id.  Furthermore, since we cannot avoid having NULL ids
anyway, allow the id of a top-level node to be reset to NULL.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2009-07-09 07:38:26 +02:00
Takashi Iwai
0400fa6f8d Don't accept an empty string for $ALSA_CONFIG_PATH
The variable $ALSA_CONFIG_PATH specifies the config path, but the current
code accepts the empty string and results in a mysterious error because
no config file is found.

This patch fixes the check of the variable and takes the default value
if the string is empty.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2008-12-10 18:20:50 +01:00
Clemens Ladisch
50ce5d049e fix memory leak in snd_config_update_r error path
Do not forget to free the memory for the file name when a file to be
read by snd_config_update_r() cannot be accessed.
2008-01-14 08:53:06 +01:00
Clemens Ladisch
a73ad3f265 conf: show path of any missing configuration file
In all cases where a configuration file is not found, show an error
message with its full path.
2008-01-09 09:42:42 +01:00
Jaroslav Kysela
2ba380fdc4 fix error path in snd_config_hook_load_for_all_cards() 2007-11-25 23:19:49 +01:00
Jaroslav Kysela
d25e281230 Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.cz 2007-10-15 10:24:55 +02:00
Takashi Iwai
21888c5f50 Add config and plugin directory options to configure
Added --with-configdir and --with-plugindir options to configure
which specify the directories for config files and plugin objects
respectively.  The default paths when these options are not
specified are unchanged.
2007-05-03 20:55:54 +02:00
Takashi Iwai
70e4ec9d08 Allow build without libdl and libpthread
Allow building alsa-lib without libdl and libpthread.
Added new options to configure, --with-libdl and --with-pthread.
2007-03-22 00:48:18 +01:00
Jaroslav Kysela
13fdc41785 add snd_device_name_hint() function and initial implementation
- add snd_device_name_hint() and snd_device_name_free_hint() functions
- add snd_ctl_iface_conf_name() functions
- do not accept parameters for the plugin definition without @args section
- add defaults.pcm.dmix.card/device and dsnoop.card/device definitions
- add hints for HDA-Intel.conf, pcm/dmix.conf, pcm/dsnoop.conf and alsa.conf
- add test/namehint test utility
- doxygen related cleanups
2006-10-11 13:18:57 +02:00
Jaroslav Kysela
35b1df509f configuration: added one more alias check to detect a circular configuration 2006-09-28 16:42:19 +02:00
Jaroslav Kysela
1dc96732c2 configuration: avoid endless loop when a key refers to itself
remove one warning from tlv_read routine in control.c
2006-09-28 15:47:25 +02:00
Clemens Ladisch
0211bc3b68 fix parsing of non-decimal integers in configuration files
safe_strtoll() now accepts numbers in any base. It formerly assumed that
its input was a decimal number, which had the consequence that
hexadecimal or octal numbers would be parsed as strings when occurring
outside of parameter lists.

This obsoletes some workarounds in the file permission parsing code that
relied on this bug.
2006-09-18 17:57:58 +02:00
Takashi Iwai
ae363f57be Fix the description of return value of snd_config_search_definition()
Fixed the description of the return value of snd_config_search_definition().
2006-05-02 17:48:47 +02:00
Clemens Ladisch
4433248bf3 remove superfluous free() checks
free() correctly handles NULL pointers, so we can omit explicit checks
for that condition.
2006-02-27 09:58:32 +00:00
Takashi Iwai
eccc92a34d Fix infinite parse of recursive definitions
Fixed the infinite parse (and eventually segfault) of recursive definitions.
Also fixed the parse of a string slave PCM of direct plugins.
2006-01-30 14:41:51 +00:00
Takashi Iwai
b23f367ee3 Remove bad assert
From: Pierre Ossman <drzeus-list@drzeus.cx>

Freeing the global config update structure when it had been created
without any configs present caused an assertion to trigger. Since this
is a valid scenario and the assertion didn't really protect against
anything, it should simply be removed. Attached patch does exactly that.
2006-01-27 11:54:06 +00:00
Jaroslav Kysela
3f5756ca72 Remove superfluous wordexp.h inclusion 2005-11-28 12:02:55 +00:00
Takashi Iwai
2bcaa1f133 Fix free of uninitialized pointer
Fix free of uninitialized pointer (bug#1576).
2005-11-18 16:01:39 +00:00
Clemens Ladisch
b5f50b06d2 fix doxygen warnings
Fix some wrong parameter names, hide some undocumented functions, and
correctly escape <> characters.
2005-10-12 16:08:53 +00:00
Takashi Iwai
1fdd1a6c19 Fix invalid read in setlocale()
Fix suspicious warnings "Invalid read" of setlocale() detected by valgrind2.
2005-08-18 14:58:31 +00:00
Takashi Iwai
e120114bde Clean up string parser
Clean up string parser routines.
2005-08-18 14:53:39 +00:00
Takashi Iwai
7a89e3bbca Fix compile warnings with gcc-4
Fixed compile warnings with gcc-4 about pointer signedness.
2005-06-28 10:24:44 +00:00
Takashi Iwai
087184b0f9 Fix doxygen documents
Fix the warnings of doxygen parsing.
Add some missing documentation.
2005-05-24 14:14:28 +00:00
Takashi Iwai
ad0b348227 Fix compile with gcc-4.0
Fixed compilation with gcc-4.0.
2005-03-24 17:18:01 +00:00
Takashi Iwai
d8f7de1b16 Support dl-object cache
Added the support of dl-object caches for PCM plugins.
2005-02-14 15:09:09 +00:00
Clemens Ladisch
49c9eba8e4 use "C" locale when parsing floating point numbers
Floating point numbers in configuration files always use "." as separator,
so set the locale temporarily to "C" when calling strtod().
2005-02-14 09:35:06 +00:00
Takashi Iwai
361b8128f1 Fix the parse of filenames with spaces
Fixed the parse of filenames with spaces.
2005-02-09 16:59:10 +00:00
Takashi Iwai
2010890399 Fix the bogus return values
Fixed return values from snd_config_load().  Return -EINVAL instead of
internal error numbers.
2005-01-13 15:44:05 +00:00
Clemens Ladisch
593cff5bdc fix memory leak
fix memory leak if snd_user_file() fails
2004-10-05 15:33:04 +00:00
Jaroslav Kysela
abd7316ac8 fixed endless loop when parsing backslash inside bad configuration file 2004-09-08 16:43:17 +00:00
Takashi Iwai
d91948db49 - check the return value of malloc & co. 2004-02-25 11:24:29 +00:00
Jaroslav Kysela
6ad93ac892 added snd_user_file() function
alisp extensions
  - added nth, include, path commands
  - added auto-exec functionality
  - added helpers for C<->lisp interoperability
2003-09-03 19:25:08 +00:00