These are mostly a copy-paste from the kernel headers. But since functions
snd_pcm_audio_tstamp_config make use of these they should be added to the
public API as well.
Reported-by: Alex Moon <alex.r.moon@gmail.com> Signed-off-by: David Henningsson <diwic@ubuntu.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Jaroslav Kysela [Tue, 13 Oct 2020 17:28:29 +0000 (19:28 +0200)]
pcm: meter / s16 - add protection for the maximum copied frames
The rewind or forward may cause the stream pointer change. Although
this patch does not fix the real meter update issue, it breaks
the possible big loops when the stream pointers are desynced with
the meters. It does not make sense to copy more samples than the
pcm buffer contains.
Jaroslav Kysela [Tue, 13 Oct 2020 14:51:21 +0000 (16:51 +0200)]
dlsym: use the only alsa plugins directory for the internal modules
The commit b2a4272ecb40d84556d8e043d0b6e89439acbc33 introduced a slightly
different behaviour for ALSA_PLUGIN_DIR. The fallback causes that the
alsa libraries are searched in all library directories.
It was never intended to do the system wide library lookups for
internal modules.
Fixes: b2a4272ecb40 ("snd_dlopen: do not use absolute plugin path for snd_dlopen() calls") Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Jaroslav Kysela [Tue, 6 Oct 2020 08:23:25 +0000 (10:23 +0200)]
ucm: Handle 'Error' keyword in the master file
With the conditional blocks, it may be useful to terminate
the hardware detection from the configuration. Introduce
'Error' keyword for the master UCM configuration file.
Piotr Maziarz [Mon, 31 Aug 2020 09:08:59 +0000 (11:08 +0200)]
topology: decode: Change declaration of enum decoding function
Size constraints are always checked before invoking
tplg_decode_control_enum1. There is no need to validate it twice.
Alos moved debug print about size to invoking function, since now it's it
responsibility to check size.
Signed-off-by: Piotr Maziarz <piotrx.maziarz@linux.intel.com> Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com> Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Piotr Maziarz [Mon, 31 Aug 2020 09:08:56 +0000 (11:08 +0200)]
topology: decode: Remove decoding values for enum control
Values have no representation in standard ALSA configuration files,
therefore there is no need to populate them. Also memory for values
wasn't allocated which was causing undefined behaviour.
Signed-off-by: Piotr Maziarz <piotrx.maziarz@linux.intel.com> Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com> Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
pcm: dmix: fix access to sum-buffer in non-interleaved mixing mode
When dmix uses non-interleaved mixing mode the offset and step width
to sum_buffer was calculated by using the dmix channels instead of
the slave channels. This leads to audio distortions due to frame
corruption.
example:
- With below configuratio, Do aplay on both device in parallel for
audio distortion
pcm: iec958: set channel status bits according to rate and format
This mimics snd_pcm_create_iec958_consumer in the kernel.
The rate and wordlength bits will only be modified if they are
set to "not indicated", which is now the default if no status
option is used.
This allows applications to override parameters determined from
the stream or implement channel status bits extensions without
needing to change pcm_iec958 code.
High bitrate compressed audio data like DTS HD or MAT is usually
packed into 8-channel data. The HDMI specs state this has to be
formatted as a single IEC958 stream, compared to normal multi-
channel PCM data which has to be formatted as parallel IEC958 streams.
As this single-stream formatting mode may break existing setups that
expect non-PCM multichannel data to be formatted as parallel IEC958
streams it needs to be explicitly selected by setting the hdmi_mode
option to true.
The single-stream formatting implementation is prepared to cope with
arbitrary channel counts but only limited testing was done for channel
counts other than 8.
Takashi Iwai [Fri, 19 Jun 2020 16:40:46 +0000 (18:40 +0200)]
pcm: dmix: Fix semaphore usage with lockless operation
As Maarten Baert recently reported, the current dmix code applies the
semaphore unnecessarily around mixing streams even when the lockless
mix operation is used on x86. This was rather introduced mistakenly
at the commit 267d7c728196 ("Add support of little-endian on
i386/x86_64 dmix") where the generic dmix code was included on x86,
too.
For achieving the original performance back, this patch changes the
semaphore handling to be checked at run time instead of statically at
compile time.
Reviewed-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Fri, 19 Jun 2020 16:57:05 +0000 (18:57 +0200)]
pcm: dmix: make lockless operation optional
The recently reported (but a long-standing) bug about the
unconditional semaphore usage in the dmix implies that basically we've
had no problem with the locking in the practical usages over years.
Although the lockless operation has a clear merit, it's a much higher
CPU usage (especially on some uncached pages), and it might lead to a
potential deadlock in theory (which is hard to reproduce at will,
though).
This patch introduces a new configure option "--enable-lockless-dmix"
or "--disable-lockless-dmix" to let user choose the default dmix
operation mode. The usage of the lockless mixing has been already
conditionally enabled via asoundrc and card config
"direct_memory_access", so we just need to set the default value based
on it.
In this patch, the default is set off to the lockless mixing, i.e. the
generic mixing is chosen. It makes more sense from the performance
POV. For any users who still require the lockless operation, it can
be enabled either via configure option or the asoundrc.
The magic number used in the shmem is also changed depending on the
operation mode. It's just for safety, not to conflict both operation
modes with each other.
Reviewed-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Takashi Iwai <tiwai@suse.de>
ctl: improve documentation for identifier of control element
In documentation, there're two ways relevant to the identifier of control
element. However, the case of combination has the lack of parameters.
This commit improves documentation in this point.
Fixes: f3c24de8c0df ("ctl: add an overview for design of ALSA control interface") Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Jaroslav Kysela [Mon, 6 Jul 2020 14:34:33 +0000 (16:34 +0200)]
ucm: substitute the merged tree completely
We need to define the common shared configuration like for multiple
HDMI devices or so. Substitute the whole merged configuration tree
including identifiers.
Fixes: https://github.com/alsa-project/alsa-lib/issues/67 Fixes: https://github.com/alsa-project/alsa-ucm-conf/commit/dcef48f13d4f5db79b006755074940b94730a883 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
The 'Empty "${var:MonoSpeaker}"' part can only every succeed if we do:
Define.MonoSpeaker ""
But so far that would result in an error like this one:
ALSA lib ucm_subs.c:367:(uc_mgr_get_substituted_value) variable '${var:MonoSpeaker}' is not defined in this context!
ALSA lib main.c:983:(snd_use_case_mgr_open) error: failed to import cht-bsw-rt5672 use case configuration -22
alsaucm: error failed to open sound card cht-bsw-rt5672: Invalid argument
This commit fixes this by allowing empty values for "${var:...}"
substitutions.
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Tested-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Mark Hills [Mon, 22 Jun 2020 13:15:10 +0000 (14:15 +0100)]
dsnoop: The delay presented to snd_pcm_status_delay() was incorrect
This was the original bug that caused me to start looking at the
ring buffer functions.
In the API this is documented as:
"Delay is distance between current application frame position and
sound frame position. It's positive and less than buffer size in
normal situation, negative on playback underrun and greater than
buffer size on capture overrun. "
Because dsnoop was returning the buffer space available to the hardware
the return value was always quite large, and moved in the wrong
direction.
With this patch, dsnoop now gives results which are comparable to using
the "hw" device directly. My test case was with snd-echo3g (Layla3G).
Signed-off-by: Mark Hills <mark@xwax.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Mark Hills [Mon, 22 Jun 2020 13:15:08 +0000 (14:15 +0100)]
control: Fix a bug that prevented namehint behaviour
Looks like the documented behaviour was broken in commit 1ba513f9 in
2006, with the introduction of multiple fields.
I've chosen to match the described behaviour. Prior to this patch,
using namehint could be made to work by exploiting the lack of escaping
of the "name", populating the other fields:
"plug:front|DESCDo all conversions for front speakers"
rather than that which is documented and presumed to be the intention
for asoundrc files:
"plug:front|Do all conversions for front speakers"
Everything seems to strongly suggest nobody is using this feature; I can
find no working examples through a web search and probably someone
would have hit this bug. It's not documented in configuration, only in
the snd_device_name_hint() call. So it would probably clutter things to
provide compatibility for the old behaviour.
I have found it to be very useful since working in Chromium, where it is
the only way to expose chosen ALSA devices to web applications.
A temporary buffer is required to null-terminate the string. I see no
use of alloca() in the code, presumably to avoid unbounded stack size.
So memory is allocated on the heap.
Signed-off-by: Mark Hills <mark@xwax.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Harald van Dijk [Tue, 16 Jun 2020 17:53:57 +0000 (18:53 +0100)]
pcm: dmic: assembly: add x32 support.
x32 is the x86_64 ABI that uses 32-bit pointers, so requires loading
addresses into edi/esi/ebx rather than rdi/rsi/rbx.
Note that instructions such as movl %eax, (%rdi) do not require
updating, as loading an address into %edi zeroes the high bits, causing
the full %rdi register to hold a valid address.
Signed-off-by: Harald van Dijk <harald@gigawatt.nl> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Feature 'variable periodsize' allows to extend user period size up to
buffer_size/2 independent of slave period. On enlargement of the settings
for period_time.max and period_size.max the setting for openmax
was not updated.
This lead to the effect, that if the slave period itself had openmax
set it was still set on the extended size. Configuration of a period
matching half buffer size was thus rejected.
Example for failure: period size of 384 (half buffer size) is requested
which is rejected and rounded down to 352:
PERIOD_SIZE: [32 352]
BUFFER_SIZE: [64 768]
When correctly applying the openmax setting:
PERIOD_SIZE: [32 384]
BUFFER_SIZE: [64 768]
Signed-off-by: Andreas Pape <apape@de.adit-jv.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
John Keeping [Tue, 16 Jun 2020 18:29:30 +0000 (19:29 +0100)]
control: ctlparse - use type-specific bound on element count
Using a fixed bound of 128 means that too many values may be set for an
INTEGER64 type and that any elements past 128 are out of reach for BYTE
type controls.
Derive the maximum number of elements from the type so that the full
range is parsed for all types.
Signed-off-by: John Keeping <john@metanate.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
pcm: Fix memory leak at snd_pcm_new when THREAD_SAVE_API is defined
The pthread_mutexattr_t object should be destroyed by calling
pthread_mutexattr_destroy(), otherwise it may cause a potential
memory leak due to the different implement of pthread_mutexattr_init()
Signed-off-by: chunxu.li <chunxuxiao@gmail.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>