Commit graph

53 commits

Author SHA1 Message Date
Jaroslav Kysela
7552aef6e0 alsaloop: use ATTRIBUTE_UNUSED instead remove argument name
We need to support older compilers than GCC 11.

Link: https://github.com/alsa-project/alsa-utils/issues/233
Fixes: d609a58 ("alsaloop: fix the verbose compilation warnings for latest gcc")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-09-04 16:45:39 +02:00
Jaroslav Kysela
feb9c4cdec reshuffle included files to include config.h as first
config.h may contain defines like _FILE_OFFSET_BITS which influence
the system wide include files (off_t types, open -> open64 function
usage etc.).

Related: https://github.com/alsa-project/alsa-utils/pull/223
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-08-30 18:48:23 +02:00
Jaroslav Kysela
d609a58664 alsaloop: fix the verbose compilation warnings for latest gcc
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-08-30 12:36:15 +02:00
Jaroslav Kysela
fd2e386b3e alsaloop: fix loopcount condition
BugLink: https://github.com/alsa-project/alsa-utils/issues/185
Fixes: e61f35b ("alsaloop: try adapt avail_min for playback to avoid 100% CPU usage")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-02-27 13:35:43 +01:00
SASANO Takayoshi
613372dc7c Add OpenBSD support
- ERESTART not supported platform: use EINTR instead
- add include/os_compat.h, well-used OS specific definition
- copied include/bswap.h from alsa-lib

- EPIPE and ESTRPIPE are different usage, but currently
  EPIPE is used when ESTRPIPE is not defined.

  To fix this problem, assign ESPIPE instead.

Fixes: https://github.com/alsa-project/alsa-utils/pull/186
Signed-off-by: SASANO Takayoshi <uaa@uaa.org.uk>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-02-03 13:08:44 +01:00
Pavel Hofman
3b1b6863e7 alsaloop: Support "Playback Pitch 1000000" rate shift
Linux 5.15 will introduce a new control element "Playback Pitch 1000000"
(commit 6fec018 ("usb: gadget: u_audio.c: Adding Playback Pitch ctl for
sync playback") which provides feedback mechanism for playback direction
of USB Audio Gadget. The control operates in the same way as the
existing control element "Capture Pitch 1000000".

This patch adds support for this feature.

Signed-off-by: Pavel Hofman <pavel.hofman@ivitera.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-28 12:32:37 +02:00
Pavel Hofman
59464effec alsaloop: Renamed field capt_pitch to ctl_pitch
Renaming capt_pitch to ctl_pitch to respect the naming style of
snd_ctl_elem_value_t fields in loopback_handle. Also making the variable
name suitable for planned support of playback pitch.

Signed-off-by: Pavel Hofman <pavel.hofman@ivitera.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-28 12:32:22 +02:00
Pavel Hofman
0fd3022e82 alsaloop: fixed parsing value 'auto' of option 'sync'
The value 'auto' was not checked which resulted in using
SYNC_TYPE_NONE instead of SYNC_TYPE_AUTO.

Signed-off-by: Pavel Hofman <pavel.hofman@ivitera.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-13 14:05:02 +02:00
Pavel Hofman
138e53aabb alsaloop: added option prateshift for PLAYSHIFT ctl elem used in PLAYSHIFT
If snd-aloop device is on playback side, the required sync mode is
PLAYSHIFT. That means Loopback ctl elem "PCM Rate Shift 100000" of the
corresponding capture side of the Loopback pipe must be controlled (by
a reciprocal).

ASCII name of the playback rate shift ctl elem is specified with newly
added option -x/--prateshift, e.g.:
  -P hw:Loopback,0 -S playshift \
  -x iface=PCM,name='PCM Rate Shift 100000',device=1

Signed-off-by: Pavel Hofman <pavel.hofman@ivitera.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-13 13:52:12 +02:00
Pavel Hofman
e2b167c490 alsaloop: Adding openctl_elem debug log
When debugging what ctl elem was found and opened (if any) a debug log is
helpful.

Signed-off-by: Pavel Hofman <pavel.hofman@ivitera.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-04 10:44:46 +02:00
Yunhao Tian
ce05208085 alsaloop: Support "Capture Pitch 1000000" rate shift
In Linux 5.14, a new feedback mechanism for USB Audio
Gadget is introduced (commit e89bb428), along with a
new control element "Capture Pitch 1000000". This patch
adds support for this feature. Note that this property
seems to be the reverse of PCM Rate Shift, so we have
to take reciprocal of pitch.

Signed-off-by: Yunhao Tian <t123yh@outlook.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-23 16:55:36 +02:00
nootc
0369271aac alsaloop: man page - correct "rate" option
Change "rate" option from "-c" to "-r".

BugLink: https://github.com/alsa-project/alsa-utils/pull/83
From: nootc
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-04-13 20:14:51 +02:00
Jaroslav Kysela
7a7e064f83 alsaloop: samplerate - fix the wrong pointer operation
It seems that the warnings fix introduced a regression.

BugLink: https://github.com/alsa-project/alsa-utils/issues/85
Fixes: cc46d02 ("alsaloop: pcmjob - fix few warnings")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-31 16:38:37 +02:00
Jaroslav Kysela
c9b4293212 alsaloop: get_queued_playback_samples() - simplify code
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-01-08 18:29:56 +01:00
Jaroslav Kysela
90bbeb1d3e alsaloop: fix possible memory leak in create_loopback_handle()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-01-08 18:21:39 +01:00
Dragos Tarcatu
8572c0c427 alsaloop: Fix the silence generation in xrun_sync
The silence frames generation in xrun_sync() seems to be currently
a bit off as snd_pcm_format_set_silence() uses a wrong buffer address
and size for zero-ing out the data. Consequently instead of clearing
out the last frame(s), snd_pcm_format_set_silence() ends up silencing
samples somewhere else in the buffer. This is partilarly more obvious
for higher frame sizes (e.g. more than 2 channels).

This patch fixes this issue by correcting the parameters passed to
snd_pcm_format_set_silence().

BugLink: https://github.com/alsa-project/alsa-utils/pull/58
Signed-off-by: Dragos Tarcatu <dragos_tarcatu@mentor.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-09-25 15:21:15 +02:00
Ruslan Bilovol
ec8717d588 alsaloop: reduce cumulative error caused by non-atomic samples calculation
When doing loopback between two audio card with
same sampling frequency, I noticed slow increase
of pitch_diff.

When I changed order of get_queued_playback_samples()
vs get_queued_capture_samples(), I noticed same drift
of pitch_diff but if was decreasing this time.

This seems to be caused by non-atomic consecutive
snd_pcm_delay() invocation for playback then for
capture. snd_pcm_delay() measures delay between
read/write call and actual ADC/DAC operation.

So while we get this value for playback path in
get_queued_playback_samples(), next call to
get_queued_capture_samples() will happen a little
bit later so snd_pcm_delay() may return incorrect
value.

Be interleaving get_queued_{playback,capture}_samples()
order, we divide this small error between playback
and capture paths. I do not see any issues anymore
with one-way drift of pitch_diff.

Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-03-11 09:45:10 +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
Jaroslav Kysela
8dcc3a1391 alsaloop: remove unused assignment warning (coverity)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-03-13 14:47:23 +01:00
Jaroslav Kysela
8bc1bc53d0 alsaloop: more avail_min cleanups
1) do not increase avail_min forever

It seems that there are broken plugins like pulse which returns from poll()
immediately regardless avail_min settings.

2) remove ommited debug printf()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2018-10-24 16:01:06 +02:00
Jaroslav Kysela
cc46d02f58 alsaloop: pcmjob - fix few warnings
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2018-10-14 16:59:28 +02:00
Kirill Marinushkin
66b31f2451 alsaloop: fix a typo in the comparison
Hello maintainers,

I would like to suggest you a patch which fixes a typo in the alsa-utils
alsaloop.

Best Regards,
Kirill Marinushkin

Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
Cc: patch@alsa-project.org
Cc: alsa-devel@alsa-project.org
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2018-02-05 09:40:41 +01:00
Jaroslav Kysela
b1e3d945b7 Change FSF address (Franklin Street)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2017-11-14 14:28:53 +01:00
Jaroslav Kysela
e61f35ba4d alsaloop: try adapt avail_min for playback to avoid 100% CPU usage 2016-10-18 13:57:19 +02:00
Jaroslav Kysela
0a6c9e80f7 Makefiles - use AM_CPPFLAGS instead INCLUDES
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2014-05-07 10:55:59 +02:00
John Spencer
0616d87fba alsaloop: pcmjob.c: use portable way to initialize recursive mutex
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP is not in POSIX, as _NP
(non-portable) suggests.

exposing such a symbol in musl libc would lock in the ABI for all
times and makes it impossible to do future changes to the under-
lying struct without hideous symbol versioning hacks.

use the portable way instead: pthread_once was designed for such
cases.

Signed-off-by: John Spencer <maillist-alsa@barfooze.de>
Tested-by: John Spencer <maillist-alsa@barfooze.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-11-08 14:57:06 +01:00
Jaroslav Kysela
87bcda4b8a alsaloop: add -z,--syslog option to use syslog for errors
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-09-16 14:14:41 +02:00
Jaroslav Kysela
8f57464190 alsaloop: fix wrong alias for signal.h
in POSIX, there is no <sys/signal.h>.

it's merely a legacy alias used by glibc, and the header does nothing
else than including <signal.h>.

so let's do the right thing and use the right name, which works everywhere.

Signed-off-by: John Spencer <maillist-alsa@barfooze.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-07-23 14:57:05 +02:00
Jordi Mallach
093a371a27 Several formatting fixes for manpages.
Fix many occurrences of unescaped “-”.
Fix minor English issue.

Signed-off-by: Jordi Mallach <jordi@debian.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-05-16 10:38:13 +02:00
Takashi Iwai
c7b9d3e394 alsaloop: Fix missing #endif
Sorry, forgotten.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-30 14:53:12 +01:00
Takashi Iwai
b7ea343820 alsaloop: Make alsaloop working without libsamplerate
When alsaloop is built with libsamplerate, it quits immediately with
  No libsamplerate suppor
message.  It's because the check of -A option and it's set as default
non-zero value.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-30 14:35:31 +01:00
Jaroslav Kysela
b72e221aab alsaloop: fix the avail_min setup
The previous code does not work as expected for some period_size
configurations. We do not rely on the period size value, so do not
correlate the avail_min parameter with this value.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2012-05-13 13:30:15 +02:00
Jaroslav Kysela
53107e1e31 alsaloop: Improve xrun_sync - fill missing playback samples
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2012-02-20 16:41:19 +01:00
Takashi Iwai
2a627cfaed alsaloop: Use AM_CFLAGS in Makefile.am
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-06-03 14:21:53 +02:00
Jaroslav Kysela
3801e25964 alsaloop: another try to force correct formats for libsamplerate
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2011-03-08 12:57:14 +01:00
Jaroslav Kysela
3853175d12 alsaloop: libsamplerate requires specific formats, force them for slave mode
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2011-03-07 14:22:12 +01:00
Jaroslav Kysela
7a11a2b546 alsaloop: rework the ctl event handling routine
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-10-21 20:38:06 +02:00
Jaroslav Kysela
d53eb0309d alsaloop: Delay the restart a bit (to handle snd-aloop playback xruns better)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-10-20 09:31:01 +02:00
Jaroslav Kysela
1ae28cae89 alsaloop: Fix latency print
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-10-14 15:39:28 +02:00
Jaroslav Kysela
513a9c7ad1 alsaloop: fixes, added -W/--wake option
- added -W/--wake option to reduce poll time
- another try to fix the avail_min parameter for playback
- fixed initial silence fill

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-10-14 11:17:25 +02:00
Jaroslav Kysela
b68986fb4a alsaloop: add -U/--xrun to alsaloop.1 man page
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-10-13 23:41:29 +02:00
Jaroslav Kysela
1a35bdf7c6 alsaloop: added xrun profiling support (-U,--xrun), added SIGUSR1 state dump
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-10-13 23:39:36 +02:00
Jaroslav Kysela
af61ea60cf alsaloop: add --pctl and --cctl options to man page
Signed-off-by: Jaroslav Kysela <perex@perex.cz># Please enter the commit message for your changes. Lines starting
2010-10-11 11:56:16 +02:00
Jaroslav Kysela
38c2ef96b7 alsaloop: add --pctl and --cctl options
In some cases it might be usefull to specify another CTL device names.
Add -X/--pctl and -Y/--cctl options.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-10-11 11:53:50 +02:00
Jaroslav Kysela
bee994f509 alsaloop: Fixes and added --workaround option
- added workaround for alsa-lib (pthread configuration parsing issue) -
  the workaround must be activated manually using ('--workaround serialopen')
- fixed avail_min initialization (caused high CPU usage or xruns)
- fixed shared buffer initialization (both capture and playback buffers
  must have equal number of samples in this config)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-10-11 10:24:14 +02:00
Jaroslav Kysela
e77983d3c5 alsaloop: Fix command-line parsing and pollfd initialization
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-10-08 22:23:05 +02:00
Jaroslav Kysela
147a1cc75c alsaloop: Add OSS mixer redirection support
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-10-08 15:10:23 +02:00
Jaroslav Kysela
058357f042 alsaloop: added resampling for unsupported soundcard rates
- improve also xrun synchronization

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-10-07 20:38:36 +02:00
Jaroslav Kysela
f956c329aa alsaloop: fix resample argument parsing
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-10-07 00:12:38 +02:00
Jaroslav Kysela
5ad13c4825 alsaloop: fix -a option and slave mode processing
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-10-06 20:34:03 +02:00