Commit graph

2890 commits

Author SHA1 Message Date
Takashi Iwai
30122df4fa Use __inline__ for exported headers
Some programs are still using C90.

Bugzilla: https://bugzilla.novell.com/show_bug.cgi?id=817077
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-04-25 09:52:33 +02:00
Daniel Mack
886f0cc3c2 bring pcm.h and pcm.c in sync with the kernel list
In particular, this adds definitions and descriptions for G.723 and
DSD types.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-04-18 11:45:11 +02:00
Daniel Mack
697f8c296c pcm.c: fix indentation
Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-04-18 11:45:01 +02:00
Takashi Iwai
e1e40c2553 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.

Bugzilla: https://bugzilla.novell.com/show_bug.cgi?id=814250

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-04-15 18:23:46 +02:00
Jaroslav Kysela
812e4b0c5b Release v1.0.27
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-11 13:43:05 +02:00
Jaroslav Kysela
201f28a008 control: enhance doc for snd_ctl_ascii_value_parse() function
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-11 13:38:25 +02:00
Takashi Iwai
91de1212d0 Optimize NULL check in snd_dlobj_cache_put()
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-04-09 15:00:23 +02:00
Takashi Iwai
e79990ac5d Clean up dlobj cache only when no user is present
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.

Bugzilla: https://bugzilla.novell.com/show_bug.cgi?id=814250

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-04-09 15:00:11 +02:00
Jaroslav Kysela
a6813c2d0e pcm: direct plugins: do more safe IPC semaphore handling
As reported dead-lock, do local lock counting and invoke abort() when
the lock counts do not match at close() time.

Reported-by: <mateen abdulmateen.shaikh@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-09 14:37:21 +02:00
Jaroslav Kysela
b6eb0f9bfd all places: doxygen cleanups
I see no errors with these changes using doxygen 1.8.1.1 .

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-08 16:42:24 +02:00
Jaroslav Kysela
e23fb2c4de control, pcm: implement snd_ctl_abort() and snd_pcm_abort() functions
Upon an interrupt, it is necessary to abort the wait loops with the EINTR
error code. Introduce snd_*_abort() functions to handle this case.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-08 13:28:03 +02:00
Daniel Svensson
730c833dd8 pcm: fix typo, should be SND_PCM_STATE_PREPARED.
Signed-off-by: Daniel Svensson <dsvensson@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-04-05 07:36:28 +02:00
David Henningsson
02d9f316a5 USB-audio: Add "HP Digital Stereo Headset" to SPDIF blacklist
Yet another headset without digital I/O.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-04-02 11:21:43 +02:00
Jaroslav Kysela
009193a345 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>
2013-03-20 20:43:34 +01:00
Sander Jansen
28493d9d69 snd_mixer_poll_descriptors_revents should loop over pollfd
Signed-off-by: Sander Jansen <s.jansen@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-02-26 10:08:06 +01:00
Takashi Iwai
f5f45589f8 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.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-02-21 17:52:17 +01:00
Takashi Iwai
8c6da54073 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.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-02-21 17:48:55 +01:00
David Henningsson
3e7dc283ed Add sys/types.h to include list
This is needed by snd_pcm_format_silence* functions which
return u_int*_t. It was discovered while trying to compile ALSA
programs with eglibc 2.17.

Credits to Richard Shaw, Gary Buhrmaster, Matthieu Baerts and
 Adam Conrad for this fix.

BugLink: https://bugs.launchpad.net/bugs/1109298
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=885306
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-02-12 11:18:08 +01:00
Allan Wirth
7f2b2c8c16 conf: Fix a memory access violation resulting from improper error propogation
Fixes an issue where a variable is used undeclared, which can cause seg
faults on some systems if the configuration file is not formatted
properly.

Signed-off-by: Allan Wirth <allan@allanwirth.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-02-01 08:00:24 +01:00
Jerome Forissier
f49b2dc522 snd_device_name_hint(): do not use global snd_config.
This commit and its parent make the function reentrant.

Signed-off-by: Jerome Forissier <jerome@taodyne.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-31 16:28:27 +01:00
Jerome Forissier
25dbb10281 snd_device_name_hint(): do not change the global error handler.
This is the first step towards making this function reentrant.

Signed-off-by: Jerome Forissier <jerome@taodyne.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-31 16:28:21 +01:00
Jerome Forissier
44c1a623dd 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.

Signed-off-by: Jerome Forissier <jerome@taodyne.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-31 16:28:14 +01:00
Jerome Forissier
2cfc8b9b44 snd_pcm_direct_parse_open_conf(): use thread-safe getgrnam_r()
Fixes a thread safety issue with snd_pcm_open().

Signed-off-by: Jerome Forissier <jerome@taodyne.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-30 17:07:12 +01:00
Tanu Kaskinen
1629e2fbf3 ucm: Set uc_mgr->ctl to NULL after closing it.
Fixes a double-free bug.

Signed-off-by: Tanu Kaskinen <tanuk@iki.fi>
Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-28 10:22:30 +01:00
Olivier Blin
b11911dddf 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 bug has been introduced in the initial --with-host support from
2002, commit eb267ade29

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.
2012-12-15 11:18:37 +01:00
Takashi Iwai
72bbf96e1f Fix endian check in local.h
SNDRV_LITTLE_ENDIAN and SNDRV_BIG_ENDIAN checks have been removed from
sound/asound.h during UAPI header move, and this resulted in a wrong
detected endian.

Move together with the similar check for SND_*_ENDIAN at the earlier
place in local.h.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-12-13 09:55:44 +01:00
Takashi Iwai
1b428e7719 mixer: Don't build simple_abst when no libdl is available
Check BUILD_MODULES conditional not to compile simple_abst.c.
Also return -ENXIO to caller statically in that case.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-12-07 09:28:06 +01:00
Takashi Iwai
8d14698931 configure: Quite AM_CONDITIONAL() arguments
Otherwise it won't be processed properly with the recent automake.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-12-07 09:27:11 +01:00
Takashi Iwai
03c26d0ede 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.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-12-04 12:17:00 +01:00
Takashi Iwai
22d6b6e643 Add workaround for conflicting snd_seq_event_t definitions
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-30 14:33:54 +01:00
Takashi Iwai
f47816d6b7 PCM: shut up a compile "unused parameter" compile warning in pcm_multi.c
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-26 18:13:01 +01:00
Takashi Iwai
67d692af48 PCM: Add more chmap definitions for UAC2
The new PCM chmap positions have been added in (to be) 3.8-rc1 kernel,
and now updated alsa-lib, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-26 18:10:26 +01:00
Takashi Iwai
9b5beef1dd Merge kernel uapi/sound/asound.h and asequencer.h
Instead of keeping modified asound.h and asequencer.h, copy the files
in the kernel include/uapi/sound as is, and give some renames for
avoiding conflicts with alsa-lib's definitions.

Some structs, unions and typedefs in asound.h and asequencer.h are
once renamed in local.h before inclusion, then renamed back again.

A bonus by this action is that some local codes don't have to refer to
sndrv_xxx any longer.  However, some codes like src/seq/seq.c need
explicit cast because of unavoidable conflicts of struct types.

Another significant change is that now snd_pcm_sw_params.period_event
field is removed.  Instead, try to access the last reserved field
internally.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-26 18:02:17 +01:00
Takashi Iwai
3fd4ab9be0 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.

Reported-by: Trent Piepho <tpiepho@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-13 16:16:26 +01:00
Jaroslav Kysela
49dde08641 Reduce compilation warnings
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2012-10-30 13:09:10 +01:00
Jaroslav Kysela
edcd677bf2 PCM: Fix memory leak for pcm empty and asym plugins
The init-only plugins do not have own pcm handle, so free the references
to open function immediately after open.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2012-10-30 11:43:07 +01:00
Clemens Ladisch
2b49df0c55 pcm: fix 64-bit SNDRV_PCM_IOCTL_STATUS ABI breakage
Commit cf40ea169a (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>
2012-10-28 12:30:29 +01:00
Pierre-Louis Bossart
cf40ea169a pcm: support for audio timestamps
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.

TODO: check protocol compatibility?

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-10-25 00:13:51 +02:00
Takashi Iwai
4bdb09126a PCM: Fix the invalid snd_pcm_close() calls in rate plugin
It happens in the error path, should call snd_pcm_free() instead.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-10-10 10:22:54 +02:00
Takashi Iwai
a9f395e97c Update .gitignore
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-22 09:39:12 +02:00
Pierre-Louis Bossart
6429a450a3 test: add audio_time
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

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-22 09:39:07 +02:00
Takashi Iwai
5a6ce31520 PCM: Fix infinite loop in htimestamp of dmix, dsnoop and dshare plugins
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-21 17:59:42 +02:00
Takashi Iwai
5a2daef192 PCM: Fill SND_CHMAP_NA to silent channels in route plugin
Instead of SND_CHMAP_UNKNOWN, fill SND_CHMAP_NA to the silent channels.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-20 13:43:12 +02:00
Takashi Iwai
63f6f4a610 PCM: A few doxygen fixes for chmap stuff
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-13 08:38:59 +02:00
Takashi Iwai
c6db60e327 PCM: Fix the conversion from string to chmap position
Use strncasecmp() to allow lower cases, and also evaluate the inverted
phase suffix, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-13 08:24:59 +02:00
Takashi Iwai
f7300682dc PCM: Define MONO and other channel map positions
Follow the new definitions in the kernel side.  MONO and others have
been added, and the order of position table was changed again.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-13 08:24:59 +02:00
Takashi Iwai
58c45b3030 test/chmap: Fix wrong malloc size
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-13 08:24:59 +02:00
Takashi Iwai
2c61a4173f conf: Add chmap definitions to TRIDENT and SI7018 configurations
Manually add the channel map definitions as the channel front/rear is
determined dynamically.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-13 08:24:59 +02:00
Takashi Iwai
ec7acfc408 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.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-13 08:24:59 +02:00
Takashi Iwai
5ba11d69da 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.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-13 08:24:59 +02:00