Commit graph

89 commits

Author SHA1 Message Date
Jaroslav Kysela
8291d2c601 add snd_strlcat() function
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-04-14 18:41:42 +02:00
Jaroslav Kysela
ea8972c83b include: prefer alsa/asoundlib.h for apps, dependency cleanups
Fixes several issues with header files:

- prefer alsa/asoundlib.h file for the alsa-lib core functionalities
  (use #warning to inform current and future developers, do the job)
- include alsa/asoundlib.h in headers for external plugins by default
- pcm_external.h: dependencies cleanup
- as benefit, the parsers in IDEs should get all information for individial
  header files (see PR#435)

This change was mainly tergetted to fix errors caused by wrong include order
(like for endianness detection, missing typedefs etc.).

Closes: https://github.com/alsa-project/alsa-lib/issues/431
Link: https://github.com/alsa-project/alsa-lib/pull/435
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-02-02 18:56:47 +01:00
Takashi Iwai
35d2efefa9 seq: Define new events for UMP EP/FB change notifications
Two new sequencer event types are added for notifications of UMP info
changes: SND_SEQ_EVENT_UMP_EP_CHANGE (68) and
SND_SEQ_EVENT_UMP_BLOCK_CHANGE (69).

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2025-01-14 16:47:37 +01:00
Takashi Iwai
2aefb5c41c seq: Add UMP support
This patch adds the basic support of UMP on ALSA sequencer API.
An extended event type, snd_seq_ump_event_t, is defined.  It's
compatible with the existing type, snd_seq_event_t, but it has a
larger payload of 16 bytes instead of 12 bytes, for holding the full
128bit UMP packet.

The new snd_seq_ump_event_t must have the bit SND_SEQ_EVENT_UMP in the
event flags.

A few new API functions have been added such as
snd_seq_ump_event_output() and snd_seq_ump_event_input() for
reading/writing this new event object.

The support of UMP in the sequencer client is switched by the function
snd_seq_client_set_midi_version().  It can switch from the default
legacy MIDI to UMP MIDI 1.0 or 2.0 on the fly.

The automatic event conversion among UMP and legacy clients can be
suppressed via snd_seq_client_set_ump_conversion().

The inquiry of the associated UMP Endpoints and UMP Blocks can be done
via snd_seq_get_ump_endpoint_info() and snd_seq_get_ump_block_info().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-06 15:13:27 +02:00
Takashi Iwai
040356ecf0 ump: Add helpers to parse / set UMP packet data
This patch defines the structs / unions that can be used for encoding
and decoding UMP packets, as well as inline helper functions.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-06 15:13:27 +02:00
Takashi Iwai
81b0cf46d1 control: Add UMP Endpoint and Block info query support
Add functions to query the UMP Endpoint and Block info via control
interface.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-06 15:13:27 +02:00
SASANO Takayoshi
b33ef3f73d add NetBSD/OpenBSD build support (except test/)
Fixes: https://github.com/alsa-project/alsa-lib/pull/250
Signed-off-by: SASANO Takayoshi <uaa@uaa.org.uk>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-10-17 13:11:29 +02:00
Simon McVittie
87ff5318e3 conf: Use ino64_t to save and compare inode numbers
On 32-bit platforms when not using the large-file-support ABI,
struct stat64 contains ino64_t which is 64-bit, while ino_t is only
32-bit.

snd_config_update_r() checks whether a file has been replaced by saving
the ino member of a struct stat64 and comparing it with a previously-saved
inode number. On 32-bit platforms, assigning the 64-bit member of struct
stat64 to a 32-bit member of struct finfo will truncate it modulo 1<<32,
which could conceivably result in libasound not reloading configuration
when it should (although the inode number space is large enough to make
this failure mode highly unlikely).

Fixes: https://github.com/alsa-project/alsa-lib/pull/231
Signed-off-by: Simon McVittie <smcv@collabora.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-06-05 10:24:26 +02:00
Jaroslav Kysela
a513e65e19 configure: add --with-lfs option
We are forcibly use the LFS (64-bit) calls in the source now. Add a new
check to the configure script and use compatibility defines when those
calls are not available for a reason.

Fixes: https://github.com/alsa-project/alsa-lib/pull/223
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-20 09:55:17 +02:00
Jaroslav Kysela
c687c48210 conf: fix the export of safe_strto* functions from libasound
Only one library should define the safe_strto function. Export it
correctly and add _snd_ prefix to avoid possible clashes with the other
application code.

Fixes: 47252054 ("src/topology/parser.c: drop duplicate safe_strtol_base")
Fixes: https://github.com/alsa-project/alsa-lib/pull/208
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-01-01 19:26:48 +01:00
Jaroslav Kysela
32d332b786 conf: add safe_strtoll_base() like safe_strtol_base()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-11-29 15:01:32 +01:00
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