Commit graph

39 commits

Author SHA1 Message Date
Jaroslav Kysela
d434638a68 namehint: remember the direction from the upper levels
The current code resets the direction info for each level.
Simply remove this code.

Fixes: https://github.com/alsa-project/alsa-lib/issues/39

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-03-27 11:59:55 +01:00
Jaroslav Kysela
09e78da4ca conf: namehint - add omit_noargs to the hint section
Do not list simple surround devices in the namehint function by default.

Fixes: https://github.com/alsa-project/alsa-lib/issues/27

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-03-02 09:45:55 +01:00
Jaroslav Kysela
6055f8a584 namehint: improve the previous patch (check the returned value)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-12-01 14:30:54 +01:00
Jaroslav Kysela
5ee5ef31b5 namehint: correct the @args check
BugLink: https://github.com/alsa-project/alsa-plugins/issues/3
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-12-01 14:27:04 +01:00
Jaroslav Kysela
5b9041bced Change FSF address (Franklin Street)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2017-11-14 14:29:26 +01:00
Takashi Sakamoto
06a51e29f4 ctl: use automatic variable instead of call of alloca(3)
Inner this library, layouts of all structures are public. At a compilation
time, each size of the structures can be calculated. It means that we can
use automatic variable instead of calling alloca(3) to program this
library because in both ways storages are kept on stack frame of process
VMA. Besides, the usage of automatic variables requires less instructions
than calls of alloca(3). Furthermore, alloca(3) is not described in any
C language standards.

This commit replaces calls of alloca(3) just for structures with automatic
variables, for control features.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-06-27 17:56:21 +02:00
Takashi Iwai
8cdbdae731 namehint: Don't enumerate as duplex if only a single direction is defined
When a hint description has only either device_input or device_output,
we shouldn't handle it as a full duplex but rather a single
direction.  In that way, we can avoid to list up a playback stream
like dmix or surround51 as a capture stream in the namehint.

Reported-by: Trent Reed <treed0803@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-05-12 16:30:44 +02:00
Jaroslav Kysela
df20aa2a1e coverity fixes 2016-01-12 16:26:58 +01:00
Takashi Iwai
46d98392d0 namehint: Fix bad free with invalid iface name
Due to the uninitialized field before the error path, passing an
invalid iface argument may result in a bad free() call.  Initialize
the fields properly beforehand.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-30 14:38:25 +02:00
Takashi Iwai
c8667e3db4 namehint: Fix the listing without device number
The current code of snd_device_name_hint() has a bug when listing up
devices without the device index (e.g. ctl).  Because it assigns the
default device index 0 unconditionally and it has a check at the later
point to filter entries with dev >= 0, it ended up with empty
outputs.

The fix is simply to remove the bogus assignment of dev = 0.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-30 14:32:49 +02:00
Takashi Iwai
bf98b4e316 namehint: Fix invalid list access in snd_device_name_hint()
snd_device_name_hint() tries to free the allocated list at the error
path via snd_device_name_free_hint().  But snd_device_name_free_hint()
expects a list terminated by NULL while snd_device_name_hint() doesn't
add it.  Adding it may again result in an error and thus isn't
guaranteed to work.  Hence we can't add NULL at the error path.

Instead, now the code always allocates one entry more, and zero-clears
the newly allocated beforehand to guarantee the NULL termination.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-30 12:26:43 +02:00
David Henningsson
23bf1dce94 Fix access of freed memory in namehints
Sometimes a hook manipulates the config tree, which makes currently
running iterators point to freed memory. As a workaround, make two
copies, one for the iterators and another for the hooks.

BugLink: https://bugs.launchpad.net/bugs/1008600
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-09-19 18:44:03 +02:00
Jerome Forissier
f49b2dc522 snd_device_name_hint(): do not use global snd_config.
This commit and its parent make the function reentrant.

Signed-off-by: Jerome Forissier <jerome@taodyne.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-31 16:28:27 +01:00
Jerome Forissier
25dbb10281 snd_device_name_hint(): do not change the global error handler.
This is the first step towards making this function reentrant.

Signed-off-by: Jerome Forissier <jerome@taodyne.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-31 16:28:21 +01:00
Andrew Eikum
ad2a0b3a56 Improve snd_device_name_hint documentation
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-01-19 12:36:58 +01:00
Jaroslav Kysela
c049d48407 namehint: Another fix to properly evaluate hw devices
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-10-01 14:08:03 +02:00
Jaroslav Kysela
0244370be6 namehint: Fix hw device evaluation (missing last device)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-10-01 13:31:45 +02:00
Jaroslav Kysela
97d25c0766 namehint: Evaluate more possibilities for hw devices
This tries to fix the issue when logical device indexes does not match the
hardware device indexes (like hdmi -> 0:3, 1:7, 2:8, 3:9).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-08-20 10:33:32 +02:00
John Lindgren
8dde984237 Memory leak in namehint.c
Get_card_name() can be called more than once on the same list, so it
must free the previous list->cardname before replacing it.

Signed-off-by: John Lindgren <john.lindgren@tds.net>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-07-21 09:28:18 +02:00
Jaroslav Kysela
407e98b4c3 namehint: list card independent devices only once
Card-independent devices such as "null" or "pulse" should only be
added once, not once for each card.

Signed-off-by: John Lindgren <john.lindgren@tds.net>\
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2009-11-03 16:44:51 +01:00
Jaroslav Kysela
0fcac21756 namehint: Allow snd_device_name_hint to search for CTL devices.
Signed-off-by: John Lindgren <john.lindgren@tds.net>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2009-11-03 16:42:49 +01:00
Jaroslav Kysela
592bd1e98b namehint: add missing list->card initialization
list->card is wrongly assumed to be initialized, but the previous
initialization is within a conditional that is false when only
card-independent devices are found.  (This is the case when searching
for mixers on my system; the end result is that the "pulse" mixer is
listed three times.)

Signed-off-by: John Lindgren <john.lindgren@tds.net>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2009-11-03 16:42:44 +01:00
Takashi Iwai
e1c7dd2613 Fix corruption after snd_device_name_hint()
snd_device_name_hint() corrupts the config name space after its call.
This results in the error from the suceeding calls of snd_pcm_open()
after snd_device_name_hint().

The bug is in try_config() in namehint.c; it calls snd_config_delete(res)
but res can be two different objects in the function.  One is the object
obtained via snd_config_search_definition(), and another is the one from
snd_config_search_alias_hooks().  The former is the expanded objects,
thus it should be freed.  But, the latter is a reference, and must not be
freed.

This patch adds the check to free or not.

Reported-by: John Lindgren <john.lindgren@tds.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-11-03 09:02:39 +01:00
Diego E. 'Flameeyes' Pettenò
03388ca6d3 Mark static tables as constant when possible.
This makes it possible to write them to .data.rel.ro or to .rodata if
there is no relocation involved (arrays of character arrays).

Signed-off-by: Diego E. 'Flameeyes' Pettenò <flameeyes@gmail.com>
2008-11-21 22:39:38 +01:00
Takashi Iwai
3b2c53c2a6 Fix sort-out of non-existing devices in namehint
get_dev_name() checks wrongly the device_output, and it doesn't check
properly the case when only device is set and device_input and output
are unset.  This resulted in listing of non-existing HDMI device, for
example.  The patch fixes both issues.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2008-10-17 17:51:45 +02:00
Takashi Iwai
363b7f8289 Don't show non-existing devices in snd_device_name_hint()
Suppress the non-existing devices in snd_device_name_hint().
2008-03-07 17:01:56 +01:00
Takashi Iwai
e58bd6762f Fix device number assignment in hints
Handle the device number properly if given in hints.
The current code resets the device number to -1 wrongly.
2008-03-07 17:00:45 +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
40415cd180 Fix undefined references in namehint.c
Fixed undefined references in namehint.c when not all components are
selected via configure options.
2007-07-03 20:22:21 +02:00
Jaroslav Kysela
afb23f3f58 release 1.0.14rc3
Patch-level: Merged
2007-02-26 09:21:12 +01:00
Jaroslav Kysela
2c02c139f4 remove snd_ctl_iface_conf_name() prototype, namehint doxygen cleanups 2006-12-07 15:29:20 +01:00
Jaroslav Kysela
1ba513f96f add snd_device_name_get_hint() function, make hints private to alsa-lib (void)
We can define more string groups for one hint now. It is quite easy
flexible for future.
2006-11-30 13:41:53 +01:00
Takashi Iwai
10e3360575 Fix device name listing with card = -1
Fixed the device name listing with card = -1, such as
aplay -L.
2006-11-06 17:37:15 +01:00
Jaroslav Kysela
9df5c28f55 namehint changes: longname -> cardname, use get_card_name instead longname 2006-10-27 18:19:48 +02:00
Jaroslav Kysela
03389a444b change iface argument for namehint function to const char *
remove snd_ctl_iface_conf_name function
2006-10-27 13:31:32 +02:00
Jaroslav Kysela
d7916981bf pcm config files cleanups and name hint extension
- remove device 0/subdevice 0 from configuration files (it's default)
- name_hint
  - fixed parsing slaves
  - obtain device numbers directly from 'type hw' configurations to
    avoid poluting of configurations scripts with hint.device lines
2006-10-12 16:27:23 +02:00
Jaroslav Kysela
1300e70573 more name hint interace updates
- add long card name to device description
- create empty PCM plugin to allow right hint description parsing
- reorder devices in alsa.conf
- make namehint more configurable (using default.namehint.showall switch)
- add two levels basic and exteded for hints to default configuration files
- do not show direct device aliases
- removed all known memory leaks
2006-10-12 14:34:23 +02:00
Jaroslav Kysela
faf8aad99a fix two issues in snd_device_name_hint()
- returned wrong error when the namehint section does not exist
- variable underflow for the rawmidi interface
2006-10-11 13:59:42 +02: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