Fix a variable uninitialized issue, adding the initialized assignment to fix it.
Signed-off-by: Zhang Keqiao <keqiaox.k.zhang@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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>
This introduces read_header function which tries
to read the header of an audio file in order to determine
its type.
This has the following effects:
(1) makes code easier to read
(2) don't abort if file size is less than expected header
(2), allows us to play small files with size smaller than any
supported audio file headers.
Suggested-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-s --samples allows aplay to be used for playback/capture a given
number of samples per channel
Signed-off-by: Ion-Horia Petrisor <ion-horia.petrisor@nxp.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Fix bug in arecord --max-file-time where the file size could overflow
32 bits.
Signed-off-by: Scott Gilliland <scott.gilliland@gatech.edu>
Acked-by: John Sauter <John_Sauter@systemeyescomputerstore.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
verbose, compile and output options all have a parameter.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Write can return less then requested bytes, but we treat this as
an error thus ending up with confusing error messages.
Fix this by introducing xwrite helper, which makes sure all bytes
are written or an error is returned.
With this patch an usecase where disk is filled by recording will
print:
$ /mnt/msc/audio.wav: No space left on device
instead of random messages like:
$/mnt/msc/audio.wav: No such file or directory
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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.
$ more /sys/bus/acpi/devices/10EC*/status
::::::::::::::
/sys/bus/acpi/devices/10EC3270:00/status
::::::::::::::
15
::::::::::::::
/sys/bus/acpi/devices/10EC5640:00/status
::::::::::::::
0
::::::::::::::
/sys/bus/acpi/devices/10EC5648:00/status
::::::::::::::
0
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
!!---------------
/sys/bus/acpi/devices/10EC3270:00/status 15
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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
Example on Intel NUC:
!!DMI Information
!!---------------
Manufacturer:
Product Name:
Product Version:
Firmware Version: KYSKLi70.86A.0042.2016.0929.1933
Board Vendor: Intel Corporation
Board Name: NUC6i7KYB
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
`/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/
Signed-off-by: Paul Menzel <paulepanter@users.sourceforge.net>
CC: Jordi Mallach <jordi@debian.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The code releasing the each card object may access to NULL when a
bogus count is given. Add a NULL check just to make sure.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Define a USE_RST2MAN conditional so that, when available, rst2man can be
used to generate man pages from reStructuredText source files.
The code follows what is done to check for xmlto.
On Debian system, the rst2man executable is provided by python-docutils
or python3-docutils.
Signed-off-by: Antonio Ospite <ao2@ao2.it>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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.
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
If PCM is paused and then we do system supend-resume, the stream throws
error(EBADF) when stream is paused released.
Check the pcm state before pause/release and if stream is suspended,
call snd_pcm_resume to resume the stream.
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This patch adds a new option to amidi tool: sysex-interval.
It adds a delay (in milliseconds) in between each SysEx message - it searches
for a 0xF7 byte.
This is very useful when sending firmware updates to a remote device via SysEx
or any other use that requires this delay in between SysEx messages.
`amidi' manual was updated with an example usage as well.
Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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.
Signed-off-by: Keqiao, Zhang <keqiao.zhang@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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.
Write PCM device error: Streams pipe error(-86)
Read PCM device error: Streams pipe error(-86)
*** Error in alsabat: double free or corruption (out): 0x00007fb438001810 ***
Signed-off-by: Keqiao, Zhang <keqiao.zhang@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This patch includes the reference asound.state config files
on Intel Skylake, Broadwell and Hsawell platforms
Signed-off-by: Focus Luo <focus.luo@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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>
The timeout is not supposed to expire when ignored messages are
received. This cannot be handled with the poll() timeout, so add
a separate timer.
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>
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>
The compilation fails due to multiple defination of snr_is_valid
common.o: In function `snr_is_valid':
bat/common.h:99: multiple definition of `snr_is_valid'
bat.o:bat/common.h:99: first defined here
signal.o: In function `snr_is_valid':
bat/common.h:99: multiple definition of `snr_is_valid'
bat.o:bat/common.h:99: first defined here
latencytest.o: In function `snr_is_valid':
bat/common.h:99: multiple definition of `snr_is_valid'
bat.o:bat/common.h:99: first defined here
analyze.o: In function `snr_is_valid':
bat/common.h:99: multiple definition of `snr_is_valid'
bat.o:bat/common.h:99: first defined here
alsa.o: In function `snr_is_valid':
bat/common.h:99: multiple definition of `snr_is_valid'
bat.o:bat/common.h:99: first defined here
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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>
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>
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>
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>
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.
Signed-off-by: Zhang Vivian <vivian.zhang@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Fix a possible memory leak in generate_sine_wave(). Memory free was
ignored when the function return an error.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add buffer size and period size settings in alsabat.
With -E and -B options, alsabat performs the test with
specified buffer size and period size
Signed-off-by: Zhang Vivian <vivian.zhang@intel.com>
Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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>
If -d was given to arecord while commit
8aa13eec80 (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.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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>
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>
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>