In case the rewind did not rewind as much as expected, e g due to
time delay between the latest avail update and the rewind, we must
properly account for that in the plugin layer.
Otherwise, the plugin's appl ptr and the hw's appl ptr become
unsynchronised, which is very bad, especially in mmap_shadow plugins,
e g, this could cause the overlapping memcpy in the softvol plugin
as seen here:
https://bugs.freedesktop.org/show_bug.cgi?id=64299
Signed-off-by: David Henningsson <david.henningsson@canonical.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Olivier Langlois [Thu, 16 May 2013 08:32:58 +0000 (04:32 -0400)]
Remove an obsolete macro in configure.in
Replaced AM_CONFIG_HEADER with AC_CONFIG_HEADERS
lano1106@whippet2 ~/dev/alsa-lib $ ./gitcompile
aclocal: warning: autoconf input should be named 'configure.ac', not 'configure.in'
configure.in:56: error: 'AM_CONFIG_HEADER': this macro is obsolete.
You should use the 'AC_CONFIG_HEADERS' macro instead.
/usr/share/aclocal-1.13/obsolete-err.m4:12: AM_CONFIG_HEADER is expanded from...
configure.in:56: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
aclocal: error: echo failed with exit status: 1
Steve Langasek [Wed, 15 May 2013 17:05:59 +0000 (19:05 +0200)]
Compile in the ALSA search path instead of relying on ld.so.conf.
The Ubuntu package currently uses ld.so.conf.d fragments to add
/usr/lib/alsa-lib and /usr/lib{32,64}/alsa-lib to the dlopen search path.
These don't *belong* on the global search path, and it becomes much more
problematic to put them there with the advent of multiarch because each
architecture then needs its own distinct config file to add the separate
path... which is then also put in the global library namespace. Instead,
let ALSA make use of the already defined ALSA_PLUGIN_DIR to look up
plugins.
Clemens Ladisch [Mon, 13 May 2013 19:16:36 +0000 (21:16 +0200)]
seqmid: restore sequencer address prefix match feature
Commit 19892334499e (seq: Fix for snd_seq_parse_address()) removed the
ability to match sequencer client names by any of by their prefixes in
an attempt to avoid wrong matches when one client name is the prefix of
another.
However, the prefix match feature was documented and actually used.
Allow prefixes to match, but only if there is no exact match.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Fix doubly call of dlclose() in dlobj caching code
When multiple dlobj_cache items point to the same dlobj, dlclose() may
be called wrongly multiple times when these items are cleared, because
we manage the dlobj_cache list as a flat list. This results in a bad
segfault we've seen in openal-soft, for example.
For fixing this, we need the refcounting of dlobj itself. But, in
this case, we don't have to manage yet another list, since dlopen()
does a proper refcounting by itself. That is, we can just call always
dlopen() at each time a new function is assigned, and also call
dlclose() for each released dlobj_cache item at cleanup.
Cleaning up the dlobj cache seems crashing some cases when the library
is used from another plugin like openal-soft. A simple workaround is
to do the cleanup only when really no user is left, i.e. after all
close calls.
Jaroslav Kysela [Wed, 20 Mar 2013 19:37:50 +0000 (20:37 +0100)]
pcm: fix and optimize snd_pcm_areas_copy function
The memcpy() function in snd_pcm_area_copy() should not be called
with the overlapped areas. Alex discovered - using own LD_PRELOAD checked
for memcpy() input - that the memcpy() is called with src == dst.
For some special plugin combos (rate+softvol+hw for example), the same
areas with same offsets can be asked to be copied (softvol). The collapse
check uses own areas created on heap, causing dst_area == src_area &&
dst_offset == src_offset check bypassed.
Two fixes are in this patch:
- use assert to check the memcpy() input for future triggers
- bypass the snd_pcm_area_copy() call for collapsed identical areas
Reported-by: Alexander Kruppa <akruppa@gmail.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Takashi Iwai [Mon, 11 Feb 2013 11:28:45 +0000 (12:28 +0100)]
Add workaround for conflicting IEC958 controls for HD-audio
When both an SPDIF and an HDMI output are present on HD-audio, both
try to access IEC958 controls with index=0 although one of them must
be wrong. For avoiding this conflict, the recent kernel code (3.9 and
3.8 stable) moves the IEC958 controls of an SPDIF with index=16 once
when the conflict happens.
In this patch, the corresponding support is added in alsa-lib side.
The new "skip_rest" boolean flag is added to the hooked element
definition which indicates that the rest of element array will be
ignored once when this element is present and evaluated. With this
new flag, the HD-audio config takes index=16 primarily, then take
index=0 as fallback.
Takashi Iwai [Fri, 12 Oct 2012 10:22:53 +0000 (12:22 +0200)]
control: Simplify using snd_config_get_bool()
snd_config_get_bool() was improved to parse also ASCII strings now,
so we don't have to open-code the boolean parser in
src/control/setup.c any longer.
Jerome Forissier [Thu, 31 Jan 2013 14:47:23 +0000 (15:47 +0100)]
Add snd_lib_error_set_local() to install a thread-local error handler.
This is required so we can make other functions reentrant (such as
snd_device_name_hint()).
The default error handling function snd_lib_error_default() now checks
if a local handler exists, and if so, calls it. Otherwise, the previous
behavior is unchanged.
Olivier Blin [Sat, 15 Dec 2012 00:58:59 +0000 (01:58 +0100)]
configure: do not detect incorrect cross-compiler
On Ubuntu 11.04, configuring with --build=x86_64-unknown-linux-gnu
--host=x86_64-linux-gnu finds a wrong cross-compiler:
checking for cross-compiler... x86_64-x86_64-pc-linux-gnu-gcc
This happens because of a dash vs underscore inconsistency in configure.in:
host=x86_64-pc-linux-gnu
host_cpu=x86_64
host_os=linux-gnu
which ${host_cpu}-${host_os}-gcc >/dev/null 2>&1 && echo ${host_cpu}-${host-os}-gcc
This configure command is about "cross-compiling for i586", where the
system compiler is used, which just -m32 additional options.
The --build value comes from config.guess.
Takashi Iwai [Thu, 13 Dec 2012 08:55:44 +0000 (09:55 +0100)]
Fix endian check in local.h
SNDRV_LITTLE_ENDIAN and SNDRV_BIG_ENDIAN checks have been removed from
sound/asound.h during UAPI header move, and this resulted in a wrong
detected endian.
Move together with the similar check for SND_*_ENDIAN at the earlier
place in local.h.
Takashi Iwai [Tue, 4 Dec 2012 11:17:00 +0000 (12:17 +0100)]
PCM: Fix conflict of _snd_pcm_hw_params definitions
Fix the call of _snd_pcm_hw_params() to _snd_pcm_hw_params_internal().
The build passed wrongly because of _snd_pcm_hw_params define.
Having the same function name as the struct name is is simply
confusing...
Also, to be sure, _snd_pcm_hw_params is undef'ed in pcm_local.h, too.
Takashi Iwai [Mon, 26 Nov 2012 16:54:29 +0000 (17:54 +0100)]
Merge kernel uapi/sound/asound.h and asequencer.h
Instead of keeping modified asound.h and asequencer.h, copy the files
in the kernel include/uapi/sound as is, and give some renames for
avoiding conflicts with alsa-lib's definitions.
Some structs, unions and typedefs in asound.h and asequencer.h are
once renamed in local.h before inclusion, then renamed back again.
A bonus by this action is that some local codes don't have to refer to
sndrv_xxx any longer. However, some codes like src/seq/seq.c need
explicit cast because of unavoidable conflicts of struct types.
Another significant change is that now snd_pcm_sw_params.period_event
field is removed. Instead, try to access the last reserved field
internally.
Takashi Iwai [Tue, 13 Nov 2012 15:16:26 +0000 (16:16 +0100)]
PCM: Avoid busy loop in snd_pcm_write_areas() with rate plugin
snd_pcm_write_areas() tries to wait until avail >= avail_min condition
is satisfied. This doesn't work always well when a rate plugin is in
the play.
When a partial data with a smaller size than a period is written, the
rate plugin doesn't transfer the data immediately to the slave PCM,
but kept in an internal buffer and it changes only the hwptr of the
plugin. Thus, the condition "avail < avail_min" is triggered for a
wait check although the underlying slave PCM has enough room. This
results in a call of snd_pcm_wait() which returns immediately after
poll() call, and the snd_pcm_write_areas() loop continues. As a
consequence, it falls into a CPU hog.
This patch fixes that busy loop by introducing a new fast_ops to check
the availability for wait of avail_min. Then a plugin can ask the
slave PCM whether the wait is required (or possible).
A few plugins like multi plugin need a special handling. Otherwise a
generic plugin function can be used.
Clemens Ladisch [Sun, 28 Oct 2012 11:30:29 +0000 (12:30 +0100)]
pcm: fix 64-bit SNDRV_PCM_IOCTL_STATUS ABI breakage
Commit cf40ea169aad (pcm: support for audio timestamps) added the new
audio_tstamp field to struct sndrv_pcm_status. However, struct timespec
requires 64-bit alignment, so the 64-bit compiler would insert
32 bits of padding before this field, which broke SNDRV_PCM_IOCTL_STATUS
with error messages like this:
kernel: unknown ioctl = 0x80984120
To solve this, insert the padding explicitly so that it can be taken
into account when calculating the ABI structure size.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
add new snd_pcm_status_get_audio_htstamp() routine to
query the audio timestamps provided by the kernel.
This change provides applications with better ways
to track elapsed time. Before this patch, applications
would subtract queued samples (delay) from written samples,
resulting in a 1-2 sample error.
Also add snd_pcm_hw_params_supports_audio_wallclock_ts()
to query what the hardware supports.
Simple test to create playback and capture streams, and
check elapsed time vs. sample counts reported by driver.
This should be helpful for driver developers and anyone
interested in system/audio time drift.
tested only on HDAudio
[added Makefile.am change by tiwai]
TODO:
- make period configurable
- better output messages
- support for wall clock when it's in the mainline
PCM: Use compounds for overriding / enhancing chmaps
Instead of a single channel map, multiple channel maps can be provided
in a form of compound (array) to hw and null plugins. In null
get_chmap, the channel map corresponding to the current channels is
copied from the given channel maps.
Add chmap override definitions for Emu10k1, Audigy and Audigy2 cards
These cards won't provide the channel maps from the driver itself
because of the dynamic routing. For simplicity, define chmaps in the
configurations, so that chmap querying of individual stereo streams
and combined multi streams works properly.
Add a config definition "chmap" to override (or enhance) the channel
maps. So far, only a single channel map can be provided, and the
channel count consistency isn't strictly tested at all.
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.