]> git.alsa-project.org Git - alsa-lib.git/log
alsa-lib.git
3 years agoucm: main - fix the compilation error (signess)
Jaroslav Kysela [Fri, 20 May 2022 07:22:33 +0000 (09:22 +0200)]
ucm: main - fix the compilation error (signess)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agogitcompile: fix 32 bit compilation support
Jaroslav Kysela [Fri, 20 May 2022 06:46:43 +0000 (08:46 +0200)]
gitcompile: fix 32 bit compilation support

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: eld - add missing ctype.h header inclusion
Jaroslav Kysela [Thu, 19 May 2022 16:00:15 +0000 (18:00 +0200)]
control: eld - add missing ctype.h header inclusion

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: fix for the unitialized write buffer
Jaroslav Kysela [Thu, 19 May 2022 15:35:08 +0000 (17:35 +0200)]
pcm: fix for the unitialized write buffer

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: vc4-hdmi: use a proper hdmi pcm, fix broken default pcm
Matthias Reichl [Sat, 30 Apr 2022 14:28:45 +0000 (16:28 +0200)]
conf: vc4-hdmi: use a proper hdmi pcm, fix broken default pcm

Userspace expects to see a HDMI pcm, so remove the somewhat broken
front and iec958 pcms and add a proper hdmi pcm instead.

The hdmi pcm supports HD/HBR audio passthrough and relays the IEC958
status bits on to the kernel driver so it can switch to HBR audio
packets if needed. The control hook is marked optional because kernels
before 5.14 didn't expose the IEC958 controls.

The default pcm never worked as dmix doesn't support the iec958 format.
So drop dmix, only use plug and softvol, and use the hdmi pcm for
iec958 formatting.

Fixes: https://github.com/alsa-project/alsa-lib/issues/229
Link: https://lore.kernel.org/alsa-devel/20220430142845.229409-1-hias@horus.com/
Signed-off-by: Matthias Reichl <hias@horus.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoremove .travis.yml (using github actions)
Jaroslav Kysela [Thu, 19 May 2022 10:49:49 +0000 (12:49 +0200)]
remove .travis.yml (using github actions)

Fixes: https://github.com/alsa-project/alsa-lib/pull/226
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoREADME: Add link to GitHub Actions
Tomohiro IKEDA [Sun, 15 May 2022 01:05:11 +0000 (10:05 +0900)]
README: Add link to GitHub Actions

Fixes: https://github.com/alsa-project/alsa-lib/pull/225
From: Tomohiro IKEDA <rilakkuma.san.xjapan@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agogithub actions: move to checkout@v3
Jaroslav Kysela [Thu, 19 May 2022 09:46:49 +0000 (11:46 +0200)]
github actions: move to checkout@v3

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: macro - make argument names shorter
Jaroslav Kysela [Thu, 19 May 2022 09:27:37 +0000 (11:27 +0200)]
ucm: macro - make argument names shorter

It seems that the use the macro name as the variable prefix is too large.
Use just two underscores as prefix for the macro arguments to make
macro definitions more readable.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: doc - describe variants, minor corrections
Jaroslav Kysela [Thu, 19 May 2022 08:18:38 +0000 (10:18 +0200)]
ucm: doc - describe variants, minor corrections

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: implement enadev2 and disdev2 sequence commands
Jaroslav Kysela [Thu, 19 May 2022 08:08:48 +0000 (10:08 +0200)]
ucm: implement enadev2 and disdev2 sequence commands

It may be useful to call the sequences from devices from
the verb sequences or another device sequences.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: add support for verb variants
Jaroslav Kysela [Wed, 18 May 2022 11:10:35 +0000 (13:10 +0200)]
ucm: add support for verb variants

The bellow configuration example creates two verbs ("HiFi" and "HiFi 7+1")
with different playback channels for the "Speaker" device.

SectionUseCase."HiFi" {
        File "HiFi.conf"
        Variant."HiFi" {
Comment "Default"
}
Variant."HiFi 7+1" {
Comment "HiFi 7.1"
         }
}

SectionDevice."Speaker" {
Value {
PlaybackChannels 2
}
Variant."HiFi 7+1".Value {
PlaybackChannels 8
}
}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: set SYNTAX_VERSION_MAX to 6
Jaroslav Kysela [Wed, 18 May 2022 06:53:34 +0000 (08:53 +0200)]
ucm: set SYNTAX_VERSION_MAX to 6

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: move macros and evali substitution to Syntax 6
Jaroslav Kysela [Wed, 18 May 2022 06:45:33 +0000 (08:45 +0200)]
ucm: move macros and evali substitution to Syntax 6

There should be printed an error when the new configuration
blocks are used with the older alsa-lib.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: macro - add deep call protection (recursion)
Jaroslav Kysela [Tue, 17 May 2022 17:25:20 +0000 (19:25 +0200)]
ucm: macro - add deep call protection (recursion)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: macro call inplace evaluate inside macro
Jaroslav Kysela [Tue, 17 May 2022 17:21:22 +0000 (19:21 +0200)]
ucm: macro call inplace evaluate inside macro

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: macro - fix the error message, print id
Jaroslav Kysela [Tue, 17 May 2022 16:19:44 +0000 (18:19 +0200)]
ucm: macro - fix the error message, print id

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: return empty string for undefined "open" variables (arguments)
Jaroslav Kysela [Tue, 17 May 2022 12:37:39 +0000 (14:37 +0200)]
ucm: return empty string for undefined "open" variables (arguments)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: allow '-' prefix to avoid errors when the variable is not defined
Jaroslav Kysela [Tue, 17 May 2022 12:35:51 +0000 (14:35 +0200)]
ucm: allow '-' prefix to avoid errors when the variable is not defined

It may be useful to check if variable is not defined.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: allow passing variables through ucm open string
Jaroslav Kysela [Mon, 16 May 2022 11:16:01 +0000 (13:16 +0200)]
ucm: allow passing variables through ucm open string

It is useful to pass information like application capabilities
to the UCM configuration parser. Those variables are prefixed
with '@' for the configuration files.

An example:

   "<<<v1='a b c',x=12>>>hw:1"

Variables can substituted in the configuration:

   "${var:@v1}" -> "a b c"
   "${var:@x}" -> 12

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agouse-case.h: add SND_USE_CASE_DEV_DIRECT define
Jaroslav Kysela [Sat, 14 May 2022 14:20:29 +0000 (16:20 +0200)]
use-case.h: add SND_USE_CASE_DEV_DIRECT define

It may be useful to define the devices without channel remapping
(e.g. ProAudio devices).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: implement MacroDefine and Macro subtree evaluation
Jaroslav Kysela [Fri, 13 May 2022 14:07:38 +0000 (16:07 +0200)]
ucm: implement MacroDefine and Macro subtree evaluation

The arguments are set as temporary variables as /MACRO_NAME/_/ARGUMENT_NAME/.

Example:

  # define new macro MyMacro with arguments ctl_name and ctl_value
  DefineMacro.MyMacro {
    BootSequence [
      cset "name='${var:MyMacro_ctl_name}' ${var:MyMacro_ctl_value}"
    ]
  }

  # instantiate macro for Speaker control (short version)
  Macro.headphone.MyMacro "ctl_name='Speaker Switch',ctl_value=off"

  # instantiate macro for Mic control (second version)
  Macro.mic.MyMacro {
ctl_name "Mic Switch"
ctl_value "off"
  }

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: fix memory leak in snd_config_substitute() for strings
Jaroslav Kysela [Fri, 13 May 2022 14:19:48 +0000 (16:19 +0200)]
conf: fix memory leak in snd_config_substitute() for strings

When destination type is SND_CONFIG_TYPE_STRING, the old string
must be freed.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: local_config may be NULL (error path)
Jaroslav Kysela [Fri, 13 May 2022 07:32:51 +0000 (09:32 +0200)]
ucm: local_config may be NULL (error path)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: add ${evali:} substitution
Jaroslav Kysela [Thu, 12 May 2022 16:33:29 +0000 (18:33 +0200)]
ucm: add ${evali:} substitution

Example:

  Define.var1 2

  LibraryConfig.test.SubstiConfig {
          a "${evali:$var1+1}"
  }

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: shm - initialize write buffer
Jaroslav Kysela [Thu, 5 May 2022 12:37:52 +0000 (14:37 +0200)]
control: shm - initialize write buffer

  ccontrol_shm.c: In function ‘snd_ctl_shm_action’:
  control_shm.c:54:23: error: invalid initializer
     54 |         char buf[1] = 0;
        |                       ^

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: decode HDMI device name from ELD
Jaroslav Kysela [Thu, 5 May 2022 12:28:41 +0000 (14:28 +0200)]
control: decode HDMI device name from ELD

The HDMI drivers set an uniform PCM names. Use ELD (EDID) to obtain
the HDMI device name and send this string to applications for a better
user experience.

Example (aplay -l):

  card 1: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
    Subdevices: 1/1

  vs improved:

  card 1: PCH [HDA Intel PCH], device 8: HDMI 2 [Philips 272P4]
    Subdevices: 1/1

Fixes: https://github.com/alsa-project/alsa-lib/issues/209
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: multi: return correct hwptr and avail from snd_pcm_multi_status()
Yutao Yuan [Wed, 4 May 2022 03:01:34 +0000 (11:01 +0800)]
pcm: multi: return correct hwptr and avail from snd_pcm_multi_status()

Ensure the logic of snd_pcm_multi_status() is consistent with
snd_pcm_multi_avail_update().

Fixes: https://github.com/alsa-project/alsa-lib/pull/224
Fixes: https://github.com/alsa-project/alsa-lib/issues/217
Signed-off-by: Yutao Yuan <infmagic2047reg@outlook.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: direct - allow 'off' string for hw_ptr_alignment
Jaroslav Kysela [Tue, 3 May 2022 17:12:03 +0000 (19:12 +0200)]
pcm: direct - allow 'off' string for hw_ptr_alignment

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: direct - cleanups for snd_pcm_direct_reset_slave_ptr()
Jaroslav Kysela [Tue, 3 May 2022 17:08:59 +0000 (19:08 +0200)]
pcm: direct - cleanups for snd_pcm_direct_reset_slave_ptr()

- improve readability
- pass slave hw_ptr as argument - improves the code flow

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: direct - add support for channel bindings in snd_pcm_direct_query_chmaps()
Jaroslav Kysela [Wed, 6 Apr 2022 18:17:58 +0000 (20:17 +0200)]
pcm: direct - add support for channel bindings in snd_pcm_direct_query_chmaps()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: direct: Check xrun/suspend before the slave hwptr update
Takashi Iwai [Thu, 10 Mar 2022 08:24:12 +0000 (09:24 +0100)]
pcm: direct: Check xrun/suspend before the slave hwptr update

The xrun/suspend may happen at any time and we should check it right
after the slave hwptr update (but before the actual sync_ptr update in
direct pcm side).  Otherwise the hwptr value may be screwed and get
unexpected large read/write.

Reported-by: S.J. Wang <shengjiu.wang@nxp.com>
Acked-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agopcm: direct: Move slave PCM state checks into XRUN check helper
Takashi Iwai [Fri, 4 Mar 2022 09:31:08 +0000 (10:31 +0100)]
pcm: direct: Move slave PCM state checks into XRUN check helper

The check of slave PCM state is always done before the client's
recoveries count check, so let's merge them to the common helper.
Also rename the helper function to snd_pcm_direct_check_xrun() as it's
checking both slave and client states now.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agopcm: direct: Improved suspend/resume support
Takashi Iwai [Thu, 3 Mar 2022 14:09:19 +0000 (15:09 +0100)]
pcm: direct: Improved suspend/resume support

The current resume handling in PCM direct plugins don't treat multiple
clients properly: once after the slave PCM gets resumed by one
client, the access from others at a later point is seen as already
running although the internal state isn't updated and becomes
inconsistent.  This may end up a negative size, which eventually hangs
up.

This patch is an attempt to improve the handling for resume.  Now the
suspended state is treated similarly like XRUN; namely, we keep the
slave PCM "recoveries" count that is modified at each time the slave
PCM XRUN happens, so that we can check the inconsistency against the
client's state.  As a differentiation to XRUN, we set the highest bit
of recoveries count when the slave stream hits SUSPENDED state.  This
bit is referred at comparing with clients, and the client's state is
updated to either XRUN or SUSPENDED depending on this bit.

Along with this change, the actual resume is done in
snd_pcm_direct_slave_recover(), and snd_pcm_direct_resume() rather
calls this internally.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agopcm: direct: Propagate error code from snd_pcm_direct_client_chk_xrun()
Takashi Iwai [Thu, 3 Mar 2022 14:04:09 +0000 (15:04 +0100)]
pcm: direct: Propagate error code from snd_pcm_direct_client_chk_xrun()

Change the snd_pcm_direct_client_chk_xrun() function to return the
current XRUN state via an error code instead of the state change.
This allows the caller more straightforwardly returning its error, and
also covers the case where XRUN has been set but the function gets
called twice.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agopcm: rate: fix drain of partial period at end of buffer
Alan Young [Wed, 23 Feb 2022 09:37:40 +0000 (09:37 +0000)]
pcm: rate: fix drain of partial period at end of buffer

In the case that:
* the buffer size is not an integer multiple of the period size, and
* drain must flush a partial period located before the end of the buffer
  but without a full period available, where
* these conditions may pertain to the source or slave pcm buffer, and
* because rate conversion is always done on a full period,
it is necessary to check that both a full source period is available
before source pcm buffer wrap and a full slave period is available
before slave pcm buffer wrap in order to use the simple, single-commit
implementation in snd_pcm_rate_commit_area().

The alternative fix would be to change snd_pcm_rate_write_areas1() to
take size and slave_size parameters. This would be more disruptive to
the code base, tricky to get right, and is unnecessary given that
snd_pcm_mmap_commit() only commits the partial period of actually valid
converted samples.

Fixes: 3047f8fa5a3d ("Fix possible problems of playback drain with rate plugin")
Signed-off-by: Alan Young <consult.awy@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoucm: fix the '${eval:EXPR}' substitution
Jaroslav Kysela [Tue, 22 Feb 2022 08:50:30 +0000 (09:50 +0100)]
ucm: fix the '${eval:EXPR}' substitution

There was already a variable substitution. Skip it for the eval: case.

Fixes: 7b6da9ee ("ucm: add ${eval:EXPR} substitution (Syntax 5)")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: snd_config_merge - fix comment (overwrite / override)
Jaroslav Kysela [Thu, 27 Jan 2022 17:25:00 +0000 (18:25 +0100)]
conf: snd_config_merge - fix comment (overwrite / override)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: fix the export of safe_strto* functions from libasound
Jaroslav Kysela [Sat, 1 Jan 2022 18:18:25 +0000 (19:18 +0100)]
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>
3 years agosrc/topology/parser.c: drop duplicate safe_strtol_base
Fabrice Fontaine [Sat, 1 Jan 2022 16:20:47 +0000 (17:20 +0100)]
src/topology/parser.c: drop duplicate safe_strtol_base

The safe_strtol_base() function is defined twice since
f547b2e3 ("conf: introduce safe_strtol_base()") and
5fab157a ("topology: do not call strtol directly")
resulting in the following build failure when alsa-utils is built
statically because safe_strtol_base is defined twice.

Fixes: http://autobuild.buildroot.org/results/08d028004090b2a8292f03910cb9bf80a73ac804
Fixes: https://github.com/alsa-project/alsa-lib/pull/207
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: top-level path - set directory from symlink
Jaroslav Kysela [Mon, 13 Dec 2021 13:40:56 +0000 (14:40 +0100)]
ucm: top-level path - set directory from symlink

It is useful to read the top-level symlink and set the configuration
directory according this symlink for the relative paths.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoRelease v1.2.6.1 v1.2.6.1
Jaroslav Kysela [Thu, 9 Dec 2021 13:17:59 +0000 (14:17 +0100)]
Release v1.2.6.1

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: fix the device parsing when arguments has no defaults
Jaroslav Kysela [Thu, 9 Dec 2021 09:15:29 +0000 (10:15 +0100)]
conf: fix the device parsing when arguments has no defaults

The commit bf528b90 sets the value to an empty string which causes
these errors:

   pcm_hw.c: Invalid type for device
   pcm_hw.c: Invalid type for subdevice

When device arguments (@args) have no default values set,
the field must be skipped to keep the compatibility.

BugLink: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/1246
Fixes: https://github.com/alsa-project/alsa-lib/issues/199
Fixes: bf528b90 ("conf: add possibility to evaluate simple integer math expressions")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: accept '_' character in the variable name
Jaroslav Kysela [Tue, 7 Dec 2021 08:21:24 +0000 (09:21 +0100)]
conf: accept '_' character in the variable name

Fixes: https://github.com/alsa-project/alsa-lib/issues/197
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoRelease v1.2.6 v1.2.6
Jaroslav Kysela [Mon, 6 Dec 2021 10:17:27 +0000 (11:17 +0100)]
Release v1.2.6

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: add initial doxygen documenation
Jaroslav Kysela [Sun, 19 Sep 2021 19:00:11 +0000 (21:00 +0200)]
ucm: add initial doxygen documenation

This is an attempt to explain the UCM in a more verbose way.

BugLink: https://github.com/alsa-project/alsa-ucm-conf/issues/103
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: introduce snd_config_load_string()
Jaroslav Kysela [Wed, 1 Dec 2021 09:14:12 +0000 (10:14 +0100)]
conf: introduce snd_config_load_string()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: confeval - fix _to_integer error code
Jaroslav Kysela [Tue, 30 Nov 2021 13:42:12 +0000 (14:42 +0100)]
conf: confeval - fix _to_integer error code

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: fix test/lsb/config.c
Jaroslav Kysela [Tue, 30 Nov 2021 13:41:14 +0000 (14:41 +0100)]
conf: fix test/lsb/config.c

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: improve simple integer math expressions - brackets
Jaroslav Kysela [Tue, 30 Nov 2021 13:32:58 +0000 (14:32 +0100)]
conf: improve simple integer math expressions - brackets

Add brackets to the simple math expressions like:

  $[($a+($val+100))/2]

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: add ${eval:EXPR} substitution (Syntax 5)
Jaroslav Kysela [Tue, 30 Nov 2021 13:19:58 +0000 (14:19 +0100)]
ucm: add ${eval:EXPR} substitution (Syntax 5)

It is useful to do simple integer math in UCM configurations, too.
Use snd_config_evaluate_string() string for this job.

Example:

    ${eval:1+1}
    ${eval:100*$var1}
    ${eval:$[$var2+1]/5}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: add possibility to evaluate simple integer math expressions
Jaroslav Kysela [Mon, 29 Nov 2021 13:57:29 +0000 (14:57 +0100)]
conf: add possibility to evaluate simple integer math expressions

It is useful to use the math expressions for the values in configuration.
This patch adds a simple expression evaluation routines (integer only).
The syntax is simplified unix shell (bash) style.

Examples:

$[1 + 1]
$[$[2 + 2] / $var1]
$[0xa0 | 0x05]

As a bonus, the variable substitutions were more abstracted.
The function snd_config_expand_custom() was introduced to be used
for example in the topology pre-precessor.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: add safe_strtoll_base() like safe_strtol_base()
Jaroslav Kysela [Mon, 29 Nov 2021 14:01:32 +0000 (15:01 +0100)]
conf: add safe_strtoll_base() like safe_strtol_base()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: fix parsing of the internal hexadecimal card identifier (2)
Jaroslav Kysela [Fri, 12 Nov 2021 16:27:02 +0000 (17:27 +0100)]
ucm: fix parsing of the internal hexadecimal card identifier (2)

I forgot to change the passed variable name.

Fixes: 050f18c5 ("ucm: fix parsing of the internal hexadecimal card identifier")
Fixes: https://github.com/alsa-project/alsa-lib/issues/188
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: fix parsing of the internal hexadecimal card identifier
Jaroslav Kysela [Fri, 12 Nov 2021 14:59:28 +0000 (15:59 +0100)]
ucm: fix parsing of the internal hexadecimal card identifier

Too many code was removed.

Fixes: f547b2e3 ("conf: introduce safe_strtol_base()")
Fixes: https://github.com/alsa-project/alsa-lib/issues/188
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: fix DeviceModifier parser
Jaroslav Kysela [Sun, 7 Nov 2021 17:40:18 +0000 (18:40 +0100)]
ucm: fix DeviceModifier parser

The bellow commit caused regression for the SectionModifier parser. Revert
the single line change.

Fixes: 251bc204 ("ucm: implement RenameDevice and RemoveDevice verb management")
Fixes: https://github.com/alsa-project/alsa-lib/issues/167
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: softvol - mark _snd_pcm_parse_control_id as static
Jaroslav Kysela [Tue, 2 Nov 2021 10:04:43 +0000 (11:04 +0100)]
pcm: softvol - mark _snd_pcm_parse_control_id as static

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: partially revert "pcm: softvol - make snd_pcm_parse_control_id private"
Jaroslav Kysela [Tue, 2 Nov 2021 09:55:45 +0000 (10:55 +0100)]
pcm: partially revert "pcm: softvol - make snd_pcm_parse_control_id private"

This reverts partially commit b9a4997e92e4c16147fcf96453a4c3e08080ac66.

It seems that we have have some users for this very specific function.
Mark it deprecated and keep the softvol implementation separate,
so we can remove this function easily in future.

Fixes: https://github.com/alsa-project/alsa-lib/issues/186
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agotopology: do not call strtol directly
Jaroslav Kysela [Tue, 2 Nov 2021 09:43:27 +0000 (10:43 +0100)]
topology: do not call strtol directly

Introduce safe_strtol_base() function and redirects all
strtol calls there. Also, improve error and value handling
in callers.

BugLink: https://github.com/alsa-project/alsa-lib/issues/187
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: introduce safe_strtol_base()
Jaroslav Kysela [Tue, 2 Nov 2021 09:41:07 +0000 (10:41 +0100)]
conf: introduce safe_strtol_base()

It is useful to parse hexadecimal strings, too.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconfigure: bumb version to 1.2.6pre1 (for alsactl/alsa-utils)
Jaroslav Kysela [Thu, 28 Oct 2021 10:13:44 +0000 (12:13 +0200)]
configure: bumb version to 1.2.6pre1 (for alsactl/alsa-utils)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: suppress the no device (no UCM card) errors on request
Jaroslav Kysela [Thu, 28 Oct 2021 09:48:54 +0000 (11:48 +0200)]
ucm: suppress the no device (no UCM card) errors on request

It seems that users are confused when the UCM configuration
is not ready for the particular hardware. Actually, we don't
allow a fine grained message classification in alsa-lib and
UCM API. Allow suppression of this specific type of messages
on the application request (typically alsactl).

BugLink: https://github.com/alsa-project/alsa-utils/issues/111
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agorawmidi: allocate the read buffer in the params call
Jaroslav Kysela [Mon, 11 Oct 2021 12:33:29 +0000 (14:33 +0200)]
rawmidi: allocate the read buffer in the params call

It is better to allocate the read buffer for the framing stream
in the params setup call.

Suggested-by: David Henningsson <coding@diwic.se>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agorawmidi: free framing read bufffer when the framing mode becomes inactive
Jaroslav Kysela [Tue, 5 Oct 2021 12:54:59 +0000 (14:54 +0200)]
rawmidi: free framing read bufffer when the framing mode becomes inactive

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agorawmidi: add support for SNDRV_RAWMIDI_IOCTL_USER_PVERSION
Jaroslav Kysela [Mon, 4 Oct 2021 15:25:06 +0000 (17:25 +0200)]
rawmidi: add support for SNDRV_RAWMIDI_IOCTL_USER_PVERSION

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agorawmidi: return ENOTSUP when timestamp reads are not supported by plugins
Jaroslav Kysela [Wed, 22 Sep 2021 18:18:57 +0000 (20:18 +0200)]
rawmidi: return ENOTSUP when timestamp reads are not supported by plugins

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agorawmidi: allow timestamp reads only for the appropriate read mode
Jaroslav Kysela [Wed, 22 Sep 2021 11:16:54 +0000 (13:16 +0200)]
rawmidi: allow timestamp reads only for the appropriate read mode

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agorawmidi: doc - fix the framing / read mode section
Jaroslav Kysela [Wed, 22 Sep 2021 09:13:57 +0000 (11:13 +0200)]
rawmidi: doc - fix the framing / read mode section

Follow the previous changes and describe the current API.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agorawmidi: rename enum snd_rawmidi_framing to snd_rawmidi_read_mode
Jaroslav Kysela [Wed, 22 Sep 2021 09:05:23 +0000 (11:05 +0200)]
rawmidi: rename enum snd_rawmidi_framing to snd_rawmidi_read_mode

We hide the internal data transfers using the data frames. Rename
the snd_rawmidi_framing enum to snd_rawmidi_read_mode to make
API more straight and understandable.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agorawmidi: define more abstract API for the timestamp reads
Jaroslav Kysela [Tue, 24 Aug 2021 09:36:30 +0000 (11:36 +0200)]
rawmidi: define more abstract API for the timestamp reads

The frame structure is a bit internal thing for the kernel
data transfer implementation. Introduce snd_rawmidi_tread()
function which is straight for the application usage and hides
the framing data transfers (kernel space API).

The current code implements the read cache and does the merging
of the frame reads with the similar timestamps (opposite
to the kernel data split for big chunks).

If the application wants to use super-duper-lighting-fast reads,
the snd_rawmidi_read() may be used, but the structure must be
defined on it's own, because this mechanism is not preferred
and unsupported.

BugLink: https://github.com/alsa-project/alsa-lib/issues/172
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agodlmisc.c: Avoid double unlock in snd_dlobj_cache_get0()
Johan Adolfsson [Thu, 7 Oct 2021 10:12:24 +0000 (12:12 +0200)]
dlmisc.c: Avoid double unlock in snd_dlobj_cache_get0()

Remove call to snd_dlobj_unlock() in snd_dlobj_cache_get0()
All lock/unlock is done by callers of the function.

Buglink: https://github.com/alsa-project/alsa-lib/issues/181
Fixes: https://github.com/alsa-project/alsa-lib/pull/182
Signed-off-by: Johan Adolfsson <johana@axis.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agorawmidi: initialize the reserved space in snd_rawmidi_params_default()
Jaroslav Kysela [Sun, 19 Sep 2021 19:03:43 +0000 (21:03 +0200)]
rawmidi: initialize the reserved space in snd_rawmidi_params_default()

BugLink: https://github.com/alsa-project/alsa-lib/issues/178
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agopcm: multi plugin - adjust appl_ptr on rewind/forward operations
Sava Jakovljev [Mon, 5 Jul 2021 18:28:34 +0000 (20:28 +0200)]
pcm: multi plugin - adjust appl_ptr on rewind/forward operations

When doing rewind or forward operations, application pointer needs to
be properly adjusted, in the same way when doing commit/write
operations.

Fixes: https://github.com/alsa-project/alsa-lib/pull/161
Signed-off-by: Sava Jakovljev <sava.jakovljev@teufel.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agopcm: add a note about return values of snd_pcm_state()
Henrik Enquist [Wed, 7 Jul 2021 19:10:16 +0000 (21:10 +0200)]
pcm: add a note about return values of snd_pcm_state()

Fixes: https://github.com/alsa-project/alsa-lib/pull/162
Signed-off-by: Henrik Enquist <henrik.enquist@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoucm: substitute the before/after identifiers
Jaroslav Kysela [Wed, 1 Sep 2021 09:03:53 +0000 (11:03 +0200)]
ucm: substitute the before/after identifiers

This allows to handle correctly declarations like:
  Before.SectionDevice "${var:DeviceMic}"

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoucm: fix the parsing of the hexadecimal prefix
Jaroslav Kysela [Tue, 31 Aug 2021 07:40:42 +0000 (09:40 +0200)]
ucm: fix the parsing of the hexadecimal prefix

The safe_strtol() function use strtol() which expects
to have the '0x' prefix for the hexadecimal number (when
base argument is zero).

BugLink: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1553
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoucm: avoid zero card instance number
Jaroslav Kysela [Tue, 31 Aug 2021 07:25:12 +0000 (09:25 +0200)]
ucm: avoid zero card instance number

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agorawmidi: Use the standard types for snd_rawmidi_framing_tstamp_t definition
Takashi Iwai [Tue, 24 Aug 2021 08:36:23 +0000 (10:36 +0200)]
rawmidi: Use the standard types for snd_rawmidi_framing_tstamp_t definition

Using the kernel-specific types like __u8 breaks the compilation of
applications.  Also we need the packed attribute.

Although we may want to move to an opaque type later, let's put the
workaround at first.

Fixes: https://github.com/alsa-project/alsa-lib/issues/172
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoasound.h: fix the __packed use for the out-of-kernel code
Jaroslav Kysela [Fri, 20 Aug 2021 19:13:44 +0000 (21:13 +0200)]
asound.h: fix the __packed use for the out-of-kernel code

Also, move __kernel_long_t to type_compat.h for the consistency.

Fixes: https://github.com/alsa-project/alsa-lib/issues/171
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotest: rawmidi: Add test for rawmidi framing API
David Henningsson [Tue, 17 Aug 2021 14:21:13 +0000 (16:21 +0200)]
test: rawmidi: Add test for rawmidi framing API

Adds a "clock type" parameter to the "rawmidi" test program, that when
used and combined with -i (and -v to be useful), activates tstamp type
framing with the specified clock type.

Signed-off-by: David Henningsson <coding@diwic.se>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agorawmidi: Add rawmidi framing API
David Henningsson [Tue, 17 Aug 2021 14:21:12 +0000 (16:21 +0200)]
rawmidi: Add rawmidi framing API

Optionally, incoming rawmidi bytes can be put inside a frame of type
snd_rawmidi_framing_tstamp_t.
The main current benefit is that can enable in-kernel timestamping of
incoming bytes, and that timestamp is likely to be more precise than
what userspace can offer.

Tstamp type framing requires a kernel >= 5.14 and a buffer size that
is a multiple of sizeof(snd_rawmidi_framing_tstamp_t). It is only
available on input streams.

Signed-off-by: David Henningsson <coding@diwic.se>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agocontrol: remap - assign right name to the child handle for no-op (2nd case)
Jaroslav Kysela [Tue, 29 Jun 2021 17:31:28 +0000 (19:31 +0200)]
control: remap - assign right name to the child handle for no-op (2nd case)

Fixes: https://github.com/alsa-project/alsa-utils/issues/100
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agocontrol: remap - assign right name to the child handle for no-op
Jaroslav Kysela [Tue, 29 Jun 2021 16:02:27 +0000 (18:02 +0200)]
control: remap - assign right name to the child handle for no-op

Fixes: https://github.com/alsa-project/alsa-utils/issues/100
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agopcm: rate - fix some gcc warnings
Jaroslav Kysela [Mon, 28 Jun 2021 10:11:54 +0000 (12:11 +0200)]
pcm: rate - fix some gcc warnings

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agofix build with --disable-ucm
Jaroslav Kysela [Mon, 28 Jun 2021 10:08:53 +0000 (12:08 +0200)]
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>
4 years agocontrol: Minor documentation fixes.
Tanjeff-N. Moos [Thu, 17 Jun 2021 08:36:39 +0000 (10:36 +0200)]
control: Minor documentation fixes.

Signed-off-by: Tanjeff-N. Moos <tanjeff@cccmz.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agocontrol: Add documentation for snd_ctl_card_* and friends.
Tanjeff-N. Moos [Thu, 17 Jun 2021 08:36:38 +0000 (10:36 +0200)]
control: Add documentation for snd_ctl_card_* and friends.

In this patch series, I added a description about control interface
handling and how control interfaces are identified.

In addition, I added/improved Doxygen documentation for the
snd_ctl_card_info_t type and related corresponding functions,
e.g. snd_ctl_card_info(). I also documented other card-related like
snd_card_next().

Along the way I did minor documentation improvements.

Signed-off-by: Tanjeff-N. Moos <tanjeff@cccmz.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agopcm: direct plugins - fix bad memory access when channel bindings do not match hw
Jaroslav Kysela [Mon, 21 Jun 2021 13:14:18 +0000 (15:14 +0200)]
pcm: direct plugins - fix bad memory access when channel bindings do not match hw

Fix and cleanup snd_pcm_direct_check_interleave() function.
Add requested / hardware channel check and use goto when the interleaved

Fixes: https://github.com/alsa-project/alsa-lib/issues/117
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agopcm: Move snd_pcm_channel_area_addr() and _step() to public header
Takashi Iwai [Mon, 21 Jun 2021 12:21:26 +0000 (14:21 +0200)]
pcm: Move snd_pcm_channel_area_addr() and _step() to public header

Used in the rate plugins commonly.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agopcm: direct plugins - fix hw_ptr in the status callback
Jaroslav Kysela [Mon, 21 Jun 2021 07:28:41 +0000 (09:28 +0200)]
pcm: direct plugins - fix hw_ptr in the status callback

The parent hw_ptr may be in another range (boundary limit).
Set the correct value for the caller.

BugLink: https://github.com/alsa-project/alsa-lib/issues/155
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agopcm: dmix - use pcm_frame_diff() in snd_pcm_dmix_sync_ptr0()
Jaroslav Kysela [Mon, 21 Jun 2021 07:23:02 +0000 (09:23 +0200)]
pcm: dmix - use pcm_frame_diff() in snd_pcm_dmix_sync_ptr0()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agopcm: improve docs for snd_pcm_sw_params_get_avail_min() and snd_pcm_status_get_avail_...
Jaroslav Kysela [Fri, 18 Jun 2021 09:35:30 +0000 (11:35 +0200)]
pcm: improve docs for snd_pcm_sw_params_get_avail_min() and snd_pcm_status_get_avail_max()

Fixes: https://github.com/alsa-project/alsa-lib/issues/44
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agopcm: rate: Improve the support multiple formats
Takashi Iwai [Thu, 17 Jun 2021 08:03:17 +0000 (10:03 +0200)]
pcm: rate: Improve the support multiple formats

This patch extends the PCM rate plugin for allowing its converter
plugin to deal with multiple formats.  Currently, the converter plugin
is allowed to take different formats only when convert callback is
defined.  And for this way (so far only the standard linear rate
plugin does), all linear formats have to be handled, and it's
cumbersome.

OTOH, most other rate plugins are implemented with convert_s16
callback, which accepts only S16 format.  This is often not ideal
because many converter engines can handle 32bit formats.  Also, the
target format is often 32bit format, hence this would require
additional conversion even if the converter engine can output 32bit
natively.

In this patch, for addressing the problems above, the rate plugin API
is extended in the following way:

- The new get_supported_formats callback is added; this stores the bit
  masks of the supported input and output formats, as well as the
  behavior flags.  Currently only linear formats are allowed.
- When the plugin accepts only the interleaved stream, set
  SND_PCM_RATE_FLAG_INTERLEAVED flag bit.  Otherwise the code has to
  handle snd_pcm_channel_area at each call.
- When both input and output formats have to be identical, pass
  SND_PCM_RATE_FLAG_SYNC_FORMATS flag bit.
- When the converter wants to process different formats, use convert
  callback instead of convert_s16.  You can put both in the ops for
  compatibility, too.
  The input and output formats are found in the info argument of init
  callback.
- Now the PCM rate plugin core will skip the temporary buffer
  allocation and conversions for pre- and post-process if not needed
  (i.e. matching with the requested input or output format).

The rate plugin API version is bumped to 0x010003.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agopcm: rate: Refactoring temporary buffer allocations
Takashi Iwai [Thu, 17 Jun 2021 08:20:25 +0000 (10:20 +0200)]
pcm: rate: Refactoring temporary buffer allocations

Introduce common helpers to allocate and release the temporary buffers
and the associated snd_pcm_channel.  Now two allocated objects are
used instead of one malloc to be split.

Also, change the snd_pcm_channel set up to be in interleaved mode.
This will be necessary in the following change in the rate plugin.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agocontrol: empty - fix the static build
Jaroslav Kysela [Tue, 15 Jun 2021 21:21:42 +0000 (23:21 +0200)]
control: empty - fix the static build

Reported-by: Jan Palus <atler@pld-linux.org>
Fixes: https://github.com/alsa-project/alsa-lib/issues/157
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agocontrol: remap - fix an infinite recursive call in the async callback
Chih-Wei Huang [Mon, 14 Jun 2021 05:08:08 +0000 (13:08 +0800)]
control: remap - fix an infinite recursive call in the async callback

The function snd_ctl_remap_async will call itself infinitely. Looks like
a typo.

Fixes: a64391a42 ("control: remap plugin - initial version")
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoFix EXPORT_SYMBOL attribute for clang
Chih-Wei Huang [Mon, 14 Jun 2021 04:41:11 +0000 (12:41 +0800)]
Fix EXPORT_SYMBOL attribute for clang

Clang doesn't have the externally_visible attribute.

    src/pcm/pcm.c:1503:1: error: unknown attribute 'externally_visible' ignored [-Werror,-Wunknown-attributes]
    #define EXPORT_SYMBOL __attribute__((visibility("default"),externally_visible))                                                         ^

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoconfigure: check if eaccess() is available
Chih-Wei Huang [Mon, 14 Jun 2021 04:24:10 +0000 (12:24 +0800)]
configure: check if eaccess() is available

To fix the build error on Android:
  src/ucm/parser.c:2521:7: error: implicit declaration of function 'eaccess' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                if (eaccess(filename, R_OK))
                    ^
  src/ucm/parser.c:2521:7: note: did you mean 'access'?

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoucm: include sys/wait.h to fix build on Android
Chih-Wei Huang [Mon, 14 Jun 2021 04:21:35 +0000 (12:21 +0800)]
ucm: include sys/wait.h to fix build on Android

    src/ucm/main.c:788:8: error: implicit declaration of function 'WIFSIGNALED' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                        if (WIFSIGNALED(err)) {
                            ^
    src/ucm/main.c:790:10: error: implicit declaration of function 'WIFEXITED' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                        } if (WIFEXITED(err)) {
                              ^
    src/ucm/main.c:791:34: error: implicit declaration of function 'WEXITSTATUS' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                                if (ignore_error == false && WEXITSTATUS(err) != 0) {

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoucm_exec.c: Include limits.h explicitly to fix build on musl
Andreas Müller [Thu, 3 Jun 2021 10:29:03 +0000 (12:29 +0200)]
ucm_exec.c: Include limits.h explicitly to fix build on musl

Fixes:
| ../../../alsa-lib-1.2.5/src/ucm/ucm_exec.c: In function 'find_exec':
| ../../../alsa-lib-1.2.5/src/ucm/ucm_exec.c:43:18: error: 'PATH_MAX' undeclared (first use in this function)
|    43 |         char bin[PATH_MAX];
|       |                  ^~~~~~~~
| ../../../alsa-lib-1.2.5/src/ucm/ucm_exec.c:43:18: note: each undeclared identifier is reported only once for each function it appears in
| ../../../alsa-lib-1.2.5/src/ucm/ucm_exec.c: In function 'uc_mgr_exec':
| ../../../alsa-lib-1.2.5/src/ucm/ucm_exec.c:177:18: error: 'PATH_MAX' undeclared (first use in this function)
|   177 |         char bin[PATH_MAX];
|       |                  ^~~~~~~~

Fixes: https://github.com/alsa-project/alsa-lib/pull/145
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>