PCM: Add string conversion helper functions for chmap
Added a few helper functions between chmap and string.
snd_pcm_chmap_type_name() -- a string of the given chmap type
snd_pcm_chmap_name() -- a string of the given channel position
snd_pcm_chmap_print() -- print channel map on the given buffer
snd_pcm_chmap_from_string() -- get a channel position from string
snd_pcm_parse_string() -- parse the whole channel map from string
This is a function similar like snd_pcm_query_chmaps() but performs
the query without a PCM handle. The card, device and substream
numbers are passed as well as stream direction.
PCM: Introduce snd_pcm_chmap_t and snd_pcm_chmap_query_t
Instead of passing ambiguous integer array, define snd_pcm_chmap_t and
snd_pcm_chmap_query_t so that user can understand more easily which
element is for what.
Takashi Iwai [Tue, 21 Aug 2012 13:07:44 +0000 (15:07 +0200)]
Follow channel position definitions to mixer channel in mixer.h
mixer.h already contains some channel position definitions.
To be more consistent over all systems, better to follow the same
order for the new channel map, too. But since UNKNOWN channel must be
zero but the definition in mixer.h contains -1 as UNKNOWN, simply
shift the value with 1.
If the conversion is required between SND_CHMAP and SND_MIXER_SCHN,
just increment/decrement 1. Eventually I'll provide helper functions
for that...
Reilly Grant [Tue, 6 Dec 2011 02:05:42 +0000 (18:05 -0800)]
PCM: plug: Move fast_ops copy after slave configuration.
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
The plug plugin copies the fast_ops structure and fast_op_arg from its
slave PCM on initialization and after inserting a new plugin. This works
unless the slave PCM is also an instance of the plug plugin because plug
can change its fast_ops structure during _snd_pcm_hw_params.
Instead of copying fast_ops in snd_pcm_plug_insert_plugins wait until
the end of snd_pcm_plug_hw_params when the slave has been fully
initialized.
This fixes a crash when two instances of plug are instantiated back to
back and the format conversion plugin inserted by the second is skipped
by the first because the fast_ops pointer is not properly updated.
Takashi Iwai [Fri, 10 Aug 2012 12:14:28 +0000 (14:14 +0200)]
ucm: Improve cset command parsing
The cset command parsing in ucm/main.c assumes implicitly that the
argument contains no space, thus an example below wouldn't work:
cset "name='Input Select' Digital Mic"
This patch introduces a new internal API function
__snd_ctl_ascii_elem_id_parse() to improve the cset parser.
Tanu Kaskinen [Wed, 1 Aug 2012 13:06:16 +0000 (16:06 +0300)]
ucm: Return NULL from get_list0() and get_list20() in case of empty lists.
alloc_str_list() sets the result to NULL too, so this patch
makes the behavior more consistent. This also fixes a crash
in PulseAudio, because PulseAudio assumes that
snd_use_case_get_list() always initializes the result, and
since snd_use_case_get_list() uses get_list20(), this
assumption didn't hold.
This allows us to build in environments that don't provide stpcpy().
This makes it necessary to traverse the string twice, but should not be
noticeable in clients since this function is very unlikely to be part of
a performance-critical path.
Arun Raghavan [Wed, 23 May 2012 12:46:33 +0000 (18:16 +0530)]
ucm: Handle repeat device and modifier enables/disables
Currently, enabling a device twice can cause it to be added to
snd_use_case_mgr_t->active_devices twice, causing the list to become a
loop and subsequent uses to result in an infinite loop.
This patch makes sure we don't enable/disable a device twice, and avoid
doing the same for modifiers.
snd_tlv_convert_from_dB() relies on rangemin/max blindly.
Since this function is exported, it is better for robustness and
consistency to parse the range properly, which this patch does.
Antonio Borneo [Sat, 12 May 2012 16:06:23 +0000 (00:06 +0800)]
pcm: add missing "break" in "switch"
A missing "break" in procedure snd_pcm_write_mmap() causes
execution of "case SND_PCM_ACCESS_MMAP_NONINTERLEAVED" to
fall through next "default" case of the "switch" statement.
Since "default" handles error cases, the procedure returns
error.
The error fixed by this patch blocks transfer of capture
data from kernel to application. Execution get stuck in
alsa-lib, that discards all received data.
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
control_external: Add ability to specify TLV data.
Allow external control plugins to provide TLV data. This allows
user-space pcms to specify dB ranges for controls.
This follows the same model as the ALSA drivers for accessing the
data. The code is based on that implementation. The control can
provide static data or a callback. The data is accessed or modified
in the new snd_ctl_ext_elem_tlv callback.
Rev bump the protocol version to enable checking if an external
control supports TLV.
Luke Yelavich [Wed, 8 Feb 2012 04:09:55 +0000 (15:09 +1100)]
conf/pcm: Add support for Echo3G devices. Thanks to unimatrix.
BugLink: https://bugs.launchpad.net/bugs/433573 Signed-off-by: Luke Yelavich <luke.yelavich@canonical.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Takashi Iwai [Mon, 14 Nov 2011 16:02:40 +0000 (17:02 +0100)]
pcm:mmap_emul: Fix sw_params and others in bypass mode
When the slave doesn't need any mmap-emulation, the plugin shouldn't do
anything special in sw_params and other callbacks but just pass to the
generic helpers and update hwptr and applptr.
Clemens Ladisch [Fri, 7 Oct 2011 20:46:51 +0000 (22:46 +0200)]
control: add snd_ctl_elem_add_enumerated()
Handling of user control elements was implemented for all types except
BYTES and ENUMERATED. Enumerated user controls will be needed for the
device-specific mixers of upcoming FireWire drivers.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Clemens Ladisch [Wed, 21 Sep 2011 06:30:20 +0000 (08:30 +0200)]
pcm: recalculate all rules after changing hw_params flags
The rules engine avoids recalculating rules that do not depend on
any changed parameter, but there is no mechanism to record changed
flags. So when we change a flag, we have to ensure that all rules
depending on that flag are recalculated; the only method to do this
is to force recalculation of all rules.
So far, there have been no kernel drivers with rules depending
on flags, but rules to disable hardware SRCs by setting
SND_PCM_HW_PARAMS_NORESAMPLE are being introduced now.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Colin Guthrie [Fri, 16 Sep 2011 09:04:26 +0000 (10:04 +0100)]
conf: Allow for a directory to be given as a config file.
When this is done, *.conf files can be placed in that directory and they
will be processed by as if they were included directly.
A directory (typically /usr/share/alsa/alsa.conf.d/) has been
added into the distribution.
v2: Used existing conf syntax rather than processing via autotools
v3: Split file loading into separate function and made error handling
more consistent.
Signed-off-by: Colin Guthrie <colin@mageia.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This patch adds new API functions, snd_ctl_open_fallback() and
snd_pcm_open_fallback(). These are just like snd_*_open_lconf() but
used to open a fallback PCM/control. The difference is that it replaces
the name string with the given original name, so that hctl and other
upper-layers will recognize it as an alias.
When "default" PCM and control definitions are overwritten by others
like PulseAudio setup, the original system-default defition is lost.
This is a problem when PA is temporarily (or intentionally) disabled
and user wants to use the default dmix.
This patch adds a new standard definition for the system-default,
"sysdefault". This can be used for fallbacks.
Stephen Warren [Mon, 6 Jun 2011 20:16:57 +0000 (14:16 -0600)]
UCM: get: Implement 'exact' value retrieval
[=]<NAME>[/[<modifier>|</device>][/<verb>]]
- value identifier <NAME>
- Search starts at given modifier or device if any,
else at a verb
- Search starts at given verb if any,
else current verb
- Searches modifier/device, then verb, then defaults
- Specify a leading "=" to search only the exact
device/modifier/verb specified, and not search
through each object in turn.
- Examples:
"PlaybackPCM/Play Music"
"CapturePCM/SPDIF"
From ValueDefaults only:
"=Variable"
From current active verb:
"=Variable//"
From verb "Verb":
"=Variable//Verb"
From "Modifier" in current active verb:
"=Variable/Modifier/"
From "Modifier" in "Verb":
"=Variable/Modifier/Verb"
Stephen Warren [Fri, 3 Jun 2011 20:56:32 +0000 (14:56 -0600)]
UCM: Disallow gets of undefined system properties
In UCM, there are various system-defined properties whose names start
with "_". Explicitly prevent any gets from falling back to properties
defined in a config file if the property name starts with "_", in order
to reserve the entire "_" namespace for system-defined properties.
Stephen Warren [Fri, 3 Jun 2011 20:56:31 +0000 (14:56 -0600)]
UCM: Implement ConflictingDevices, add device list to devices
Wherever SupportedDevice can appear, also allow ConflictingDevice. Only
one or the other (or neither) may be specified. When neither is
specified, allow anything. Sometimes, listing ConflictingDevices may
result in a shorter list than explicitly listing all SupportedDevices.
Add support for SupportedDevice and ConflictingDevice to SectionDevice.
This allows representing devices which are mutually exclusive, e.g. due
to a mux that switches between capturing from two different microphones,
without the possibility of mixing.
Enhance is_modifier_supported to allow ignoring SupportedDevice and
ConflictingDevice. This is useful when querying values from a
SectionModifier; there's no reason we shouldn't be able to query values
just because the current configuration would prevent enabling that
device. The new is_device_supported is implemented similarly.
Enhance switch_device to remove the old device from the current device
list before querying for the new device, and add it back immediately
afterwards. This allows the query for the new device to ignore any
conflicts caused solely by the old device.
... but also allows the old syntax, iff the index is exactly "0". If an
index is present, but not exactly "0", parsing will appear to succeed,
but produce an empty device or modifier.
When naming devices and modifiers, even if the legacy format is used,
any index is not included in the name; i.e. both sets of syntax above
name the device just "Speaker".
The SupportedDevice list syntax still also accepts either "x" or "x.0",
but internally strips ".0" from the tail of any device name. Any other
name including "." is disallowed.
Finally, when comparing device or modifier names, a simple exact string
compare is now used, since no index data is ever present in device or
modifier names.
The one functional change introduced here is that a SupportedDevice
entry of just "x" will now only ever match a single device. It previously
acted as a wildcard for any device named "x.foo".
Stephen Warren [Thu, 2 Jun 2011 22:44:39 +0000 (16:44 -0600)]
UCM: Fix deadlock following failed get _verb
When querying the current verb without a verb set, snd_use_case_get bails
out early without unlocking uc_mgr->mutex. This causes subsequent API calls
to hang. Instead, s/return/goto __end/.
Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Raymond Yau [Fri, 13 May 2011 02:40:28 +0000 (10:40 +0800)]
emu10k1.conf - Fix no sound problem when using SB Live! Platinum
Add asym to front, rear and center_lfe to prevent route change after
removed the lock.
After removed the lock, when application using "hw", "front", "rear",
"surround40" and "surround51", the route of the front channel is
changed (lost right channel or both channels) when other application
using "front", "rear" or "center_lfe" to record
Signed-off-by: Raymond Yau <superquad.vortex2@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Wed, 4 May 2011 07:14:29 +0000 (09:14 +0200)]
Fix compile warnings
strstr() returns a char pointer
simple_none.c: In function ‘base_len’:
simple_none.c:940:33: warning: ordered comparison of pointer with integer zero
simple_none.c:941:29: warning: ordered comparison of pointer with integer zero
alsa-lib: fixed coverity reported issues under "FORWARD_NULL" checker.
Coverity Static Analysis helps developers find hard-to-spot,
yet potentially crash-causing defects early in the development phase,
reducing the cost,time, and risk of software errors.
This patch has fix for situations where variable can be NULL
but not been checked beforehand
Locking the controls in hooks causes a BUSY error when multiple
streams are opened, typically in PulseAudio. Better not to touch
the locking in hooks in such a case.
The ICE1712 kernel driver accepts 10 playback channels and
12 recording channels only. Therefore fix this channel count
in alsa-lib.
BugLink: http://bugs.launchpad.net/bugs/178442 Signed-off-by: David Henningsson <david.henningsson@canonical.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>