summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSASANO Takayoshi <uaa@uaa.org.uk>2023-02-02 16:00:45 +0900
committerJaroslav Kysela <perex@perex.cz>2023-02-03 13:22:04 +0100
commit44705e3a2050162c4f434d712d22bfe3f7fb5021 (patch)
treec4617bb21e1d894449277b499159d829b913a47b
parent3b4cdbdf19c70255d2d4c31b5a7d5ae2548eb9ef (diff)
downloadalsa-lib-44705e3a2050162c4f434d712d22bfe3f7fb5021.tar.gz
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>
-rw-r--r--test/audio_time.c3
-rw-r--r--test/latency.c13
-rw-r--r--test/midifile.c6
-rw-r--r--test/namehint.c5
-rw-r--r--test/pcm-multi-thread.c8
-rw-r--r--test/queue_timer.c4
6 files changed, 26 insertions, 13 deletions
diff --git a/test/audio_time.c b/test/audio_time.c
index 919bebe3..1c8481be 100644
--- a/test/audio_time.c
+++ b/test/audio_time.c
@@ -4,8 +4,11 @@
* helpful to verify the information reported by drivers.
*/
+#include "../include/config.h"
#include <stdio.h>
+#if HAVE_MALLOC_H
#include <malloc.h>
+#endif
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
diff --git a/test/latency.c b/test/latency.c
index 5e67015c..40c63e24 100644
--- a/test/latency.c
+++ b/test/latency.c
@@ -38,6 +38,15 @@
#include <sys/time.h>
#include <math.h>
+#ifndef CLOCK_MONOTONIC_RAW
+#define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
+#endif
+
+#if defined(__OpenBSD__)
+#define sched_getparam(pid, parm) (-1)
+#define sched_setscheduler(pid, policy, parm) (-1)
+#endif
+
typedef struct timespec timestamp_t;
char *sched_policy = "rr";
@@ -839,9 +848,9 @@ int main(int argc, char *argv[])
if (ok) {
#if 1
printf("Playback time = %li.%i, Record time = %li.%i, diff = %li\n",
- p_tstamp.tv_sec,
+ (long)p_tstamp.tv_sec,
(int)p_tstamp.tv_usec,
- c_tstamp.tv_sec,
+ (long)c_tstamp.tv_sec,
(int)c_tstamp.tv_usec,
timediff(p_tstamp, c_tstamp));
#endif
diff --git a/test/midifile.c b/test/midifile.c
index 3d72b9f9..4862b199 100644
--- a/test/midifile.c
+++ b/test/midifile.c
@@ -71,7 +71,7 @@
#endif
#include <stdio.h>
-#include <values.h>
+#include <limits.h>
#include <string.h>
/*void exit(), free();*/
@@ -148,7 +148,7 @@ static void msginit ();
static int msgleng ();
static void msgadd ();
static void biggermsg ();
-static int eputc (unsigned char c);
+static int eputc ();
double mf_ticks2sec (unsigned long ticks, int division, unsigned long tempo);
int mf_write_meta_event ();
@@ -328,7 +328,7 @@ readtrack () /* read a track chunk */
if (Mf_interactive)
{
- Mf_toberead = MAXINT;
+ Mf_toberead = INT_MAX;
}
else
{
diff --git a/test/namehint.c b/test/namehint.c
index e978d5ca..18bad1d8 100644
--- a/test/namehint.c
+++ b/test/namehint.c
@@ -4,7 +4,8 @@
int main(int argc, char *argv[])
{
const char *iface = "pcm";
- char **hints, **n;
+ void **hints;
+ char **n;
int err;
if (argc > 1)
@@ -12,7 +13,7 @@ int main(int argc, char *argv[])
err = snd_device_name_hint(-1, iface, &hints);
if (err < 0)
errx(1, "snd_device_name_hint error: %s", snd_strerror(err));
- n = hints;
+ n = (char **)hints;
while (*n != NULL) {
printf("%s\n", *n);
n++;
diff --git a/test/pcm-multi-thread.c b/test/pcm-multi-thread.c
index da1b87c6..de178899 100644
--- a/test/pcm-multi-thread.c
+++ b/test/pcm-multi-thread.c
@@ -37,7 +37,7 @@ static char mode_suffix[] = {
'a', 's', 'h', 't', 'd', 'r'
};
-static const char *devname = "default";
+static const char *pcmdev = "default";
static int stream = SND_PCM_STREAM_PLAYBACK;
static int num_threads = 1;
static int periodsize = 16 * 1024;
@@ -127,7 +127,7 @@ static int parse_options(int argc, char **argv)
while ((c = getopt(argc, argv, "D:r:f:p:b:s:t:m:vq")) >= 0) {
switch (c) {
case 'D':
- devname = optarg;
+ pcmdev = optarg;
break;
case 'r':
rate = atoi(optarg);
@@ -213,9 +213,9 @@ int main(int argc, char **argv)
if (parse_options(argc, argv))
return 1;
- err = snd_pcm_open(&pcm, devname, stream, 0);
+ err = snd_pcm_open(&pcm, pcmdev, stream, 0);
if (err < 0) {
- fprintf(stderr, "cannot open pcm %s\n", devname);
+ fprintf(stderr, "cannot open pcm %s\n", pcmdev);
return 1;
}
diff --git a/test/queue_timer.c b/test/queue_timer.c
index c4ffb192..4e1fa967 100644
--- a/test/queue_timer.c
+++ b/test/queue_timer.c
@@ -100,9 +100,9 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
prevdiff = diff;
fprintf(stderr, " real time: %12ld sec %8ld usec\nqueue time: %12ld sec %8ld usec\n diff: %12ld sec %8ld usec\n diffdiff: %12ld sec %8ld usec\n",
- tv.tv_sec, tv.tv_usec,
+ (long)tv.tv_sec, tv.tv_usec,
(long)rtime->tv_sec, (long)rtime->tv_nsec / 1000,
- diff.tv_sec, diff.tv_usec,
+ (long)diff.tv_sec, diff.tv_usec,
(long)diffdiff.tv_sec, (long)diffdiff.tv_usec);
if (diffdiff.tv_usec > 5000 ||