Commit graph

276 commits

Author SHA1 Message Date
Jaroslav Kysela
c8bc54a9ca test/playmidi1: fix compilation caused by conflict between midifile.h and ump_msg.h
It's a fast fix. The better way is to fix midifile.h or remote this example
(we have already some

Closes: https://github.com/alsa-project/alsa-lib/issues/436
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-02-02 19:22:05 +01:00
Takashi Iwai
3e38164ee5 test: Add an example program to inquire UMP Endpoint and Block info
Provide an example program to inquire UMP Endpoint and Block info in
various APIs.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2024-08-15 16:41:53 +02:00
Takashi Iwai
f784035a90 test: Add an example program to create a virtual UMP Endpoint
Provide an example program to demonstrate how to create a UMP Endpoint
and Blocks, i.e. a virtual UMP device.

It's a simple filtering application that just haves the incoming note
on/off velocity and sends out to the output.  The UMP Endpoint and
Block attributes can be adjusted via command-line options.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2024-06-19 17:24:50 +02:00
Giulio Moro
431f69a8c3 tests: latency.c - fix copy-n-paste typos (sw -> hw params) in error messages
Closes: https://github.com/alsa-project/alsa-lib/pull/384
Signed-off-by: Giulio Moro <giuliomoro@yahoo.it>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2024-02-23 09:57:15 +01:00
Jaroslav Kysela
ad3a8b8b31 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-lib/pull/333
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-08-30 18:25:37 +02:00
Jaroslav Kysela
ec20272797 test: oldapi - fix the clang-16 compilation error
Fixes: https://github.com/alsa-project/alsa-lib/issues/323
From: Fabio Scaccabarozzi
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-08-22 16:52:15 +02:00
SASANO Takayoshi
44705e3a20 test: BSD-like fixes
- rename devname -> pcmdev, it conflicts *BSD <stdlib.h> function
- replace <values.h> -> <limits.h> and fix K&R style related warning
- use config.h to determine include <malloc.h>
- add OpenBSD support and fix printf() warning
- fix warning

Fixes: https://github.com/alsa-project/alsa-lib/pull/298
Signed-off-by: SASANO Takayoshi <uaa@uaa.org.uk>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-02-03 13:22:04 +01:00
SASANO Takayoshi
3b4cdbdf19 type_compat.h: use ESPIPE instead of EPIPE when ESTRPIPE not defined
Fixes: https://github.com/alsa-project/alsa-lib/pull/298
Signed-off-by: SASANO Takayoshi <uaa@uaa.org.uk>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-02-03 13:21:54 +01:00
Jaroslav Kysela
75f8e2e73e test: latency - --policy option - allow using SCHED_OTHER
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-11-24 10:55:32 +01:00
Jaroslav Kysela
ea0850f3f3 test: latency - add --policy option to allow using SCHED_FIFO
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-11-24 08:33:47 +01:00
Jaroslav Kysela
536c93928b test: latency - usleep should not be used in the block mode
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-11-23 19:45:15 +01:00
Jaroslav Kysela
f0f054517c test: latency - add -y option (I/O usleep)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-11-23 17:56:20 +01:00
Jaroslav Kysela
a0836e2af1 latency: add timestamps to the POS lines
- remove first capture pos line
- measure the snd_pcm_start() call, too

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-11-14 21:27:09 +01:00
Jaroslav Kysela
3e4aeba25b test: latency - add more realtime tests
Add '-x' and '-X' tests and '-U' - I/O update mode based
on the system timing.

It may be required to check the position updates for the specific hardware.
Print the real time / stream time differences.

Also include code to make valgrind happy (including the wrong memory
llocation for the stream buffer).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-11-14 20:47:59 +01:00
Jaroslav Kysela
78b20e3caa test: latency - use snd_pcm_format_physical_width()
We need to allocate frames using the physical size not
the sample bit size.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-11-14 12:36:07 +01:00
Jaroslav Kysela
ebb8a6c7a1 conf: introduce snd_config_load_string()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-12-01 10:18:58 +01:00
Jaroslav Kysela
327bd5f28b conf: fix test/lsb/config.c
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-11-30 14:41:14 +01:00
Jaroslav Kysela
9b53b1f0fb conf: improve simple integer math expressions - brackets
Add brackets to the simple math expressions like:

  $[($a+($val+100))/2]

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-11-30 14:35:58 +01:00
Jaroslav Kysela
bf528b9066 conf: add possibility to evaluate simple integer math expressions
It is useful to use the math expressions for the values in configuration.
This patch adds a simple expression evaluation routines (integer only).
The syntax is simplified unix shell (bash) style.

Examples:

	$[1 + 1]
	$[$[2 + 2] / $var1]
	$[0xa0 | 0x05]

As a bonus, the variable substitutions were more abstracted.
The function snd_config_expand_custom() was introduced to be used
for example in the topology pre-precessor.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-11-30 11:33:35 +01:00
Jaroslav Kysela
d3c5e9e009 rawmidi: rename enum snd_rawmidi_framing to snd_rawmidi_read_mode
We hide the internal data transfers using the data frames. Rename
the snd_rawmidi_framing enum to snd_rawmidi_read_mode to make
API more straight and understandable.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-28 08:40:20 +02:00
Jaroslav Kysela
5a5c2953ea rawmidi: define more abstract API for the timestamp reads
The frame structure is a bit internal thing for the kernel
data transfer implementation. Introduce snd_rawmidi_tread()
function which is straight for the application usage and hides
the framing data transfers (kernel space API).

The current code implements the read cache and does the merging
of the frame reads with the similar timestamps (opposite
to the kernel data split for big chunks).

If the application wants to use super-duper-lighting-fast reads,
the snd_rawmidi_read() may be used, but the structure must be
defined on it's own, because this mechanism is not preferred
and unsupported.

BugLink: https://github.com/alsa-project/alsa-lib/issues/172
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-28 08:40:20 +02:00
David Henningsson
868ecd509d test: rawmidi: Add test for rawmidi framing API
Adds a "clock type" parameter to the "rawmidi" test program, that when
used and combined with -i (and -v to be useful), activates tstamp type
framing with the specified clock type.

Signed-off-by: David Henningsson <coding@diwic.se>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-08-20 08:47:23 +02:00
Jaroslav Kysela
c71bb0fb39 test: audio_time - fix timestamp2ns() and usage()
BugLink: https://github.com/alsa-project/alsa-lib/issues/132
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-04-13 19:49:48 +02:00
David Henningsson
dcda999d00 test/audio_time: Make use of SND_PCM_AUDIO_TSTAMP_TYPE constants
Also fixup the usage row which seemed wrong to me.

Signed-off-by: David Henningsson <diwic@ubuntu.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-12-17 11:26:15 +01:00
Jaroslav Kysela
21e2fc3857 test: pcm_min - add snd_pcm_drain() call and indentation fixes
Fixes: https://github.com/alsa-project/alsa-lib/issues/46
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-05-03 20:07:55 +02:00
Quipyowert2
8f2a029925 Printf unsigned longs with %lu instead of %ld (playmidi1.c)
Signed-off-by: Nathan Mills <the.true.nathan.mills@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-04-09 10:27:36 +02:00
Quipyowert2
09abb79c5a Printf unsigned ints with %u instead of %i (pcm.c)
Signed-off-by: Nathan Mills <the.true.nathan.mills@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-04-09 10:27:36 +02:00
Quipyowert2
ac83808882 Printf unsigned long longs with %llu (mixtest.c)
Signed-off-by: Nathan Mills <the.true.nathan.mills@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-04-09 10:27:36 +02:00
Quipyowert2
a2ebf5b60d Printf unsigned longs with %lu instead of %li (midifile.c)
Signed-off-by: Nathan Mills <the.true.nathan.mills@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-04-09 10:27:36 +02:00
Quipyowert2
a894128edd Printf unsigned long with %lu instead of %li (latency.c)
Signed-off-by: Nathan Mills <the.true.nathan.mills@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-04-09 10:27:36 +02:00
Jaroslav Kysela
deb07a0b20 test/latency: use frame bytes correctly in writebuf()
Reported-by: Alessandro Lapini <alessandro.lapini@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-03-01 12:44:44 +01:00
Jaroslav Kysela
92172adb0b test/audio_time: remove unused variables
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2018-10-24 12:07:33 +02:00
Jaroslav Kysela
956bc152e7 test: rename code to more approriate mixtest
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2018-10-24 12:07:33 +02:00
Jaroslav Kysela
82ae026f49 test/code: make it work again
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2018-10-24 12:07:33 +02:00
Jaroslav Kysela
6852f88e80 test/latecy: fix typo in tstamp compare
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2018-10-24 12:07:33 +02:00
Takashi Sakamoto
275a438d42 test: use position offset macro of TLV data
A series of SNDRV_CTL_TLVO_XXX macro was introduced for position offset
of TLV data. This commit applies a code optimization.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-05-15 18:03:13 +02:00
Takashi Sakamoto
38a39091e3 test: correct emulation for channel-map TLV
Current implementation of channel-map TLV on test program is not valid.
Furthermore, it brings buffer-over-run due to byte counting.

This commit fixes it.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-11-24 13:47:17 +01:00
Jaroslav Kysela
5b9041bced Change FSF address (Franklin Street)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2017-11-14 14:29:26 +01:00
Takashi Sakamoto
53cdfa39e5 test: obsolete usage of APIs of dimensional information
APIs of dimensional information are deprecated for future removal. This
commit removes test codes for user-defined element set in an aspect of
the feature.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-11-13 16:57:25 +01:00
Antonio Ospite
8c0b17bca3 test/seq-decoder: enable timestamping for external subscribers
Events sent by external clients subscribed to the input port are not
timestamped.

This inconsistent behavior may surprise newbies who look at seq-decoder as
a reference example.

See the example below using "vkeybd --addr 128:0" to connect to seq-decoder,
the events sent by vkeybd are on a different queue with no timestamps:

  ...
  EVENT>>> Type = 66, flags = 0x0, time = 0 ticks
           Source = 0.1, dest = 128.0, queue = 253
           Event = Port Subscribed; 129:0 -> 128:0
  EVENT>>> Type = 66, flags = 0x1, time = 4.829712627
           Source = 0.1, dest = 128.0, queue = 0
           Event = Port Subscribed; 129:0 -> 128:0
  EVENT>>> Type = 10, flags = 0x0, time = 0 ticks
           Source = 129.0, dest = 128.0, queue = 253
           Event = Controller; ch=0, param=0, value=0
  EVENT>>> Type = 11, flags = 0x0, time = 0 ticks
           Source = 129.0, dest = 128.0, queue = 253
           Event = Program Change; ch=0, program=0
  ...

After the change events are on the main queue and are timestamped:

  ...
  EVENT>>> Type = 66, flags = 0x1, time = 4.280907223
           Source = 0.1, dest = 128.0, queue = 0
           Event = Port Subscribed; 129:0 -> 128:0
  EVENT>>> Type = 66, flags = 0x1, time = 4.280912063
           Source = 0.1, dest = 128.0, queue = 0
           Event = Port Subscribed; 129:0 -> 128:0
  EVENT>>> Type = 10, flags = 0x1, time = 4.280990702
           Source = 129.0, dest = 128.0, queue = 0
           Event = Controller; ch=0, param=0, value=0
  EVENT>>> Type = 11, flags = 0x1, time = 4.280994862
           Source = 129.0, dest = 128.0, queue = 0
           Event = Program Change; ch=0, program=0
  ...

Signed-off-by: Antonio Ospite <ao2@ao2.it>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-10-03 09:14:07 +02:00
Takashi Sakamoto
5efdabc1ab test: apply optimization for v4.14 kernel about changes for TLV data handling on user-defined element set
At kernel v4.14, in initial state, elements on user-defined sets have
write-only flag. When applications write TLV data, then the elements
get readable flag and the TLV data is available. Originally TLV data
is shared by elements in the same set, thus events are generated for
all of elements in the set by the write operation.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-08-24 09:17:32 +02:00
Takashi Sakamoto
79f735fbc1 test: add a test for list operation to user-defined element sets
Current implementation of test for user-defined element doesn't perform
list operation. This commit adds easy test for the operation.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-05-25 18:45:41 +02:00
Takashi Sakamoto
ee1182d2cb test: use actual information for TLV operation
Currently, this test program uses undefined type of TLV data. This can
bring confusions to userspace applications.

This commit replaces the array with valid information, constructed by newly
exported TLV macros from kernel land.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-09-30 17:12:38 +02:00
Takashi Sakamoto
7bebd4c980 ctl: rename APIs to add an element set so that their names are appropriate
In this development period, some APIs have already been added. Most of
them are to add an element set, while their names are not so appropriate
against their feature. This is due to following to names of old APIs.

This commit renames them.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-07-17 10:01:25 +02:00
Takashi Sakamoto
42ff384a98 test: add linker flag with pthread for pcm-multi-thread stress test
This test program is a pthread application, while Makefile has no flags
for linker about pthread library. This can cause below error.

$ make pcm-multi-thread
  CCLD     pcm-multi-thread
/usr/bin/ld: pcm-multi-thread.o: undefined reference to symbol 'pthread_cancel@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:523: recipe for target 'pcm-multi-thread' failed
make: *** [pcm-multi-thread] Error 1

This commit fixes the bug by adding a corresponding flag.

Fixes: 147093ac5b8d('test: Add pcm-multi-thread program')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-07-07 23:48:52 +02:00
Takashi Iwai
147093ac5b test: Add pcm-multi-thread program
A simple multi-thread stress test for PCM is added to test
subdirectory.  It can perform various PCM update function in the
worker threads while reading/writing the data in the main thread.
It can help catching the unexpected error or blockage.  For example,
running the capture test with a softvol plugin will lead to the assert
due to the races.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-07-07 16:30:54 +02:00
Takashi Sakamoto
d61d71a9bb ctl: fix a test for user-defined element set in a point of dimension
Currently, this test program has a bug related to dimension information.
When testing an element set with byte type, the program adds 512 members
to an element. This is a maximum number permitted for this type.

On the other hand, dimension information of the elements consists of
[8, 4, 8, 4]. Calculated members in the multi-dimensional matrix is 1024.
This should be less than 512.

This commit fixes the bug.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-07-07 16:30:37 +02:00
Takashi Sakamoto
ea7bc7f91a ctl: support dimension test for user-defined element set
In former commits, APIs to add an element set are extended to support extra
fields to information structure. Currently, the fields are mainly used to
describe dimension level.

This commit adds tests to check the dimension level.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-06-30 08:42:18 +02:00
Takashi Sakamoto
18a46abf34 ctl: optimize a test for user-defined element set to changes of APIs
In former commits, APIs to add an element set are changed, while a test
program for user-defined element set doesn't follow them.

This commit add support the change.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-06-30 08:42:18 +02:00
Takashi Sakamoto
1edc5f5259 ctl: optimize a test for user-defined element set to older kernels
In Linux 4.0 or former, call of ioctl(2) with SNDRV_CTL_IOCTL_ELEM_ADD
doesn't fill all of identical information in an argument; i.e. numid.
With the kernel, a test of user-defined element set fails.

This commit fixes the bug. The 'numid' field in identical information
is always zero when adding an element set, therefore zero check has an
effect.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-06-30 08:42:17 +02:00