Commit graph

1310 commits

Author SHA1 Message Date
Lu, Han
f51cb7212a alsabat: add tinyalsa support
Use "configure --enable-alsabat-backend-tiny" for alsabat to use
tinyalsa as backend lib. On a system that has both ALSA and tinyalsa
installed, alsabat will use ALSA library by default.
The intention is for alsabat to run on tinyalsa platforms such as
Android or some Internet of Things(IoT) devices.

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-23 17:51:22 +01:00
Lu, Han
986db20331 alsabat: move alsa process to a single block
Move all alsa callings to a single block (alsa.c), so other blocks
such as the main structure, the signal process and the data analysis
modules will be independent to alsa, and new modules such as a
tinyalsa interface can be easily embedded into alsabat.

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-23 17:51:22 +01:00
Lu, Han
c49a6180c8 alsabat: use general data generator function
Use general data generator to replace local function, so other
modules can reuse the data generator rather than re-implement it.

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-23 17:51:21 +01:00
Lu, Han
eac9b149b4 alsabat: clean return value for playback and capture threads
Remove unnecessary prints in playback and capture threads, and replace
the return value "0" with error code for convenience of maintaining.

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-23 17:51:21 +01:00
Lu, Han
2c37a6f9c4 alsabat: use general function for wav header update
In playback thread, use general function update_wav_header()
to replace a bunch of code, so the structure is cleaner and
no need to define variable "wav".

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-23 17:51:21 +01:00
Lu, Han
241d7fc1bb alsabat: refactoring alsa capture thread
Refactoring ALSA capture thread:
  1. Move file open/seek operations to sub function, so all file
  processes are now on a single function (read_from_pcm_loop()), so
  the structure is more reasonable, the function API is simplified
  and no need file cleanup in thread loop.
  2. Replace the wav header processing lines with a general function
  (update_wav_header()), which can be reused in other sections.
  3. Add pthread_exit() for thread to exit safely in single line mode,
  and correct comment.

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-23 17:51:21 +01:00
Jaroslav Kysela
c5b022e621 alsactl: init/ca0106, init/hda - use CTL{values} instead CTL{value}
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2016-03-22 16:54:05 +01:00
Jaroslav Kysela
3ad94da0c8 alsactl: remove debug line in set_ctl_values()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2016-03-22 16:50:33 +01:00
Lu, Han
98de9f7905 alsabat: use variable for thread return value
Use variable instead of 0/1 to indicate the return value of
playback and capture threads.

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-21 18:04:36 +01:00
Lu, Han
f2f6583ee6 alsabat: fix fopen and messages
All files should be opened in either "rb" or "wb" in current
usage.
Remove incorrect and unneccesary prints.

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-21 18:04:03 +01:00
Lu, Han
bd6c706606 alsabat: fix misusing of errno
Preserve errno value before use, since the value might be
changed by another library call.
Add "#include <errno.h>" and remove redundant include.

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-21 18:03:12 +01:00
Lu, Han
f84c15ca1d alsabat: add bash test script
Add bash script for alsabat feature test. It covers basic alsabat
features, including waveform and wav file generate, playback,
capture and analysis with configurable parameters under different
work modes. (loopback, single line, standalone and local mode)
Usage examples:
        alsabat-test.sh
        alsabat-test.sh plughw:1,0
        alsabat-test.sh plughw:1,0 plughw:1,0

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-15 09:59:56 +01:00
Lu, Han
72800ad6bd alsabat: add standalone mode
Add support for standalone mode where alsabat will run on a
different machine to the one being tested.
In standalone mode, the alsabat just generates, playback and
capture sound data like in normal mode, but does not analyze.
The alsabat being built without libfftw3 support is always work
in standalone mode.
The alsabat in normal mode can also bypass data analysis using
option "--standalone".

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-15 09:59:26 +01:00
Lu, Han
333cd85d7d alsabat: add default device name for playback and capture
Add default name for the playback and capture devices, in case
they were not set by user through '-D', '-P' or '-C' options.
Previously, if no device be specified, the alsabat will start
a playback thread and a capture thread, and then exit the
threads with error log.
If only one of playback and capture is specified, the alsabat
will work on single line mode as before, where only one thread
(playback or capture) will be started.
The patch was tested on Ubuntu and Chrome OS.

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-15 09:59:09 +01:00
erwin
b5c0660230 aplay/arecord: handle parsing errors of parameter values
when a user enters a command, he expects his command to be executed
as specified or aborted if it is impossible to fulfill his request

right now a command like "arecord -d hw:1,0 --max-file-time 1h recording.wav"
will happily record something and exit without error status while the resulting
recording contains definitely not what the user requested

to fix this, the patch handles the number parsing function's error channel
and checks whether the parsed number has any trailing characters

Signed-off-by: erwin <nebelbank@posteo.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-11 16:47:17 +01:00
Martin Koegler
ccc108fb83 aconnect: Show sequencer sound card numer/PID via aconnect
rawmidi devices expose the card number via IOCTLs, which allows to
find the corresponding device in sysfs.

The sequencer provides no identifing data. Chromium works around this
issue by scanning rawmidi as well as sequencer devices and matching
them by using assumtions, how the kernel register sequencer devices.

This patch adds support for displaying the sound card number/PID to
aconnect.

Signed-off-by: Martin Koegler <martin.koegler@chello.at>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-09 09:15:43 +01:00
Lu, Han
380c9fa444 alsabat: truncate sample frames for faster FFT analysis
Truncate the sample frames to powers of 2, since the FFTW algorithm
runs especially fast in this case, and other sizes may be computed
by means of a slow, general-purpose algorithm.
In my test environment applying the patch, a sound clip of 33072
frames is cut off to 32768 frames before analysis, and the time
cost is reduced from 6.128s to 0.224s.

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-01 10:31:00 +01:00
Takashi Iwai
84fa5bf945 Update .gitignore
bat was renamed to alsabat.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-02-03 08:50:28 +01:00
Lu, Han
9fa7f6fd06 alsabat: rename to avoid naming conflict
alsa-utils as well as bareos-bat (as well a some Bacula packages)
all contain a program called /usr/bin/bat, which causes conflicts on
various distributions ("basic audio tester" vs "bareos administration
tool"("bacula administration tool")).
Rename to avoid conflict.

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-02-03 08:49:53 +01:00
Vinod Koul
18d5f52a61 amixer: skip showing asoc tlv byte controls
ASoC TLV Byte controls are very large size controls so we should add new
options for these. So skip dumping contents for these.

$amixer -c0 cget numid=16
numid=16,iface=MIXER,name='mdl params'
  ; type=BYTES,access=-----RW-,values=30336
  ; ASoC TLV Byte control, skipping bytes dump

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-01-29 07:26:56 +01:00
Jaroslav Kysela
d633469c9d alsa-info.sh: add man page 2016-01-13 09:47:28 +01:00
Takashi Iwai
ed0cce1b60 bat: Don't pass incompatible function pointers to pthread_cleanup_push()
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>
2015-11-09 14:09:50 +01:00
Takashi Iwai
3bf8e79c3b bat: Avoid local signal.h file
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>
2015-11-09 14:04:11 +01:00
Jaroslav Kysela
d5a682946d Release v1.1.0
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2015-10-27 17:34:26 +01:00
Jaroslav Kysela
47e668f453 bat: add all headers to noinst_HEADERS
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2015-10-27 17:32:51 +01:00
Jaroslav Kysela
bc352dfba9 bat: don't link all binaries with fftw library, add missing header
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2015-10-27 17:15:58 +01:00
Jaroslav Kysela
9b757e3a64 configure.ac: check for fftw3/m(sqrtf)/pthread only when BAT is enabled 2015-10-27 16:09:30 +01:00
Caleb Crome
0960094905 BAT: Add missing locale.h header
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>
2015-10-24 09:43:26 +02:00
Lu, Han
73f9dd149e BAT: Add man page
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>
2015-10-21 09:29:52 +02:00
Lu, Han
2abee9c5b4 BAT: Use dynamic temp file
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>
2015-10-20 11:06:24 +02:00
Lu, Han
5a48606d94 BAT: Change comments and interface of usage()
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>
2015-10-20 11:06:24 +02:00
Lu, Han
8c910830f0 BAT: Use colon instead of comma for separation
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>
2015-10-20 11:06:24 +02:00
Lu, Han
2d0a124674 BAT: Remove redundant message strings
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>
2015-10-20 11:06:23 +02:00
Mike Frysinger
c0130c8ec2 build: Do not try to detect cross-compiler
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>
2015-10-08 19:13:47 +02:00
Takashi Iwai
6fb0f5b6d5 Add bat binary to .gitignore
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-02 12:47:25 +02:00
Takashi Iwai
2f52d5bce6 Add compile to .gitignore
Another junk.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-02 12:47:03 +02:00
Lu, Han
226ad884d2 BAT: Add Makefile and configures
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>
2015-10-02 12:42:03 +02:00
Lu, Han
d727c9d90e BAT: Add spectrum analysis functions
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>
2015-10-02 12:42:03 +02:00
Lu, Han
6c4c5e51fa BAT: Add converting functions
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>
2015-10-02 12:42:02 +02:00
Lu, Han
34e9ae911f BAT: Add signal generator
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>
2015-10-02 12:42:02 +02:00
Lu, Han
05850912b8 BAT: Add playback and record functions
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>
2015-10-02 12:42:01 +02:00
Lu, Han
cba9050edf BAT: Add common definitions and functions
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>
2015-10-02 12:42:01 +02:00
Lu, Han
c7e0c35661 BAT: Add initial functions
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>
2015-10-02 12:42:00 +02:00
Takashi Iwai
7d6673cc13 alsactl: Manage both save and restore in a single unit
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>
2015-09-29 17:54:17 +02:00
Ricard Wanderlof
cd1bb5f4a7 aplay: fix VU meter for S24_LE etc formats
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>
2015-09-23 16:28:33 +02:00
Alexander Volkov
5f0fc49a3a arecord: Remove only regular files
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>
2015-09-23 15:27:40 +02:00
Ken Benoit
4482cc7cfe speaker-test: fix option ordering
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>
2015-09-17 21:49:09 +02:00
Takashi Iwai
0e864e1a3a alsactl: Add path condition to alsa-store and alsa-restore services
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>
2015-08-10 14:42:24 +02:00
Takashi Iwai
ff9b070d9c alsaucm: Drop localbuild hacks
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>
2015-08-04 18:26:40 +02:00
Takashi Iwai
a99d4273b3 Add topology/alsatplg to .gitignore
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-08-04 17:46:42 +02:00