Takashi Iwai [Mon, 5 Mar 2018 15:10:42 +0000 (16:10 +0100)]
speaker-test: Refactor the tone-generator codes
There are many redundant open codes in speaker-test for performing the
similar things, and especially the tone generator codes are ugly.
Let's clean up a bit. This patch combines all open-codes into a
single common helper with the callback for generating the tone.
Ikey Doherty [Tue, 12 Dec 2017 13:32:34 +0000 (13:32 +0000)]
alsactl: Only start restore service when asoundrc file exists
This solves the chicken and egg problem on fresh installations whereby
the alsa state file does not yet exist, and alsa-restore unit attempted
to launch without first having a state file.
Jussi Laako [Thu, 7 Dec 2017 11:57:14 +0000 (13:57 +0200)]
aplay: Adjust sample rate limits to support newer hardware
There are number of devices that support up to 384 kHz sampling rate and
some devices up to 768 kHz sampling rate. This patch increases sanity
check limit to 768k in order to support testing of such hardware.
Signed-off-by: Jussi Laako <jussi@sonarnerd.net> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Daniel Baluta [Tue, 8 Aug 2017 22:06:00 +0000 (01:06 +0300)]
aplay: Fix playback for small raw files
This fixes a bug when trying to play files with size
smaller than maximum supported header size.
Lets have a look at the following example:
$ aplay -s 2 sample.raw
-> playback_go(fd = 10, loaded = 26, count = 2, name="sample.raw")
--> l = loaded = 26
--> c = count - written = 2
--> c -= l = 2 - 26 = -24
---> r = safe_read(fd, audiobuf + 26, -24)
---> r = -1, EXIT_FAILURE
In this case we have already 'loaded' from the input file more
bytes that we need to send to pcm device. So, we need to adjust
the number of bytes loaded and avoid reading a negative number
of bytes.
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
aplay: interrupt streaming via signal in voc_pcm_write
aplay/arecord (alsa-utils v1.1.2) cannot interrupt streaming
via CTRL-C. Fixed the issue by properly handling 'in_aborting'
flag in appropriate functions.
Liam Girdwood [Fri, 9 Jun 2017 15:33:42 +0000 (16:33 +0100)]
topology: delete output file if parsing fails.
Currently the binary output file is left when parsing fails. This confuses
GNU Make if the parsing fails and causes the compilation to partially
complete.
BIOS vendors typically reuse the same definitions between different
platforms and expose the relevant hardware by changing the value of
the _STA method.
For example on the Asus T100HA, there are 3 HID values for audio
codecs in the DSDT table but two have a zero status and will be
ignored by the ACPI subsystem.
This information is very useful to figure out which HIDs/quirks need
to be supported. Add log to alsa-info.sh to only expose non-zero
results of the ACPI _STA method, e.g.
!!ACPI Device Status Information
!!---------------
Some manufacturers don't provide useful information for Manufacturer
and Product Name but instead use Board Vendor and Board Name fields,
add them to alsa-info log
Paul Menzel [Tue, 8 Jul 2014 07:23:06 +0000 (07:23 +0000)]
alsactl: Remove standard output definition in systemd unit
`/lib/systemd/system/alsa-restore.service` specifies
`StandardOutput=syslog`. This overrides the `DefaultStandardOutput`
setting from `/etc/systemd/system.conf`, which the system administrator
can use to specify how output gets logged. In particular, the sysadmin
may want output to go to the journal, or to syslog, or nowhere at all [1].
This patch removes the definition entirely, so the units can use the
system default.
Upstream the patch from the Debian package [2].
[1] https://bugs.debian.org/741123
"systemd services should not use StandardOutput=syslog; should rely
on DefaultStandardOutput"
[2] https://sources.debian.net/src/alsa-utils/1.1.2-1/debian/patches/systemd_standardoutput.patch/
Antonio Ospite [Fri, 9 Dec 2016 13:02:29 +0000 (14:02 +0100)]
configure.ac: fix the check for xmlto availability
The same $xmlto variable is used both in AC_ARG_ENABLE and
AC_CHECK_PROG, but the latter is not setting a value to it when the
program is not found.
These two facts result in the "yes" value from the AC_ARG_ENABLE macro
to be still kept in the variable when the program is not found by
AC_CHECK_PROG, causing USE_XMLTO to be always set, finally resulting in
a build failure in case the xmlto program is not actually in the PATH.
As possible fix could have been to set "no" as a value in AC_CHECK_PROG
when program is not found.
However using two separate variables is more explicit, so fix the issue
this way.
Signed-off-by: Antonio Ospite <ao2@ao2.it> Signed-off-by: Takashi Iwai <tiwai@suse.de>
The channel selection currently does not work properly when a channel
map control is provided but no manual channel map was explicitly
requested with "-m".
For example, the CEA/HDMI 6ch (surround 5.1) map is:
FL, FR, LFE, FC, RL, RR.
Tested command: speaker-test -D hdmi -c 6 -t wav
Speaker-test tries to play channels in this following order:
0 - Front Left
3 - Front Center
1 - Front Right
5 - Rear Right
4 - Rear Left
2 - LFE
But wav file played on associated speakers are not aligned. Here are
the real files played:
0- /usr/share/sounds/alsa/Front_Left.wav => OK
3- /usr/share/sounds/alsa/Rear_Right.wav => OK
1- /usr/share/sounds/alsa/Front_Right.wav => OK
5- /usr/share/sounds/alsa/Rear_Center.wav => KO
4- found file /usr/share/sounds/alsa/Front_Center.wav => KO
2- /usr/share/sounds/alsa/Rear_Left.wav => KO
Issue is that associated wav files ordering is reworked only if
channel_map_set variable is set.
Fix consists in allowing wavs re-ordering if a channel mapping as been
get or set, i.e. channel_map is not null.
Keqiao, Zhang [Fri, 26 Aug 2016 15:37:55 +0000 (23:37 +0800)]
alsabat: add system power management S3 test
Support audio pause/resume for playback and capture. The user can
pause alsabat playback/capture threads by sending a signal. The patch
provides a method for QA to quick test audio during system s3.
Keqiao, Zhang [Fri, 26 Aug 2016 15:37:54 +0000 (23:37 +0800)]
alsabat: fix alsabat -86 error
alsabat reports -86 error when system suspend and resume. Check the
return value of read_to_pcm() and write_to_pcm(), when -x8 err is
detected, do resume and wait for read/write to pcm to complete.
Focus Luo [Mon, 22 Aug 2016 16:16:49 +0000 (00:16 +0800)]
alsabat: automation test scripts
This patch includes automated test scripts for linux audio driver
based on alsa-lib interface by using alsabat as test tool.
It supports analog and display(HDMI/DP) audio test.
The package needs the alsa-utils, alsa-lib installed environment.
Signed-off-by: Focus Luo <focus.luo@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Clemens Ladisch [Sat, 13 Aug 2016 14:41:23 +0000 (16:41 +0200)]
amidi: ignore not only Active Sensing but also Clock bytes
Active Sensing messages are sent by many devices in the background and
would only interfere with the actual messages that amidi is supposed to
capture. Therefore, amidi ignores them by default. However, there are
also devices that send Clock messages with the same problem, so it is
a better idea to filter them out, too.
Reported-by: Martin Tarenskeen <m.tarenskeen@gmail.com> Reviewd-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Tested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Lu, Han [Wed, 8 Jun 2016 19:42:49 +0000 (03:42 +0800)]
alsabat: add noise detection
Alsabat reports error when noise above threshold be detected.
Use either of the options below to designate the threshold. (e.g.
if the ratio of noise to signal is 5%, the snr is about 26dB.)
--snr-db <value in dB>
--snr-pc <value in %>
The noise detection is performed in time domain. On each period
of the sine wave being analyzed, alsabat substracts a clean sine
wave from the source, calculates the RMS value of the residual,
and compares the result with the threshold. At last, alsabat
returns the number of periods with noise above threshold. 0 is
returned when the source is clean.
Signed-off-by: Lu, Han <han.lu@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Lu, Han [Wed, 8 Jun 2016 19:42:48 +0000 (03:42 +0800)]
alsabat: add a single channel sine wave generator
Add function generate_sine_wave_raw_mono(). It serves as a single
channel sine wave generator, to provide data for calculation (e.g.
for noise analysis).
The function is similar to generate_sine_wave(), but a lite revision.
It has no dependency on bat channels and target frequency, no malloc
inside, no data conversion from float to integer samples, and supports
one channel only.
Signed-off-by: Lu, Han <han.lu@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Lu, Han [Wed, 8 Jun 2016 19:42:47 +0000 (03:42 +0800)]
alsabat: add channels parameter for adjust_waveform()
The function adjust_waveform() is a component of generate_sine_wave(),
and depended on bat->channels parameter. Add parameter "channels" to
remove the dependency, and then adjust_waveform() can be applied on
other use cases, e.g. a single channel sine wave generator.
Signed-off-by: Lu, Han <han.lu@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Lu, Han [Wed, 8 Jun 2016 19:42:46 +0000 (03:42 +0800)]
alsabat: align the data type on float
Aligning the data type of fftw analyzer, sample converter and other
components on float, because:
1. avoid unnecessary data type conversion;
2. using float is more efficient than using double;
3. the extra double accuracy is not required.
Signed-off-by: Lu, Han <han.lu@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
vivian,zhang [Fri, 3 Jun 2016 02:05:08 +0000 (10:05 +0800)]
alsabat: add round trip audio latency test
Audio latency is the time delay as an audio signal passes through
a system. There are many kinds of audio latency metrics. One useful
metric is the round trip latency, which is the sum of output latency
and input latency.
The measurement step works like below:
1. Listen and measure the average loudness of the environment for
one second;
2. Create a threshold value 16 decibels higher than the average
loudness;
3. Begin playing a ~1000 Hz sine wave and start counting the samples
elapsed;
4. Stop counting and playing if the input's loudness is higher than
the threshold, as the output wave is probably coming back;
5. Calculate the audio latency value in milliseconds.
Lu, Han [Sun, 17 Apr 2016 01:26:45 +0000 (09:26 +0800)]
alsabat: add terminate status check for capture thread
In loopback test, alsabat use pthread_join(pthread_t thread, **retval)
to wait for the capture thread to terminate. If the capture thread was
canceled, PTHREAD_CANCELED is placed in *retval, and the access to the
**retval will fail. Add status check to prevent illegal access to the
**retval.
Signed-off-by: Lu, Han <han.lu@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
David Fries [Thu, 14 Apr 2016 04:32:46 +0000 (23:32 -0500)]
aplay: fix lurking capture file overwrite bug
If -d was given to arecord while commit 8aa13eec80eac312e4b99423909387660fb99b8f (now reverted) was in effect,
the last read would be shorter than the chunk size, but pcm_read would
read and return the chunk size, the samples were discarded, and
capture() continued in a loop because count never reached 0. arecord
opens a new file each loop iteration, if arecord is dynamically naming
files, --use-strftime option or beyond the wave 2GB limit, this will
generate a series of header only wave files. If the file is unique
the originally recorded data is lost and it will continue overwriting
the same file with a header only wave file.
While the current pcm_read can't fail (it can exit), it is better to
just fix this lurking bug in case it is "fixed" again.
Lu, Han [Wed, 23 Mar 2016 07:52:47 +0000 (15:52 +0800)]
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>
Lu, Han [Wed, 23 Mar 2016 07:52:46 +0000 (15:52 +0800)]
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>
Lu, Han [Wed, 23 Mar 2016 07:52:43 +0000 (15:52 +0800)]
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>
Lu, Han [Wed, 23 Mar 2016 07:52:42 +0000 (15:52 +0800)]
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>
Lu, Han [Tue, 15 Mar 2016 03:18:54 +0000 (11:18 +0800)]
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>
Lu, Han [Tue, 15 Mar 2016 03:18:53 +0000 (11:18 +0800)]
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>
Lu, Han [Tue, 15 Mar 2016 03:18:52 +0000 (11:18 +0800)]
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>
erwin [Fri, 11 Mar 2016 11:40:30 +0000 (11:40 +0000)]
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
Martin Koegler [Tue, 8 Mar 2016 22:06:47 +0000 (23:06 +0100)]
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>
Lu, Han [Mon, 29 Feb 2016 02:33:45 +0000 (10:33 +0800)]
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>
Lu, Han [Wed, 3 Feb 2016 06:20:33 +0000 (14:20 +0800)]
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>
Takashi Iwai [Mon, 9 Nov 2015 13:09:50 +0000 (14:09 +0100)]
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
Takashi Iwai [Mon, 9 Nov 2015 13:04:11 +0000 (14:04 +0100)]
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.
Lu, Han [Tue, 20 Oct 2015 08:45:47 +0000 (16:45 +0800)]
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>
Mike Frysinger [Thu, 8 Oct 2015 16:14:05 +0000 (12:14 -0400)]
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>
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.
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.
Alexander Volkov [Mon, 21 Sep 2015 13:05:57 +0000 (16:05 +0300)]
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>