Commit graph

78 commits

Author SHA1 Message Date
Jaroslav Kysela
f547b2e35f conf: introduce safe_strtol_base()
It is useful to parse hexadecimal strings, too.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-11-02 10:41:11 +01:00
Jaroslav Kysela
f4f29d42be fix build with --disable-ucm
Link: https://mailman.alsa-project.org/pipermail/alsa-devel/2021-June/186729.html
Reported-by: Michael Forney <mforney@mforney.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-28 12:13:56 +02:00
Jaroslav Kysela
8f5779eb3f ucm: add LibraryConfig support
This commit allows to define private alsa-lib's configuration. When
the configuration is present, the device values ("PlaybackCTL",
"CaptureCTL", "PlaybackMixer", "CaptureMixer", "CapturePCM")
are prefixed with '_ucmHEXA.' string where HEXA is replaced by the
unique hexadecimal number identifying the opened ucm manager handle.

    Syntax 4

    LibraryConfig.a_label.SubstiConfig {
            # substituted library configuration like:
            usr_share_dir "${ConfLibDir}"
    }

    LibraryConfig.b_label.Config {
            # non-substituted library configuration like:
            usr_share_dir "/usr/share/alsa"
    }

    The File counterparts:

    LibraryConfig.c_label.SubstiFile "/some/path"
    LibraryConfig.d_label.File "/some/path"

Note that for files the contents is substituted on the request,
but the file name is always substituted (useful for ${ConfDir} etc.).

The private configuration is not saved or preserved. It's life time
belongs to the opened ucm manager handle.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-04-13 17:14:28 +02:00
Rolf Eike Beer
b367274b4d do not set close-on-exec flag on descriptor if it was already set
There is no need to set this again if O_CLOEXEC is supported.

Signed-off-by: Rolf Eike Beer <eb@emlix.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-02-11 12:13:08 +01:00
Jaroslav Kysela
bcd334f58f local.h: remove sound/asoundef.h dependency 2019-11-25 10:36:32 +01:00
Jaroslav Kysela
f600310954 conf: improve the include paths code
- various cleanups (more straight code and allocations)
- do not add the base config path /usr/share/alsa to the
  explicit include list of directories
  (it's not wanted for ucm configs)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-10 13:05:53 +01:00
Michael Forney
0baf7b377c Use __func__ instead of __FUNCTION__
They are equivalent, but __func__ is in C99. __FUNCTION__ exists only
for backwards compatibility with old gcc versions.

Signed-off-by: Michael Forney <mforney@mforney.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-06-12 08:52:07 +02:00
Jaroslav Kysela
8ab0393b42 rawmidi: use snd_dlobj_cache_get2() in rawmidi open (coverity)
Use proper reference counting for the dynamic symbol.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-05-24 21:25:50 +02:00
Jaroslav Kysela
1755df1d9e add snd_strlcpy() and use it everywhere
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-03-25 16:46:05 +01:00
Jaroslav Kysela
1e5ecbc806 conf: rename snd_conf_load1() to _snd_config_load_with_include()
Always free the include path which must be mallocated by the caller.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-01-07 13:15:34 +01:00
Takashi Iwai
c9fcf98369 ucm: Set default include path
Many UCM profiles include the UCM profile components under ucm/*
subdirectories and thusly put <searchdir:ucm> at each place.  This is
rather cumbersome.

This patch makes the UCM parser to set the default include path, so
that each profile no longer needs to set searchdir.  All the
<searchdir:ucm> lines currently found in the profiles are removed
gracefully, too.

For the needed implementation, a new helper,
_snd_config_load_with_include() is introduced.  It's not exported,
only for the use inside alsa-lib.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-11-29 09:40:10 +01:00
Takashi Iwai
de52ee3bb6 core: Proper reference of internal snd_dlopen()
snd_dlopen() was recently rewritten to be versioned symbols, and we
have to call it with INTERNAL() wrapper from the library itself.

Add the proper declaration in the local header and fix the callers
appropriately.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-01-04 15:29:57 +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
Natanael Copa
885c64bcc4 cleanup: fix poll.h includes
According POSIX[1] and linux manpage[2] the include is poll.h, not
sys/poll.h.

This fixes the he following compiler warning when build with musl libc:

  /usr/include/sys/poll.h:1:2: warning: #warning redirecting incorrect #include <sys/poll.h> to <poll.h> [-Wcpp]
   #warning redirecting incorrect #include <sys/poll.h> to <poll.h>
    ^~~~~~~

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-07-12 12:05:37 +02:00
Thomas Klausner
25e6b5b473 Define some types if missing
Include Linux headers on Linux only.
For portability with non-Linux.

Signed-off-by: Thomas Klausner <wiz@NetBSD.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-03 10:59:52 +01:00
Thomas Klausner
623d3be080 Define EBADFD in terms of EBADF if it doesn't exist.
For portability on FreeBSD, NetBSD and probably others.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-02-24 16:35:26 +01:00
Liam Girdwood
ab9633d581 core: add convenience macros to local.h
Move ARRAY_SIZE() from tplg_local.h to local.h and add container_of()
macro to local.h. Both macros are generic but are initially used by
topology.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-08-12 16:39:27 +02:00
Takashi Iwai
7d9972c6ad Allow hint for ctl, hwdep, timer and seq
Like pcm and rawmidi, each object parser needs to accept the hint
component.  Now a new local function _snd_conf_generic_id() was
introduced to replace each call of "comment" and "type" field checks.

Also, the two existing identical functions for pcm and rawmidi are
removed and the new function is used commonly.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-30 14:52:35 +02:00
Patrick Welche
7a6e8ca348 Portability fix: look for sys/endian.h as well as endian.h
- define __BYTE_ORDER and friends.
- adjust asoundlib.h accordingly.

Signed-off-by: Patrick Welche <prlw1@cam.ac.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-02-24 11:00:53 +01:00
John Spencer
10ecf963ca local.h: include sys/types.h to fix issues with pcm.h
sys/types.h is required for the u_int_XX types used by pcm.h.
since a change in pcm.h is not desired, we add the inclusion
to the header that includes pcm.h during build.

Signed-off-by: John Spencer <maillist-alsa@barfooze.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-10-11 09:29:05 +02:00
Jaroslav Kysela
b3b53a1bec local.h: use __kernel_off_t from <linux/types.h>
Also, make the empty definitions __user and __force conditional.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-07-23 14:50:41 +02:00
Takashi Iwai
72bbf96e1f Fix endian check in local.h
SNDRV_LITTLE_ENDIAN and SNDRV_BIG_ENDIAN checks have been removed from
sound/asound.h during UAPI header move, and this resulted in a wrong
detected endian.

Move together with the similar check for SND_*_ENDIAN at the earlier
place in local.h.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-12-13 09:55:44 +01:00
Takashi Iwai
22d6b6e643 Add workaround for conflicting snd_seq_event_t definitions
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-30 14:33:54 +01:00
Takashi Iwai
9b5beef1dd Merge kernel uapi/sound/asound.h and asequencer.h
Instead of keeping modified asound.h and asequencer.h, copy the files
in the kernel include/uapi/sound as is, and give some renames for
avoiding conflicts with alsa-lib's definitions.

Some structs, unions and typedefs in asound.h and asequencer.h are
once renamed in local.h before inclusion, then renamed back again.

A bonus by this action is that some local codes don't have to refer to
sndrv_xxx any longer.  However, some codes like src/seq/seq.c need
explicit cast because of unavoidable conflicts of struct types.

Another significant change is that now snd_pcm_sw_params.period_event
field is removed.  Instead, try to access the last reserved field
internally.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-26 18:02:17 +01:00
Jaroslav Kysela
91c9c8f1b8 general: recoded snd_dlobj_ functions
- changed logic to get/put blocks
- added mutex locking of the symbol list
- added reference counting (do not free used dl handles)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-08-23 17:10:16 +02:00
Rémi Denis-Courmont
8264b2fd0a Open device nodes with close-on-exec flag
Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-11-08 09:23:07 +01:00
Takashi Iwai
7dca3ab1ea Make local functions really local
Rename the local functions to snd1_* so that they won't be exported
out of alsa-lib.

Some functions are still kept because aserver requires them.  Sigh.
2007-11-30 18:26:13 +01:00
Takashi Iwai
54a2cf5ecf Remove sequencer instrument layer
Remove obsoleted sequencer instrument layer from alsa-lib.
The old symbols are compiled in as default as dummy functions
(unless --disable-old-symbols is given to configure) so that
the old binaries can still work more or less.
2007-10-30 12:31:55 +01: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
Takashi Iwai
f0fbd4c03e add support for hosts that have custom symbol prefixes
From: Mike Frysinger <vapier@gentoo.org>

some architectures, like Blackfin, have a prefix added to all symbols (in our
case it's historical baggage)

while normally packages shouldnt care, when code starts mixing assembler with
C (like symbol versioning), you need to dip down into the inner details.
find attached a patch which queries gcc for the prefix (all gcc toolchains
have a builtin define of __USER_LABEL_PREFIX__) and then automatically has
asm() constructs utilize this

since most targets define __USER_LABEL_PREFIX__ to nothing, hopefully this
shouldnt cause any problems :)
2006-09-19 18:07:51 +02:00
Takashi Iwai
609d4a7de6 Avoid unnecesasry call of resmgr
Avoid unnecesasry call of resmgr if the device file really doesn't exist.
2006-02-20 19:32:53 +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
add3a4a1e2 Skip resmgr when EAGAIN or EBUSY
Skip resmgr when EAGAIN or EBUSY.
2006-01-13 15:09:40 +00:00
Takashi Iwai
2f71b8753b Fix type-punning
Fixed compile warnings on the latest gcc about type-punning.
Removed unnecessary casts.
2005-09-29 19:11:50 +00:00
Jaroslav Kysela
8ec3e4ea6c added full async interface to timer API
- added snd_async_add_timer_handler and snd_async_handler_get_timer functions
- added async command to test/timer.c
2005-05-11 12:18:51 +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
Takashi Iwai
f9b9015245 Fix resmgr support
Call normal open() before trying with res_open_device().
snd_open_device() is defined to do this procedure.
2005-02-11 16:35:24 +00:00
Takashi Iwai
2b54677fdb Change error message handling
Change the handling of non-fatal errors.  Now the non-fatal error
messages are not shown in stderr and no assert() as default.  The
behavior can be changed with LIBASOUND_DEBUG environment variable.
2004-12-21 14:11:00 +00:00
Jaroslav Kysela
640ee8faa7 Initial code for lisp interpreter 2003-06-24 19:30:08 +00:00
Jaroslav Kysela
2e7fe2865a Moved send_fd/receive_fd routines to src/socket.c . 2003-03-18 18:00:05 +00:00
Jaroslav Kysela
9c084c4ba6 Updated to new timer API 2003-03-04 20:01:06 +00:00
Takashi Iwai
74f0165c97 - added the hwdep DSP loader API functions.
- updated the internal asound.h.
2003-02-19 15:39:35 +00:00
Jaroslav Kysela
b9343e0834 - unified snd_pcm_hw_params_* functions
- added backward compatibility for older non-compatible functions
- added --with-compat-rc3 to configure script to build library
  backwards compatible with 0.9.0rc3
- added symbol versioning like libc.so.6
  - ALSA_0.9      - alsa base
  - ALSA_0.9.0rc4 - first set of new functions (snd_pcm_hw_params_*)
2002-09-17 12:33:05 +00:00
Jaroslav Kysela
c941c548f8 Moved ring buffer pointers and added a mechanism to transfer them via shm 2002-04-23 15:51:29 +00:00
Jaroslav Kysela
8c1887d7af Moved some prototypes from src/pcm/pcm_plugin.h to include/pcm_plugin.h.
Merged src/pcm/atomic.h to include/iatomic.h.
Added initial description of hw and hooks plugins.
2002-01-12 10:52:42 +00:00
Jaroslav Kysela
3e3df2d32b Updated GNU GPL license (address).
Changed GNU LGPL licence from 2.0 to 2.1.
2001-12-30 09:22:54 +00:00
Jaroslav Kysela
c39882f602 Configuration:
- changed snd_config_get_id function to follow semantic of other get functions
  - added snd_config_test_id
  - added runtime pointer type (not persistent)
    - added snd_config_make_pointer, snd_config_set_pointer, snd_config_get_pointer
  - added type/contents checking for callback functions
    - changed 'void *private_data' to 'snd_config_t *private_data'
  - renamed card_strtype functions to card_driver
Control:
  - fixed passing parameters to snd_ctl_async
Async handlers:
  - added public snd_async_handler_get_signo function
Documentation:
  - moved all documentation to source files
2001-11-19 08:14:21 +00:00
Jaroslav Kysela
58345ae4f4 Separated asoundlib.h to small files. 2001-09-13 11:38:32 +00:00
Jaroslav Kysela
0a8749a802 Changed location of asoundlib.h from sys dir to alsa dir.
(it means that official location is '#include <alsa/asoundlib.h>')
2001-09-11 09:34:13 +00:00