Commit graph

89 commits

Author SHA1 Message Date
Samanta Navarro
825d1d6359 treewide: fix typos in manual pages
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-10-06 13:07:29 +02:00
Michael Forney
62a765087e Avoid pointer arithmetic on void *
The pointer operand to the binary `+` operator must be to a complete
object type.

Signed-off-by: Michael Forney <mforney@mforney.org>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-02-10 12:38:52 +01:00
Rosen Penev
80fd81f4a8 treewide: Fix printf formats
Found with cppcheck

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-11-20 19:46:17 +01:00
Rosen Penev
66e9a81609 treewide: Fix wrong formats on 32-bit
uint64_t evaluates to unsigned long long on 32-bit, not unsigned long.
Use the proper formats.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-11-20 19:45:57 +01:00
Takashi Sakamoto
7d7c988e05 axfer: handle -ETIMEDOUT before non-block I/O operation
When running for IRQ-based scheduling model, transmission backend is
expected to queue PCM event in different context from the main thread.
When queueing no events during time equivalent to one period of PCM
buffer, the backend has problems.

This commit outputs report it for non-blocking operation for IRQ-based
scheduling model. The timeout is equivalent to all frames in buffer,
instead of period for safe.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-10-30 13:13:22 +01:00
Takashi Sakamoto
498ca99461 axfer: code refactoring for a helper function to wait for avail buffer space
This commit applies code refactoring for waiting PCM event queued
per period of PCM buffer in copying operation for IRQ-based scheduling
model.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-10-30 13:13:22 +01:00
Takashi Sakamoto
a07eb8e235 axfer: handle -ETIMEDOUT before handle mmap I/O operation
When running for IRQ-based scheduling model, transmission backend is
expected to queue PCM event in different context from the main thread.
When queueing no events during time equivalent to one period of PCM
buffer, the backend has problems.

This commit outputs report it for mmap operation for IRQ-based
scheduling model. The timeout is equivalent to all frames in buffer,
instead of period for safe.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-10-30 13:13:22 +01:00
Takashi Sakamoto
e5e6a7838b axfer: return ETIMEDOUT when no event occurs after waiter expiration
Although the waiter abstraction handles timeout as success, it should
report for callers to know timeout.

This commit takes the waiter to return -ETIMEDOUT when timeout expires.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-10-30 13:13:22 +01:00
Takashi Sakamoto
1c17128410 axfer: fix to return error code when a call of select(2) fails
A call of select(2) returns negative code and report errors via errno
local variable, howver current waiter implementation for select(2)
returns the negative code instead of errno.

This commit fixes it.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-10-30 13:13:22 +01:00
Takashi Sakamoto
178a1f187c axfer: return the number of file descriptors for I/O events from select(2) waiter
A call of select(2) returns error code at failure, the number of file
descriptors available I/O at success. Current implementation of
waiter abstraction for select(2) returns 0 at success and callers
can't get the number.

This commit fixes it.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-10-30 13:13:22 +01:00
Takashi Sakamoto
fbb222c9bc axfer: test: fix invalid comparison of 64 bit storage in ILP32 data type
In system V ABIs with ILP32 data model, bit shift for '1ul' can brings
undefined behaviour when the calculation result is over 32 bit width.

This commit fixes the bug.

Reported-by: Rolf Eike Beer <eike@sf-mail.de>
Reference: https://bugs.gentoo.org/681652
Reference: https://github.com/alsa-project/alsa-utils/issues/23
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-07-31 15:58:46 +02:00
Takashi Sakamoto
0bc366a15c axfer: mapper: fix parameter check for demuxer
Each container should be configured to store one saple per frame in
demuxer case. This commit fixes the bug.

Fixes: 25c8e3bebb ('axfer: add support for a mapper for multiple target')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-07-31 15:57:28 +02:00
Jaroslav Kysela
3aea4fedf9 axfer: remove unused variable warnings
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-05-27 15:37:05 +02:00
Takashi Sakamoto
0b07c560f7 axfer/test: fix uninitialized warning
This commit fixes uninitialized return value from a call of test_mux() and
text_demux() to suppress warnings below:

$ make check
...
gcc -DHAVE_CONFIG_H -I. -I../../include     -O2 -Wall -pipe -g -MT mapper-test.o -MD -MP -MF .deps/mapper-test.Tpo -c -o mapper-test.o mapper-test.c
mapper-test.c: In function ‘test_mapper’:
mapper-test.c:241:9: warning: ‘err’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  return err;
         ^~~
mapper-test.c:231:5: warning: ‘err’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  if (err < 0)
     ^

Fixes: 39d1ab8a0c: ('axfer: add a unit test for mapper interface')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-05-07 08:33:01 +02:00
Takashi Sakamoto
0248c29757 axfer/test: fix uninitialized warning
This commit fixes uninitialized return value from a call of test_vector()
to suppress a warning below.

gcc -DHAVE_CONFIG_H -I. -I../../include     -O2 -Wall -pipe -g -MT mapper-test.o -MD -MP -MF .deps/mapper-test.Tpo -c -o mapper-test.o mapper-test.c
mapper-test.c: In function ‘test_vector’:
mapper-test.c:293:6: warning: ‘err’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  int err;
      ^~~

Fixes: 39d1ab8a0c: ('axfer: add a unit test for mapper interface')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-05-07 08:32:53 +02:00
Samuel Holland
c43a62114a axfer: Declare global variables as 'extern' in header
This avoids multiple definitions of the same global variable (one in
each file that includes this header), and fixes a linking error when
compiled with -fno-common.

Fixes: 96110793b3 ("axfer: add support for a container of raw data")

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-05-07 08:30:25 +02:00
Samuel Holland
60f78865d3 axfer: Fix creation of v1.2 headers on big-endian systems
struct block_v120_format defines these members as uint8_t. On
little-endian systems, no swapping is done, and the generated block
header is fine. However, on big-endian machines, the value is swapped to
the high byte and then truncated by the assignment, causing both
bits_per_sample and samples_per_frame to be zero.

This fixes an assertion failure in container-test when later
parsing the header ["assert(*samples_per_frame > 0);" in
container_context_pre_process()].

Fixes: 4ab7510f3a: ("axfer: add support for a container of Creative Tech. voice format")

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-05-07 08:28:31 +02:00
Jaroslav Kysela
11e6de5493 xfer: fix possible minor memory leak in xfer_options_parse_args() (coverity)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-03-13 17:21:16 +01:00
Jaroslav Kysela
30f9a14a79 axfer: return back unsigned avail variable, do proper retype in xfer-libasound-irq-mmap.c
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-03-13 14:51:22 +01:00
Jaroslav Kysela
819e04c7a1 axfer: coverity fixes
- container-voc.c - out of array access
- container-voc.c - handle correctly eof
- frame_cache.c - correct memory allocation
- container.c - byte_count might be used uninitialized
- xfer-libasound-irq-mmap.c - fix avail signess
- xfer-options.c - fix potential 32-bit wrap for duration

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-03-13 14:42:42 +01:00
Takashi Sakamoto
6fdaa0c524 axfer: add missing header file of unit test to distribution
The file 'axfer/test/generator.h' is missing in distribution and brings
FTBFS for unit tests of axfer.

This commit fixes to add it.

Reported-by: Elimar Riesebieter <riesebie@lxtec.de>
Fixes: b878df1ff0: ('axfer: add unit test for container interface')
Fixes: 39d1ab8a0c: ('axfer: add a unit test for mapper interface')
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-29 16:48:00 +01:00
Takashi Sakamoto
257be19c47 axfer: allow to be compiled with glibc-2.11 or former
The program, axfer, was developed in userspace with glibc-2.28. This
userspace is mostly compliant to POSIX:2008 and some additional macros
for poll event are officially available. The glibc supports them as a
default since its v2.12 release. It will be failed to be compiled with
old glibc or the other libraries for C standard APIs.

One of the purpose of axfer is an better alternative of aplay. In a
point of the purpose, it's preferable to be compiled with the old
libraries.

This commit adds conditional macros to be compiled with libraries for
old compliance level of POSIX.

Reported-by: Jay Foster <jay@systech.com>
Fixes: fce16d9279 ('axfer: add an implementation of waiter for select(2)')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-29 16:45:51 +01:00
Takashi Sakamoto
9ed5d7c876 axfer: correct invalid usage of escape of itaric text
A dot sign is valid for a prefix of instruction.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-29 16:44:42 +01:00
Takashi Sakamoto
fb038252d4 axfer: supplement value of options for the manual of transfer subcommand
This commit supplements value of options for the manual of transfer
subcommand.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-29 16:44:35 +01:00
Takashi Sakamoto
1848b38ca9 axfer: correct message to notice that help text is implemented
Now help message is available to give help option to command line.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-29 16:44:25 +01:00
Takashi Sakamoto
827ed7d193 axfer: correct description about snoop mode of libffado
The libffado library can listen to isochronous channels to which unit on
IEEE 1394 bus transfers packets as long as the unit allows software to
read the channel from its register.

This commit corrects description about snoop mode.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-29 16:44:17 +01:00
Takashi Sakamoto
b6142611c6 axfer: fulfill section for backward compatibitity for chmap option
At present, axfer losts backward compatibility to aplay in a point of
'chmap' option.

This commit filfills a section to describe lose of backward compatibility
of chmap option.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-29 16:43:24 +01:00
Takashi Sakamoto
83bce86c26 axfer: add a section about unit test
Two unit tests are available to check internal implementation of axfer.
They perform file I/O for many times and take much time to finish.

This commit adds a section about it.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-29 16:43:09 +01:00
Takashi Sakamoto
1ad002bb2e axfer: add an explanation about advantages/issues of Timer-based scheduling model
Timer-based scheduling model has some merits against IRQ-based
scheduling model. However, as of Linux kernel v4.21, ALSA PCM interface
between kernel/userspace has a lack of some features.

This commit adds a subsection to describe it.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-07 11:51:05 +01:00
Takashi Sakamoto
87ed959f9b axfer: add an explanation about Timer-based scheduling model
This commit fulfills a subsection titled as 'Timer-based scheduling model'.

This scheduling model is introduced in a recent decade. In this model,
applications should take care of its timing to operate sampled data
according to any timer. This is an optional behaviour of runtime of
PCM substream.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-07 11:50:51 +01:00
Takashi Sakamoto
a01d54d4e2 axfer: add an explanation about IRQ-based scheduling model
This commit adds a section titled as 'SCHEDULING MODEL' and fulfill a
subsection titled as 'IRQ-based scheduling model'.

This scheduling model is for a typical applications to operate a kind of
data sampled against actual time. In this model, ALSA PCM core maintains
timing of the applications with notification of hardware by
blocking/waking up their processes. This is a default behaviour of
runtime of PCM substream.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-07 11:50:35 +01:00
Takashi Sakamoto
1c2315010c axfer: add text for compatibility loss of sw parameter in libasound backend
At present, some options for software parameters have actual effects in
cases neither mmap operation nor timer-based scheduling model is used.
For mmap operation, backward compatibility  to aplay(1) is lost.

This commit adds descriptions about it.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-02 11:25:07 +01:00
Takashi Sakamoto
0edb6ec765 axfer: fulfill manual section for libasound backend
This commit attempts to describe purpose of each option with more texts
than aplay(1).

I note that a section for scheduling model will be prepared near future.
This commit just adds a placeholder for the section.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-02 11:24:57 +01:00
Takashi Sakamoto
a0fb855e35 axfer: print help for libasound backend
This commit attempts to categorise existing options to four parts;
basics, software features, libasound plugin options and debug assistant.
These categories will assist users to get purpose of each option.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-02 11:24:47 +01:00
Takashi Sakamoto
a37703614a axfer: fulfill manual section for libffado backend
I note that libffado backend has no support for suspend/resume because
libffado has enough implementation for these features even if it exports
some symbols for them. For this backend, reception of signals for the
features brings abortion of runtime.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-02 11:24:36 +01:00
Takashi Sakamoto
7de9ddce44 axfer: print help for libffado backend
This commit adds help texts for libffado backend.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-02 11:24:18 +01:00
Takashi Sakamoto
5a30b4d009 axfer: correct description about signal handling
Some items in a section for POSIX SIGNALS includes wrong texts.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-02 11:24:08 +01:00
Takashi Sakamoto
37809b95dc axfer: fix typo in axfer(1) manual
A line has meaningless 'H' letter in its end.

Fixes: c5b2beebfd ('axfer: add a manual for entry point')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-02 11:23:55 +01:00
Takashi Sakamoto
7d0eacc3bb axfer: fix no return statement in print_help() function
A function, print_help() in xfer module is defined to return integer
value, however this is useledd.

This commit fixes it.

Fixes: 908ff69be2 ('axfer: print help text of transfer subcommand just for common options')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-02 11:23:36 +01:00
Takashi Sakamoto
97fe7b550c axfer: enable each backend to print own help
This commit adds an operation for xfer backend to print help text.
In this time, content of the help is not implemented yet.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-12-07 10:57:44 +01:00
Takashi Sakamoto
908ff69be2 axfer: print help text of transfer subcommand just for common options
This commit adds help text of transfer subcommand.

In this time, backend options are not described. They will be added in
future commits.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-12-07 10:57:37 +01:00
Takashi Sakamoto
c75b96be49 axfer: print help text of list subcommand
This commit adds help text of list subcommand.

This help text can not be in execution of alias (aplay/arecord) due to
program design.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-12-07 10:56:15 +01:00
Takashi Sakamoto
a4782feac3 axfer: print help text of command entry
This commit adds help text of command entry. This is printed when
help subcommand is given, or a valid subcommand or a valid direction
are not given.

Unfortunately, at present, execution of alias (aplay/arecord) with help
options prints the added help text. It should print help options in
transfer subcommand. This bug will fixed in future commits.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-12-07 10:56:10 +01:00
Takashi Sakamoto
422036f64c axfer: add a section about design of transfer subcommand
An implementation of transfer subcommand is the most large part and
complicated somehow. This commit adds a section titled 'DESIGN' to
manual to overall design of the subcommand.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-12-07 10:55:07 +01:00
Takashi Sakamoto
c8fde3a6e1 axfer: add a section to describe compatibility to aplay(1)
The axfer(1) is designed to keep backward compatibility to aplay(1)
as much as possible, however some changes are added to its behaviour.

This commit adds a section titles 'COMPATIBILITY TO APLAY' to each
manuals.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-12-07 10:55:01 +01:00
Takashi Sakamoto
82cb09b581 axfer: add a manual for transfer subcommand
This commit adds a manual for transfer subcommand in axfer(1). This
subcommand is a main feature of this command, to transfer audio data
frame between device/node and file/stdio.

This subcommand is designed to have several transmission backend.
Detail explanation about these backends is added in future commits.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-12-07 10:54:55 +01:00
Takashi Sakamoto
b59b616fae axfer: add a manual for list subcommand
This commit adds a manual for list subcommand of axfer(1). At present,
this subcommand prints helpful information to transfer subcommand in
libasound backend.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-12-07 10:54:49 +01:00
Takashi Sakamoto
c5b2beebfd axfer: add a manual for entry point
This commit adds a manual for axfer(1). This command is an entry point
to supported subcommand.

I note that axfer(1) has renewed option system against aplay(1). The
command get positional two options for subcommand and direction. In
short:
 $ axfer transfer capture|playback [options for transfer subcommand]
 $ axfer list capture|playback [options for list subcommand]
 $ axfer version
 $ axfer help

Manuals to subcommands are added later separately.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-12-07 10:54:36 +01:00
Takashi Sakamoto
bae5761d72 axfer: check whether a terminal is referred for stdio
A reference to a terminal for standard input/output brings some
troubles. For capture transmission, it can bring some terminal
control codes and it's possible to make the terminal in disorder.
For playback transmission, it can bring endless loop to read
data for detection of type of container.

This commit checks whether a terminal is referred for the standard
input/output by a call isatty(3). When detecting a terminal,
axfer run time prints message and goes to finish.

Suggested-by: Takashi Iwai <tiwai@suse.com>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-12-05 15:29:51 +01:00
Takashi Sakamoto
b8833717bb axfer: truncate parsed arguments before operating subcommand
When subcommands are operated, top-most two arguments are already
parsed in renewed command system, thus they're useless. Besides,
they're possible to be parsed by getopt_long(3).

This commit truncates these options before entering subcommand
operation.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-12-05 15:23:50 +01:00