]> git.alsa-project.org Git - alsa-lib.git/log
alsa-lib.git
5 years agocreate separated libatopology library with the topology routines
Jaroslav Kysela [Tue, 12 Nov 2019 18:30:36 +0000 (19:30 +0100)]
create separated libatopology library with the topology routines

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: remove configuration files (moved to alsa-ucm-conf repository)
Jaroslav Kysela [Mon, 11 Nov 2019 16:03:26 +0000 (17:03 +0100)]
ucm: remove configuration files (moved to alsa-ucm-conf repository)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: docs: Add MinBufferLevel value
Curtis Malainey [Thu, 7 Nov 2019 01:58:02 +0000 (17:58 -0800)]
ucm: docs: Add MinBufferLevel value

Allows ucm to override minimum buffer level for platforms that
incorrectly report their buffer level.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: docs: Add EDID File value
Curtis Malainey [Thu, 7 Nov 2019 01:58:01 +0000 (17:58 -0800)]
ucm: docs: Add EDID File value

Add a sys path to the EDID file for the corresponding HDMI device so
userspace can use if needed

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agouse-case header file: add more references to correct ASCII ID parsers for CTL/mixer IDs
Jaroslav Kysela [Mon, 11 Nov 2019 13:35:02 +0000 (14:35 +0100)]
use-case header file: add more references to correct ASCII ID parsers for CTL/mixer IDs

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add snd_use_case_parse_selem_id()
Jaroslav Kysela [Mon, 11 Nov 2019 13:22:36 +0000 (14:22 +0100)]
ucm: add snd_use_case_parse_selem_id()

and add strict ucm_id checks to snd_use_case_parse_ctl_elem_id()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agomixer: simple - add snd_mixer_selem_id_parse() from amixer
Jaroslav Kysela [Mon, 11 Nov 2019 13:22:11 +0000 (14:22 +0100)]
mixer: simple - add snd_mixer_selem_id_parse() from amixer

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add If.Condition.RegexMatch
Jaroslav Kysela [Wed, 6 Nov 2019 09:44:29 +0000 (10:44 +0100)]
ucm: add If.Condition.RegexMatch

If.1 {
Condition {
Type RegexMatch
String "something to match"
Regex ".*(thing)"
}
...
}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add ${CardComponents} substitution to the value string processing
Jaroslav Kysela [Wed, 6 Nov 2019 09:21:40 +0000 (10:21 +0100)]
ucm: add ${CardComponents} substitution to the value string processing

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: evaluate nested If blocks also in True/False blocks
Jaroslav Kysela [Wed, 6 Nov 2019 09:19:57 +0000 (10:19 +0100)]
ucm: evaluate nested If blocks also in True/False blocks

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add If.Condition.String to match strings and substrings
Jaroslav Kysela [Wed, 6 Nov 2019 08:51:47 +0000 (09:51 +0100)]
ucm: add If.Condition.String to match strings and substrings

Case insensitive string match:

If.1 {
Condition {
Type String
String1 "aa"
String2 "bb"
}
True {
...
}
}

Substring is present (case sensitive):

If.1 {
Condition {
Type String
Haystack "White Horse"
Needle "Horse"
}
True {
...
}
}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add snd_use_case_parse_ctl_elem_id()
Jaroslav Kysela [Tue, 5 Nov 2019 19:04:54 +0000 (20:04 +0100)]
ucm: add snd_use_case_parse_ctl_elem_id()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add PlaybackCTL and CaptureCTL default values when they are not set
Jaroslav Kysela [Tue, 5 Nov 2019 13:21:07 +0000 (14:21 +0100)]
ucm: add PlaybackCTL and CaptureCTL default values when they are not set

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: small cosmetic uc_error change in execute_sequence()
Jaroslav Kysela [Tue, 5 Nov 2019 13:07:26 +0000 (14:07 +0100)]
ucm: small cosmetic uc_error change in execute_sequence()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add If condition block
Jaroslav Kysela [Tue, 5 Nov 2019 12:02:41 +0000 (13:02 +0100)]
ucm: add If condition block

The syntax is simple:

If./any-if-identificator/ {
  Condition {
    Type /type_here/
    /optional defines/
  }
  True {
    /block used when condition is evaluated as true/
  }
  False {
    /block used when condition is evaluated as false/
  }
}

The Type "ControlExists" is implemented:

Condition {
  Type ControlExists
  Device "hw:${CardId}"
  Control "iface=CARD,name='Headphone Jack'"
}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: do not cache all control devices in get_card_long_name()
Jaroslav Kysela [Tue, 5 Nov 2019 09:21:36 +0000 (10:21 +0100)]
ucm: do not cache all control devices in get_card_long_name()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: parser - use less memory for integer/real values in parse_value()
Jaroslav Kysela [Tue, 5 Nov 2019 09:14:44 +0000 (10:14 +0100)]
ucm: parser - use less memory for integer/real values in parse_value()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: save the whole ctl info to the ctl_list structure
Jaroslav Kysela [Tue, 5 Nov 2019 09:06:37 +0000 (10:06 +0100)]
ucm: save the whole ctl info to the ctl_list structure

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add the run-time variable substitution
Jaroslav Kysela [Mon, 4 Nov 2019 15:18:07 +0000 (16:18 +0100)]
ucm: add the run-time variable substitution

Those two variables are supported:

  ${ConfName}      - configuration file name
  ${CardId}        - card identification string (like PCH)
  ${CardName}      - card name (driver)
  ${CardLongName}  - card long name (driver)
  ${env:ENV_NAME}  - returns the environment variable ENV_NAME

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: fix memory leaks for cdev, bin-file and tlv elements
Jaroslav Kysela [Mon, 4 Nov 2019 17:44:00 +0000 (18:44 +0100)]
ucm: fix memory leaks for cdev, bin-file and tlv elements

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: do not report failure when long name configuration does not exist
Jaroslav Kysela [Mon, 4 Nov 2019 16:14:40 +0000 (17:14 +0100)]
ucm: do not report failure when long name configuration does not exist

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add support for multiple control devices, more aggresive caching
Jaroslav Kysela [Mon, 4 Nov 2019 13:42:45 +0000 (14:42 +0100)]
ucm: add support for multiple control devices, more aggresive caching

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: extend snd_use_case_mgr_open() to address the sound card directly
Jaroslav Kysela [Sun, 3 Nov 2019 18:05:54 +0000 (19:05 +0100)]
ucm: extend snd_use_case_mgr_open() to address the sound card directly

Some clients like pulseaudio wants to access the multiple instances
of sound cards. This patch adds prefixes like "hw:" to the card_name
argument to handle this. The card index (value) or card identification
(string) can be used for this prefix.

Also the prefix "strict:" was added to avoid the driver name and
driver long name matching. It might be useable for use case
configurations which are not bound to the one sound card.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: switch to ucm2 directory and v2 format, keep backward compatibility
Jaroslav Kysela [Sat, 9 Nov 2019 10:53:32 +0000 (11:53 +0100)]
ucm: switch to ucm2 directory and v2 format, keep backward compatibility

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoconf: improve the include paths code
Jaroslav Kysela [Sun, 10 Nov 2019 12:00:59 +0000 (13:00 +0100)]
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>
5 years agoucm: parse_verb_file() - remove folder_name variable and extra logic
Jaroslav Kysela [Sat, 2 Nov 2019 07:57:51 +0000 (08:57 +0100)]
ucm: parse_verb_file() - remove folder_name variable and extra logic

The member uc_mgr->conf_file_name already contains the used directory
name.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: fix uc_mgr_scan_master_configs() - skip correctly component directories
Jaroslav Kysela [Sat, 2 Nov 2019 07:36:46 +0000 (08:36 +0100)]
ucm: fix uc_mgr_scan_master_configs() - skip correctly component directories

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agopcm: the maximal rate is 768000Hz, fix the remain code
Jaroslav Kysela [Fri, 25 Oct 2019 11:43:31 +0000 (13:43 +0200)]
pcm: the maximal rate is 768000Hz, fix the remain code

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: cosmetic fix in get_card_long_name()
Jaroslav Kysela [Fri, 25 Oct 2019 11:42:41 +0000 (13:42 +0200)]
ucm: cosmetic fix in get_card_long_name()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agopcm: fix the period_size for direct plugins (dmix, dsnoop, dshare)
Jaroslav Kysela [Mon, 14 Oct 2019 07:34:35 +0000 (09:34 +0200)]
pcm: fix the period_size for direct plugins (dmix, dsnoop, dshare)

BugLink: https://github.com/alsa-project/alsa-lib/issues/8
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agopcm: Fix the wrong PCM object passed for locking/unlocking
Takashi Iwai [Tue, 24 Sep 2019 10:10:41 +0000 (12:10 +0200)]
pcm: Fix the wrong PCM object passed for locking/unlocking

Most of PCM API functions have snd_pcm_lock()/unlock() wraps for the
actual calls of ops, and some plugins try to unlock/relock internally
for the given PCM object.  This, unfortunately, causes a problem in
some configurations and leads to the unexpected behavior or deadlock.

The main problem is that we call snd_pcm_lock() with the given PCM
object, while calling the ops with pcm->op_arg or pcm->fast_op_arg as
the slave PCM object.  Meanwhile the plugin code assumes that the
passed PCM object is already locked, and calls snd_pcm_unlock().
This bug doesn't hit always because in most cases pcm->op_arg and
fast_op_arg are identical with pcm itself.  But in some configurations
they have different values, so the problem surfaces.

This patch is an attempt to resolve these inconsistencies.  It
replaces most of snd_pcm_lock()/unlock() calls with either pcm->op_arg
or pcm->fast_op_arg, depending on the call pattern, so that the plugin
code can safely run snd_pcm_unlock() to the given PCM object.

Fixes: 54931e5a5455 ("pcm: Add thread-safety to PCM API")
Reported-by: Ben Russell <thematrixeatsyou@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agopcm: chmap: Fix memory leak at snd_pcm_set_chmap()
Takashi Iwai [Tue, 24 Sep 2019 11:48:37 +0000 (13:48 +0200)]
pcm: chmap: Fix memory leak at snd_pcm_set_chmap()

snd_pcm_set_chmap() leaks the memory returned from snd_pcm_get_chmap()
without releasing.  Add the missing free() call as well as a slight
code refactoring.

Reported-by: Conrad Jones
BugLink: https://github.com/alsa-project/alsa-lib/pull/11
Fixes: d20e24e5d161 ("chmap: Always succeed setting the map to what it already is")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agotopology: Fix variable overflow in split_format
Marcin Pietraszko [Mon, 26 Aug 2019 11:51:41 +0000 (13:51 +0200)]
topology: Fix variable overflow in split_format

The 1 which was 32-bit long, when left-shifted by more than 31 caused
an overflow, which resulted in some of the formats being not supported.

Signed-off-by: Marcin Pietraszko <marcin.pietraszko@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agotopology: add support to parse private data for pcm
Keyon Jie [Thu, 1 Aug 2019 09:15:06 +0000 (17:15 +0800)]
topology: add support to parse private data for pcm

We have private data section in struct snd_soc_tplg_pcm, but alsatplg
doesn't support handling it yet, here add handling in tplg_parse_pcm()
to enable it.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: dshare: allow missing bindings
Adam Miartus [Wed, 24 Jul 2019 10:13:00 +0000 (12:13 +0200)]
pcm: dshare: allow missing bindings

allow opening the device and start the audio clock without blocking
any channel

this is required if the audio clock has to be available all the time,
even when application is not streaming audio data

Signed-off-by: Andreas Pape <apape@de.adit-jv.com>
Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: return -ENOSYS when ops or fast_ops callback is NULL
Adam Miartus [Wed, 24 Jul 2019 10:12:59 +0000 (12:12 +0200)]
pcm: return -ENOSYS when ops or fast_ops callback is NULL

function is allowed to continue until it checks for error variable, as to
not conflict with original implementation flow

for simple functions involving only one line, return error immediately in
case callback is NULL

Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm_file: improve error checking in write_wav_header function
Adam Miartus [Fri, 5 Jul 2019 14:40:48 +0000 (16:40 +0200)]
pcm_file: improve error checking in write_wav_header function

previously errno would be returned even for cases where it may have
not been populated, for example one of the write functions failing,
or writing only partial buffer,

now progress through write operations separately and report errno when
appropriate

Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Reviewed-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm_file: in case of failed write clear file buffer variables
Adam Miartus [Mon, 1 Jul 2019 13:25:18 +0000 (15:25 +0200)]
pcm_file: in case of failed write clear file buffer variables

previously, in case of failed write to output file, error is returned
from snd_pcm_writei/read APIs, user could run pcm_drain as fallback and
encounter an assert, since drain would try to write remaining file
buffer to a file

if failed to write to output file in first place, it makes sense to clear
current internal pmc_file file buffer variables

Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Reviewed-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm_file: use EIO instead of EPIPE when failing to write output file
Adam Miartus [Mon, 1 Jul 2019 13:25:16 +0000 (15:25 +0200)]
pcm_file: use EIO instead of EPIPE when failing to write output file

EPIPE is defined as XRUN which is not entirely correct in this condition

failing to write to a file in pcm_file plugin can not be simply recovered
by a retry as user of the api might be led to believe when receiving EPIPE

use EIO instead to indicate a different kid of error that may not be
recoverable by retry

Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Reviewed-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm_file: return errno in case of a failed write operation
Adam Miartus [Mon, 24 Jun 2019 12:21:36 +0000 (14:21 +0200)]
pcm_file: return errno in case of a failed write operation

allows correct error code propagation for snd_pcm_file_write_bytes caller

Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm_file: remove double line
Adam Miartus [Mon, 24 Jun 2019 11:23:23 +0000 (13:23 +0200)]
pcm_file: remove double line

snd_pcm_file_add_frames called two times by mistake, introduced in
2a800c0c4f259043c9217a4aa6a57afaf9f77477

Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm_file: report write output file error to api user
Adam Miartus [Wed, 12 Jun 2019 06:48:28 +0000 (08:48 +0200)]
pcm_file: report write output file error to api user

when writing to output file fails, api user is notified and can handle
recovery

Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Reviewed-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm_file: do not disrupt playback on output file write fail
Adam Miartus [Wed, 12 Jun 2019 06:48:27 +0000 (08:48 +0200)]
pcm_file: do not disrupt playback on output file write fail

previously playback could be interrupted by snd_pcm_file_add_frames:
    assert(file->wbuf_used_bytes < file->wbuf_size_bytes)

in case snd_pcm_file_write_bytes fails to write full amount of bytes
to file, variable wbuf_used_bytes would not be fully decremented by
requested amount of bytes function was called with

for the assert to trigger, multiple write fails need to happen, so
that wbuf_used_bytes overflows wbuf_size_bytes,

this patch will allow application to report error code to api user
who might have an idea how to recover, before assert is triggered,
also reporting error along with the print out message might give user
a better idea of what is going on, where previously reason for
mentioned assert was not immediately clear

Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Reviewed-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: rate: Avoid pointer arithmetic on `void *`
Michael Forney [Wed, 12 Jun 2019 06:08:14 +0000 (23:08 -0700)]
pcm: rate: Avoid pointer arithmetic on `void *`

The pointer operand to the binary `+` operator must be to a complete
object type.

Signed-off-by: Michael Forney <mforney@mforney.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: direct: Remove unused empty struct
Michael Forney [Wed, 12 Jun 2019 06:08:13 +0000 (23:08 -0700)]
pcm: direct: Remove unused empty struct

Signed-off-by: Michael Forney <mforney@mforney.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: Make sure parameter qualifiers match between declaration and definition
Michael Forney [Wed, 12 Jun 2019 06:08:12 +0000 (23:08 -0700)]
pcm: Make sure parameter qualifiers match between declaration and definition

Signed-off-by: Michael Forney <mforney@mforney.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: hw: Don't return in a void function
Michael Forney [Wed, 12 Jun 2019 06:08:11 +0000 (23:08 -0700)]
pcm: hw: Don't return in a void function

A return statement with an expression in a function returning void is
a constraint violation.

Signed-off-by: Michael Forney <mforney@mforney.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoconf: List cases in range explicitly
Michael Forney [Wed, 12 Jun 2019 06:08:10 +0000 (23:08 -0700)]
conf: List cases in range explicitly

Case ranges are a GNU extension, and provide only a slight readability
improvement.

Signed-off-by: Michael Forney <mforney@mforney.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoUse __func__ instead of __FUNCTION__
Michael Forney [Wed, 12 Jun 2019 06:08:09 +0000 (23:08 -0700)]
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>
6 years agoucm: another coverity fix in uc_mgr_config_load()
Jaroslav Kysela [Mon, 27 May 2019 18:10:52 +0000 (20:10 +0200)]
ucm: another coverity fix in uc_mgr_config_load()

6 years agopcm_file: another locking fix (coverity)
Jaroslav Kysela [Mon, 27 May 2019 18:10:32 +0000 (20:10 +0200)]
pcm_file: another locking fix (coverity)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agotopology: next round of coverity fixes
Jaroslav Kysela [Mon, 27 May 2019 12:05:12 +0000 (14:05 +0200)]
topology: next round of coverity fixes

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agopcm_file: coverity fixes (including double locking)
Jaroslav Kysela [Mon, 27 May 2019 11:57:12 +0000 (13:57 +0200)]
pcm_file: coverity fixes (including double locking)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agoucm: coverity fixes
Jaroslav Kysela [Fri, 24 May 2019 19:11:00 +0000 (21:11 +0200)]
ucm: coverity fixes

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agotopology: various coverity fixes
Jaroslav Kysela [Fri, 24 May 2019 18:52:00 +0000 (20:52 +0200)]
topology: various coverity fixes

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agorawmidi_hw: add sanity check for the invalid stream arguments (coverity)
Jaroslav Kysela [Fri, 24 May 2019 18:45:26 +0000 (20:45 +0200)]
rawmidi_hw: add sanity check for the invalid stream arguments (coverity)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agorawmidi: use snd_dlobj_cache_get2() in rawmidi open (coverity)
Jaroslav Kysela [Fri, 24 May 2019 18:31:24 +0000 (20:31 +0200)]
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>
6 years agopcm_hw: close file descriptor in the error path in snd_pcm_hw_open() (coverity)
Jaroslav Kysela [Fri, 24 May 2019 09:11:46 +0000 (11:11 +0200)]
pcm_hw: close file descriptor in the error path in snd_pcm_hw_open() (coverity)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agopcm_file: call pclose() correctly for popen() (coverity)
Jaroslav Kysela [Fri, 24 May 2019 09:09:43 +0000 (11:09 +0200)]
pcm_file: call pclose() correctly for popen() (coverity)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agopcm: fix memory leak in _snd_pcm_parse_config_chmaps() (coverity)
Jaroslav Kysela [Fri, 24 May 2019 08:57:20 +0000 (10:57 +0200)]
pcm: fix memory leak in _snd_pcm_parse_config_chmaps() (coverity)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agocontrol_shm: add missing socket close to the error path (coverity)
Jaroslav Kysela [Fri, 24 May 2019 08:53:09 +0000 (10:53 +0200)]
control_shm: add missing socket close to the error path (coverity)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agocontrol_shm: remove duplicate code (coverity)
Jaroslav Kysela [Fri, 24 May 2019 08:51:47 +0000 (10:51 +0200)]
control_shm: remove duplicate code (coverity)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agoconfig: parse_string() fix the dynamic buffer allocation failure code (coverity)
Jaroslav Kysela [Fri, 24 May 2019 08:44:49 +0000 (10:44 +0200)]
config: parse_string() fix the dynamic buffer allocation failure code (coverity)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agosrc/conf.c: add missing va_end() call (coverity)
Jaroslav Kysela [Fri, 24 May 2019 08:39:05 +0000 (10:39 +0200)]
src/conf.c: add missing va_end() call (coverity)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agoaserver: fix resource leak coverity
Jaroslav Kysela [Fri, 24 May 2019 08:27:25 +0000 (10:27 +0200)]
aserver: fix resource leak coverity

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agopcm: file: add infile read support for mmap mode
Adam Miartus [Thu, 23 May 2019 13:00:40 +0000 (15:00 +0200)]
pcm: file: add infile read support for mmap mode

mmap_begin callback is used to copy data from input file to mmaped
buffer

guard for corner use of api (multiple mmap_begin calls by user) is
introduced to check if next continuous buffer was already overwritten

buffer is overwritten with input file data only in case of stream capture

Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Reviewed-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: add mmap_begin callback to snd_pcm_fast_ops_t api
Adam Miartus [Thu, 23 May 2019 13:00:39 +0000 (15:00 +0200)]
pcm: add mmap_begin callback to snd_pcm_fast_ops_t api

main motivation for adding the callback is to use it to enable operation
on mmaped buffer before user access for pcm_file plugin

support for MMAP read access with masking by data from input file is not
implemented for pcm_file plugin, by adding this callback implementing
such feature can be done by rewriting next continuous portion of buffer
on each mmap_begin call

plugins like softvol use pcm_plugin interface and overwrite the buffer by
looping around it in avail_update callback, this patch hopes to simplify
the task by adding new api callback, removing the need for rewriting
pcm_file (to use pcm_plugin callbacks) and careful checking when looping
around whole mmaped buffer

Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Reviewed-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoucm: Add UCM profile for CX2072X codec on Baytrail/Cherrytrail profiles
Takashi Iwai [Thu, 18 Apr 2019 18:40:18 +0000 (20:40 +0200)]
ucm: Add UCM profile for CX2072X codec on Baytrail/Cherrytrail profiles

Adding a new Conexant CX2072X codec profile and reusing the existing
BYT/CHT platform snippets.

Currently tested only on ASUS E200HA laptop.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: file: add missing unlock on early return
Adam Miartus [Thu, 23 May 2019 09:44:30 +0000 (11:44 +0200)]
pcm: file: add missing unlock on early return

Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: file: use snd_pcm_file_areas_read_infile for readi
Adam Miartus [Tue, 21 May 2019 13:33:08 +0000 (15:33 +0200)]
pcm: file: use snd_pcm_file_areas_read_infile for readi

use previously introduced helper function, this commit unifies behavior
of readi and readn

corner case behavior of readi is changed by this commit, previously,
in case 0 bytes were red from file (EOF), frames = 0 was returned,
signaling api user as if no data was red from slave, after the patch,
amount of frames red from slave with data red from slave stored in buffer
is returned when EOF is reached

Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Reviewed-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: file: add support for infile reading in non interleaved mode
Adam Miartus [Tue, 21 May 2019 13:32:47 +0000 (15:32 +0200)]
pcm: file: add support for infile reading in non interleaved mode

add helper function to copy input file data to buffer mapped by areas,
in case of an error, do not fill the areas, allowing device read buffer
to be provided to api caller

previously unused rbuf variable is reused for this purpose

Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Reviewed-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: dsnoop: Added "hw_ptr_alignment" option in configuration for slave pointer alignment
Vanitha Channaiah [Wed, 15 May 2019 06:26:34 +0000 (11:56 +0530)]
pcm: dsnoop: Added "hw_ptr_alignment" option in configuration for slave pointer alignment

This change adapt the fix commit 6b058fda9dce
("pcm: dmix: Add option to allow alignment of slave pointers")
for dsnoop plugin

Issue is that snd_pcm_wait() goes back to waiting because the hw_ptr
is not period aligned. Therefore snd_pcm_wait() will block for a longer
time as required.

With these rcar driver changes the exact position of the dma is returned.
During snd_pcm_start they read hw_ptr as reference, and this hw_ptr
is now not period aligned, and is a little ahead over the period while it
is read. Therefore when the avail is calculated during snd_pcm_wait(),
it is missing the avail_min by a few frames.

An additional option hw_ptr_alignment is provided to dsnoop configuration,
to allow the user to configure the slave application and hw pointer
alignment at startup

Signed-off-by: Vanitha Channaiah <vanitha.channaiah@in.bosch.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: dshare: Added "hw_ptr_alignment" option in configuration for alignment of slave...
Vanitha Channaiah [Wed, 15 May 2019 06:26:33 +0000 (11:56 +0530)]
pcm: dshare: Added "hw_ptr_alignment" option in configuration for alignment of slave pointers

This change adapt the fix commit 6b058fda9dce
("pcm: dmix: Add option to allow alignment of slave pointers")
for dshare plugin

Issue is that snd_pcm_wait() goes back to waiting because the hw_ptr
is not period aligned. Therefore snd_pcm_wait() will block for a longer
time as required.

With these rcar driver changes the exact position of the dma is returned.
During snd_pcm_start they read hw_ptr as reference, and this hw_ptr
is now not period aligned, and is a little ahead over the period while it
is read. Therefore when the avail is calculated during snd_pcm_wait(),
it is missing the avail_min by a few frames.

An additional option hw_ptr_alignment is provided to dshare configuration,
to allow the user to configure the slave application and hw pointer
alignment at startup

Signed-off-by: Vanitha Channaiah <vanitha.channaiah@in.bosch.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: direct: Add generic hw_ptr_alignment function for dmix, dshare and dsnoop
Vanitha Channaiah [Wed, 15 May 2019 06:26:32 +0000 (11:56 +0530)]
pcm: direct: Add generic hw_ptr_alignment function for dmix, dshare and dsnoop

Move the code snd_pcm_direct_reset_slave_ptr() from pcm_dmix.c
to pcm_direct.c and its header so that the helper function can be
re-used by other direct-pcm plugins.
There is no change in the behavior or the functionality.

Signed-off-by: Vanitha Channaiah <vanitha.channaiah@in.bosch.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoRelease v1.1.9 v1.1.9
Jaroslav Kysela [Fri, 10 May 2019 06:57:21 +0000 (08:57 +0200)]
Release v1.1.9

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agoadd support for GCC's LTO
Jaroslav Kysela [Tue, 9 Apr 2019 10:44:14 +0000 (12:44 +0200)]
add support for GCC's LTO

6 years agopcm: multi plugin: reset hw/appl pointers in prepare/reset functions
Jaroslav Kysela [Tue, 9 Apr 2019 08:33:45 +0000 (10:33 +0200)]
pcm: multi plugin: reset hw/appl pointers in prepare/reset functions

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agoPrintf unsigned longs with %lu instead of %ld (playmidi1.c)
Quipyowert2 [Sun, 17 Feb 2019 13:00:53 +0000 (05:00 -0800)]
Printf unsigned longs with %lu instead of %ld (playmidi1.c)

Signed-off-by: Nathan Mills <the.true.nathan.mills@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agoPrintf unsigned ints with %u instead of %i (pcm.c)
Quipyowert2 [Sun, 17 Feb 2019 12:56:14 +0000 (04:56 -0800)]
Printf unsigned ints with %u instead of %i (pcm.c)

Signed-off-by: Nathan Mills <the.true.nathan.mills@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agoPrintf unsigned long longs with %llu (mixtest.c)
Quipyowert2 [Sun, 17 Feb 2019 12:54:17 +0000 (04:54 -0800)]
Printf unsigned long longs with %llu (mixtest.c)

Signed-off-by: Nathan Mills <the.true.nathan.mills@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agoPrintf unsigned longs with %lu instead of %li (midifile.c)
Quipyowert2 [Sun, 17 Feb 2019 12:51:22 +0000 (04:51 -0800)]
Printf unsigned longs with %lu instead of %li (midifile.c)

Signed-off-by: Nathan Mills <the.true.nathan.mills@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agoPrintf unsigned long with %lu instead of %li (latency.c)
Quipyowert2 [Sun, 17 Feb 2019 12:39:32 +0000 (04:39 -0800)]
Printf unsigned long with %lu instead of %li (latency.c)

Signed-off-by: Nathan Mills <the.true.nathan.mills@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agoPrint unsigned ints with %u instead of %i. (snd_ctl_ascii_elem_id_get)
Quipyowert2 [Sun, 17 Feb 2019 12:37:24 +0000 (04:37 -0800)]
Print unsigned ints with %u instead of %i. (snd_ctl_ascii_elem_id_get)

Signed-off-by: Nathan Mills <the.true.nathan.mills@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agoClose topology config file after parsing it.
Quipyowert2 [Sun, 17 Feb 2019 11:38:16 +0000 (03:38 -0800)]
Close topology config file after parsing it.

Signed-off-by: Nathan Mills <the.true.nathan.mills@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agopcm: multi plugin: detach the hw_ptr and appl_ptr from master_slave
Jaroslav Kysela [Tue, 9 Apr 2019 08:12:34 +0000 (10:12 +0200)]
pcm: multi plugin: detach the hw_ptr and appl_ptr from master_slave

Unfortunately, the master_slave buffer pointers are not always in sync with
the presented avail value and the higher layers (like write_areas) got
confused. Create own hw_ptr and appl_ptr.

This commit also tries to fix the hwsync and delay implementation (iterate
through all slaves).

The multi plugin was designed only for hardware which runs really in sync.
Anyway, users are trying to use this plugin for other purposes.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agopcm: fix wait condition in snd_pcm_write_areas() to avoid return zero
Jaroslav Kysela [Tue, 9 Apr 2019 07:14:33 +0000 (09:14 +0200)]
pcm: fix wait condition in snd_pcm_write_areas() to avoid return zero

The hw_ptr might be updated during the snd_pcm_may_wait_for_avail_min() call,
so even if it returns zero (OK), the avail must be updated again.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agopcm: multi plugin - fix wait_for_avail_min
Jaroslav Kysela [Mon, 25 Mar 2019 15:15:07 +0000 (16:15 +0100)]
pcm: multi plugin - fix wait_for_avail_min

All slaves should be asked to wait otherwise the write loop might
be interrupted and zero frames might be returned.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agopcm: null: Do not allow a period size of 0
Timo Wischer [Mon, 8 Apr 2019 08:55:54 +0000 (10:55 +0200)]
pcm: null: Do not allow a period size of 0

Some applications do not expect that get_period_size_min() could
return 0. Therefore these applications cannot use the null plugin without
this patch.
Due to there is no use case for having a period size of 0 this patch
disallows a period size of 0 when using the null plugin.

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoDrop -I$includedir/alsa from alsa.pc
Takashi Iwai [Tue, 26 Mar 2019 13:48:23 +0000 (14:48 +0100)]
Drop -I$includedir/alsa from alsa.pc

We used to put the additional include path $includedir/alsa in
pkgconfig just because some applications have included asoundlib.h
like
  #include <asoundlib.h>
although the canonical form should be
  #include <alsa/asoundlib.h>

However, adding this include path is significantly dangerous due to
possible conflicts of file names like version.h.  It's already the
reason to discourage people using alsa.pc for the packages.

In this patch, the additional include path from alsa.pc is dropped
finally.  At the same time, as a rescue plan for the programs
including via <asoundlib.h>, a stub header file is provided in
include/sound/asoundlib.h.  It just includes alsa/asoundlib.h with a
warning to suggest for replacing with alsa/asoundlib.h.
Actually this is the same file as we install into sys/asoundlib.h, so
the whole changes are very minimal here.

Acked-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: rate plugin - fix signess in snd_pcm_rate_avail_update() comparison
Jaroslav Kysela [Mon, 25 Mar 2019 15:56:34 +0000 (16:56 +0100)]
pcm: rate plugin - fix signess in snd_pcm_rate_avail_update() comparison

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agoadd snd_strlcpy() and use it everywhere
Jaroslav Kysela [Mon, 25 Mar 2019 15:45:43 +0000 (16:45 +0100)]
add snd_strlcpy() and use it everywhere

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agoalisp: add the missing include
Chih-Wei Huang [Fri, 15 Mar 2019 09:17:04 +0000 (17:17 +0800)]
alisp: add the missing include

Commit d4e08c5e865 changed to use internal versioned functions.
However, the header is not included. It generates the errors:

 In file included from external/alsa-lib/src/alisp/alisp.c:3038:
 external/alsa-lib/src/alisp/alisp_snd.c:583:64: error: implicit declaration of function '__snd_ctl_elem_info_get_dimension' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                         p2 = add_cons2(instance, p2, idx > 0, new_integer(instance, INTERNAL(snd_ctl_elem_info_get_dimension)(&info, idx)));
                                                                                    ^
 external/alsa-lib/include/alsa-symbols.h:30:24: note: expanded from macro 'INTERNAL'
 #define INTERNAL(Name) INTERNAL_CONCAT2_2(__, Name)
                        ^
 external/alsa-lib/include/alsa-symbols.h:29:39: note: expanded from macro 'INTERNAL_CONCAT2_2'
 #define INTERNAL_CONCAT2_2(Pre, Post) Pre##Post
                                      ^
 <scratch space>:396:1: note: expanded from here
 __snd_ctl_elem_info_get_dimension
 ^
 external/alsa-lib/src/alisp/alisp_snd.c:583:64: note: did you mean '__snd_ctl_elem_info_get_dimensions'?
 external/alsa-lib/include/alsa-symbols.h:30:24: note: expanded from macro 'INTERNAL'
 #define INTERNAL(Name) INTERNAL_CONCAT2_2(__, Name)
                       ^
 external/alsa-lib/include/alsa-symbols.h:29:39: note: expanded from macro 'INTERNAL_CONCAT2_2'
 #define INTERNAL_CONCAT2_2(Pre, Post) Pre##Post
                                      ^
 <scratch space>:396:1: note: expanded from here
 __snd_ctl_elem_info_get_dimension
 ^
 external/alsa-lib/src/alisp/alisp_snd.c:578:8: note: '__snd_ctl_elem_info_get_dimensions' declared here
         err = INTERNAL(snd_ctl_elem_info_get_dimensions)(&info);
               ^
 external/alsa-lib/include/alsa-symbols.h:30:24: note: expanded from macro 'INTERNAL'
 #define INTERNAL(Name) INTERNAL_CONCAT2_2(__, Name)
                        ^
 external/alsa-lib/include/alsa-symbols.h:29:39: note: expanded from macro 'INTERNAL_CONCAT2_2'
 #define INTERNAL_CONCAT2_2(Pre, Post) Pre##Post
                                       ^
 <scratch space>:395:1: note: expanded from here
 __snd_ctl_elem_info_get_dimensions
 ^
 2 errors generated.

Fixes: d4e08c5e865 ("control: Proper reference of internal versioned functions")
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agopcm: add the missing <strings.h> include
Chih-Wei Huang [Fri, 15 Mar 2019 09:17:03 +0000 (17:17 +0800)]
pcm: add the missing <strings.h> include

To define the prototype of ffs. See 'man ffs'.

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agoAndroid: avoid using versionsort
Chih-Wei Huang [Fri, 15 Mar 2019 09:17:02 +0000 (17:17 +0800)]
Android: avoid using versionsort

Android doesn't have versionsort yet.

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agoconf: pcm dmix - add CHANNELS argument
Jaroslav Kysela [Wed, 13 Mar 2019 09:45:35 +0000 (10:45 +0100)]
conf: pcm dmix - add CHANNELS argument

It seems that some audio devices do use only mono audio for some
applications (RPi).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agotest/latency: use frame bytes correctly in writebuf()
Jaroslav Kysela [Fri, 1 Mar 2019 11:43:19 +0000 (12:43 +0100)]
test/latency: use frame bytes correctly in writebuf()

Reported-by: Alessandro Lapini <alessandro.lapini@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agopcm: dshare: Fix overflow when slave_hw_ptr rolls over boundary
Brendan Shanks [Mon, 11 Feb 2019 19:51:26 +0000 (11:51 -0800)]
pcm: dshare: Fix overflow when slave_hw_ptr rolls over boundary

In snd_pcm_dshare_sync_area() when 'slave_hw_ptr' rolls over
'slave_boundary', the wrong variable is checked ('dshare->slave_hw_ptr' vs
the local 'slave_hw_ptr'). In some cases, this results in 'slave_hw_ptr'
not rolling over correctly. 'slave_size' and 'size' are then much too
large, and the for loop blocks for several minutes copying samples.

This was likely only triggered on 32-bit systems, since the PCM boundary
is computed based on LONG_MAX and is much larger on 64-bit systems.

This same change was made to pcm_dmix in commit
6c7f60f7a982fdba828e4530a9d7aa0aa2b704ae ("Fix boundary overlap”) from
June 2005.

Signed-off-by: Brendan Shanks <brendan.shanks@teradek.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoucm: bytcr/PlatformEnableSeq.conf update some comments
Hans de Goede [Sun, 3 Feb 2019 11:37:41 +0000 (12:37 +0100)]
ucm: bytcr/PlatformEnableSeq.conf update some comments

Commit f91cc3c7d6b7 ("Update chtrt5645 ucm variants to use
bytcr/PlatformEnableSeq.conf component") updated the
following 2 comments:

 # codec0_out settings (used if SSP2 is connected to aif1)
 # modem_out settings (used if SSP0 is connected to aif2)

Specifically it added the " to aif1" resp. " to aif2" part of the comments.

This is not correct, AIF1 / AIF2 are something which is present on
Realtek codecs only, and either one can be used indepedent of
SSP0 or SSP2 being used (the comments in the chtrt5645 UCM profile
before this change were wrong / outdated).

Besides there not being any relationship between SSP0 or SSP2 being
used, bytcr/PlatformEnableSeq.conf is also used with other codecs,
e.g. the ESS8316 codec where this is not applicable at all.

Therefor this commit removes the " to aif?" part of the comments again
to avoid confusing people reading this in the future.

Cc: Russell Parker <russell.parker7@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoucm: Add ucm files for DB820c board
Srinivas Kandagatla [Tue, 29 Jan 2019 10:48:28 +0000 (10:48 +0000)]
ucm: Add ucm files for DB820c board

DB820c board is based of MSM8996 Qualcomm SoC, which has support for both
Digital and Analog audio. Digital audio is over HDMI and analog is over
WCD9335 codec via SLIMbus.

Board itself has HDMI port, a 3.5mm audio Jack and an Audio expansion
connector.
This patch adds support for HDMI port and 3.5mm jack.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoRevert "conf/ucm: Add a UCM profile for Dell WD19 Dock USB-audio"
Jaroslav Kysela [Fri, 25 Jan 2019 11:09:31 +0000 (12:09 +0100)]
Revert "conf/ucm: Add a UCM profile for Dell WD19 Dock USB-audio"

This reverts commit d8013619c942dd996c32337a9ade429bfaf455ee.

The USB driver defines identical profile as for WD15.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>