pthread_cleanup_push() takes a function pointer for void (void *).
Although it may work in most cases, we shouldn't pass an incompatible
function pointer there, as some old gcc complains:
alsa.c:560: warning: initialization from incompatible pointer type
alsa.c:562: warning: initialization from incompatible pointer type
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The local header file named as "signal.h" causes mysterious compile
error when built with an old glibc.
signal.h:27: error: conflicting types for 'sin_generator_init'
./signal.h:27: error: previous declaration of 'sin_generator_init' was here
signal.h:28: error: conflicting types for 'sin_generator_next_sample'
./signal.h:28: error: previous declaration of 'sin_generator_next_sample' was here
....
This turned out to be the conflict of signal.h; namely, pthread.h that
is included before our local signal.h also includes "pthread.h".
Since our local "signal.h" has a higher priority, it gets loaded
instead of the expected pthread's one. Then we load it again, and it
screws up.
Although it's basically a bug of pthread, it's anyway not good to have
a header file conflicting with the standard header file. So, let's
name it more explicitly as specific to BAT, bat-signal.h, for avoiding
such a conflict.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Missing include became apparent when -O3 was not specified.
Added the header to remove error messages during debug compile.
Signed-off-by: Caleb Crome <caleb@crome.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add more information about BAT utility, including design intent,
principles, use mode, hardware connection, options, example and
return value.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Use dynamic temp file instead of fixed temp file to store recorded
wav data, for better security.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
1. Change comment strings to make the descriptions more clear;
2. Add indent for option lines that have no indent;
3. Use a const string instead of argv[0] as program name.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Use colon instead of comma to separate frequency parameters, for
in several locale comma may be handled as decimal point.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Cutting down 6 message strings to 2, as translators need to work
on each different variant.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
cross compilers are passed via path may not be a gcc based cross
compiler in such cases this check fails and try's to force gcc based
cross compiler detection, This code is a convenience that limits the
build system.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add Makefile and configures that enable BAT on alsa-utils
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@intel.com>
Signed-off-by: Bernard Gautier <bernard.gautier@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add functions that detecting signal frequency through spectrum
analyzing.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@intel.com>
Signed-off-by: Bernard Gautier <bernard.gautier@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add functions that converting audio samples to double data for analysis,
and functions that converting float data to audio samples for playback.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@intel.com>
Signed-off-by: Bernard Gautier <bernard.gautier@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add function that generates sine waveform through math lib.
The waveform can be used as source for playback or analysis.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@intel.com>
Signed-off-by: Bernard Gautier <bernard.gautier@intel.com>
Signed-off-by: Caleb Crome <caleb@crome.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add functions as main loop of playback thread and record thread.
The functions access pcm hardware through ALSA APIs.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@intel.com>
Signed-off-by: Bernard Gautier <bernard.gautier@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add common definitions of macros and data structures; Add functions
that used by multiple components, such as wav file reading and writing.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@intel.com>
Signed-off-by: Bernard Gautier <bernard.gautier@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add main entrance, command line parsing, parameter initiating and
thread initiating functions for BAT.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@intel.com>
Signed-off-by: Bernard Gautier <bernard.gautier@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
With RemainAfterExit=true, we can manage both save and restore of the
card state in a single unit file. This will fix also the case where
systemd reloads the service; with two individual units, it will
restore the previous state before saving, and may lead to inconsistent
state suddenly.
Also fix alsa-state.service as well to make both start and stop
working in a simpler way.
Bugzilla: https://bugzilla.novell.com/show_bug.cgi?id=929619
Signed-off-by: Takashi Iwai <tiwai@suse.de>
When recording or playing back audio in a format where the number of
significant bits is less than the physical width (e.g. S24_LE), the VU
meter code needs to consider the number of significant bits in the samples
rather than the physical sample width (e.g. 24 vs 32 bits). Otherwise the
resulting VU meter display will be far too low and it will just indicate
0% all the time.
Tested with a device supporting the S24_LE format.
Signed-off-by: Ricard Wanderlof <ricardw@axis.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
arecord removes a file before writing into it. It's not
appropriate in some cases. For example, if you a pass
a symlink to a file, then the symlink will be removed
while the user expects to record into the symlink's target.
Another case is recording into the device file. Some
modems provide a tty device file as a voice device.
And it's not possible to write into it under root with
arecord, because it removes the device file.
So check the type of a file before writing into it and
remove only regular files.
Signed-off-by: Alexander Volkov <a.volkov@rusbitech.ru>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The -c and -s options needed to be provided in a specific order for the -s option to work correctly.
This pulls the speaker option check outside of the option parsing so that all the options have been parsed before checking to see if the parameter to -s is correct.
Signed-off-by: Ken Benoit <kbenoit@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
With alsa-restore.service and alsa-store.service, systemd invokes
alsactl at boot and shutdown times. When this is invoked on a system
without sound cards, it results in an ugly error message from alsact
/usr/sbin/alsactl: save_state:1590: No soundcards found...
return code is "19"
Add ConditionPathExistsGlob checks of /dev/snd/control* devices for
avoiding unnecessary invocations of alsactl on such a system.
Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=940950
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The include and library paths shouldn't be across the build tree.
The installed alsa-lib must have the UCM support for building the
stuff here in alsa-utils repo correctly.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add a command line tool that will parse topology text files and convert to the binary
topology data as used by the kernel.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Allow generated signals (sine and noise) to have a specified signal scale
instead of using hardcoded limits of 80%. This can be handy for debugging, ie
when analysing clipping issues with audio drivers.
Signed-off-by: Julian Scheel <julian@jusst.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
readlink does not guarantee that its result string is nul-terminated.
Instead, increase the buffer by one byte to make sure that we can
add '\0' at the end.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
When aplay is invoked to play from stdin, it can't be terminated by
normal signals like SIGTERM or SIGINT. It's because our signal
handler tries to trap as much as possible while the stalling point is
not in the PCM loop but rather the file I/O.
For fixing this, leave our signal handler once when a signal is
received and snd_pcm_abort() is called. At the next hit, it shall be
handled normally.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
... otherwise it overwrites a zero size file. Also add a check of
zero size file in the update procedure, too.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
According to kernel code (snd_ctl_elem_init_enum_names() in
sound/core/control.c), the maximum length of item name is 63 characters
(+ 1 terminator = 64 bytes). But current amixer implementation
uses 40 bytes. This causes name truncation and fail to operation.
This commit fixes this bug by expanding the length of local variables.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
If alsa-lib have been compiled with --disable-ucm, alsaucm can't be built.
Detection is dynamic, no configure command line option is available for now.
Signed-off-by: Matthieu Crapet <Matthieu.Crapet@ingenico.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
We now enable more outputs than just the main speaker, so update
the basic rules to reflect the actual situation.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
So far amixer allows some unexpected suffix and assumes as a raw
absolute value without returning an error. This is rather dangerous,
e.g. user might not notice that a completely wrong value was set when
the command line included a typo.
This patch makes the parser a bit more strict: it doesn't allow any
longer invalid suffixes, instead either returns an error or skips the
invalid value, depending on the operation mode.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This reverts commit 8aa13eec80.
The semantics for pcm_read() and pcm_readv() was changed, but the
callers expect the exact frame count as requested. It's possible
to fix callers, but the fix is more complicated than to revert the
change. Note that '-d' processing was broken in some cases.
Note: The reverted commit allows that the return value might be
greater than requested (see the first condition in read routines).