~ubuntu-branches/ubuntu/oneiric/oss4/oneiric-proposed

« back to all changes in this revision

Viewing changes to cmd/osstest/osstest.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefano Rivera
  • Date: 2011-06-16 20:37:48 UTC
  • mfrom: (5.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110616203748-jbrxik6ql33z54co
Tags: 4.2-build2004-1ubuntu1
* Merge from Debian unstable.
  - Supports our current kernel (LP: #746048)
  Remaining changes:
  - debian/oss4-dkms.dkms.in: s/source/build/ in Kernel headers paths.
* ld-as-needed.patch: Re-order CC arguments to enable building with ld
  --as-needed (LP: #770972)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Purpose: The osstest program shipped with OSS
 
3
 * Description:
 
4
 *
 
5
 * This file contains the main parts of the {!xlink osstest} utility that is
 
6
 * shipped with the OSS package.
 
7
 *
 
8
 * {!notice The sample rate converter (GRC3) required by this program
 
9
 * is not released by 4Front Technologies. For this reason it will not be
 
10
 * possible to compile this program. The sources have been made
 
11
 * available just because they use some of the new OSS features such as 
 
12
 * {!nlink SNDCTL_AUDIOINFO}.  However the {!nlink ossinfo.c} program might 
 
13
 * be more interesting sample source for this subject.}
 
14
 *
 
15
 * It's rather easy to get this program to work without GRC3 by
 
16
 * commenting out the contents of the src_convert routine and by 
 
17
 * modifying the Makefile. However there should be no reason to do this
 
18
 * since the precompiled program with full functionality is available for
 
19
 * free with OSS.
 
20
 *
 
21
 * The wavedata.c and wavedata.h files contain the actual samples compressed
 
22
 * using the MS ASPCM algorithm.
 
23
 */
 
24
/*
 
25
 *
 
26
 * This file is part of Open Sound System.
 
27
 *
 
28
 * Copyright (C) 4Front Technologies 1996-2008.
 
29
 *
 
30
 * This this source file is released under GPL v2 license (no other versions).
 
31
 * See the COPYING file included in the main directory of this source
 
32
 * distribution for the license terms and conditions.
 
33
 *
 
34
 */
 
35
 
 
36
#define CONFIGURE_C
 
37
#define OSSTEST
 
38
#include <stdio.h>
 
39
#include <stdlib.h>
 
40
#include <unistd.h>
 
41
#include <signal.h>
 
42
#include <fcntl.h>
 
43
#include <string.h>
 
44
#include <errno.h>
 
45
#include <sys/time.h>
 
46
#include <sys/ioctl.h>
 
47
#include <sys/utsname.h>
 
48
#include <soundcard.h>
 
49
 
 
50
/*
 
51
 * Channel selectors
 
52
 */
 
53
#define CH_MONO         0
 
54
#define CH_LEFT         1
 
55
#define CH_RIGHT        2
 
56
#define CH_STEREO       (CH_LEFT|CH_RIGHT)
 
57
 
 
58
#ifdef SRC_SUPPORT
 
59
#include <inttypes.h>
 
60
#define __inline__      inline
 
61
#include "../../kernel/framework/audio/oss_grc3.c"
 
62
#endif
 
63
 
 
64
/*
 
65
 * uncompress_wave() is defined in wavedata.c. It expands the audio samples
 
66
 * stored in wavedata.h and returns the lenghth of the uncompressed version
 
67
 * in bytes.
 
68
 *
 
69
 * The uncompressed wave data format is 16 bit (native) stereo recorded at 48000 Hz.
 
70
 */
 
71
extern int uncompress_wave (short *outbuf);
 
72
 
 
73
#define SHORTER_TEST 0          /* SET THIS TO 1 if you want SHORTER TEST */
 
74
 
 
75
static int data_len;
 
76
 
 
77
#define MAXDEVICE   64
 
78
extern void describe_error (void);      /* From ../dsp/help.c */
 
79
 
 
80
#define SAMPLE_RATE 48000
 
81
 
 
82
/*
 
83
 * Operating mode flags (set from the command line).
 
84
 */
 
85
#define TF_VIRTUAL      0x00000001      /* Test virtual devices */
 
86
#define TF_SYSTEST      0x00000002      /* Test started by oss-install */
 
87
#define TF_SNDCONF      0x00000004      /* Test started by sndconf */
 
88
#define TF_QUICK        0x00000008      /* Shortened test */
 
89
#define TF_LOOP         0x00000010      /* Loop until interrupted */
 
90
 
 
91
int cardno = -1, mixerfd, num_devices_tested = 0, play_gain = 100, skip = 0;
 
92
 
 
93
static short *sample_buf;
 
94
 
 
95
void
 
96
prepare (void)
 
97
{
 
98
  if ((sample_buf = malloc (2000000)) == NULL)
 
99
    {
 
100
      fprintf (stderr, "Out of memory\n");
 
101
      exit (-1);
 
102
    }
 
103
 
 
104
  data_len = uncompress_wave (sample_buf);
 
105
}
 
106
 
 
107
#ifdef SRC_SUPPORT
 
108
/*
 
109
 * The src_convert() routine converts the wave data to the requested
 
110
 * sampling rate.
 
111
 */
 
112
static int
 
113
src_convert (short *buf, short *newbuf, int count, int srate, int sz)
 
114
{
 
115
  int newcount = 0, c, p = 0, np = 0;
 
116
 
 
117
  grc3state_t grc1, grc2;
 
118
 
 
119
  grc3_reset (&grc1);
 
120
  grc3_reset (&grc2);
 
121
 
 
122
  grc3_setup (&grc1, SAMPLE_RATE, srate);
 
123
  grc3_setup (&grc2, SAMPLE_RATE, srate);
 
124
 
 
125
  count /= 2;
 
126
  sz /= 2;
 
127
 
 
128
  while (newcount < count)
 
129
    {
 
130
      int n;
 
131
      c = count - newcount;
 
132
      if (c > 1024)
 
133
        c = 1024;
 
134
      grc3_convert (&grc1, 16, 4, buf + p, newbuf + np, c / 2, 2048, 2, 0);
 
135
      n =
 
136
        grc3_convert (&grc2, 16, 4, buf + p, newbuf + np, c / 2, 2048, 2, 1);
 
137
      newcount += c;
 
138
      p += c;
 
139
      np += n * 2;
 
140
    }
 
141
 
 
142
  return np * 2;
 
143
}
 
144
#endif
 
145
 
 
146
/*
 
147
 * audio_write() writes the requested audio channels of the original stereo
 
148
 * recording(buf). This is done simply by setting the unnecessary
 
149
 * channel (if any) to 0.
 
150
 */
 
151
 
 
152
static int
 
153
audio_write (int fd, short *buf, int count, int chmask)
 
154
{
 
155
  short *buf2;
 
156
  int count2, l, ret, i;
 
157
 
 
158
  if (chmask == CH_STEREO)
 
159
    return write (fd, buf, count);
 
160
 
 
161
  l = count / 4;
 
162
  count2 = count;
 
163
 
 
164
  switch (chmask)
 
165
    {
 
166
    case CH_LEFT:
 
167
      buf2 = malloc (count);
 
168
      memcpy (buf2, buf, count);
 
169
      for (i = 0; i < l; i++)
 
170
        buf2[i * 2 + 1] = 0;
 
171
      break;
 
172
 
 
173
    case CH_RIGHT:
 
174
      buf2 = malloc (count);
 
175
      memcpy (buf2, buf, count);
 
176
      for (i = 0; i < l; i++)
 
177
        buf2[i * 2] = 0;
 
178
      break;
 
179
 
 
180
    default:
 
181
      abort ();
 
182
    }
 
183
 
 
184
  ret = write (fd, buf2, count2);
 
185
  free (buf2);
 
186
 
 
187
  return ret;
 
188
}
 
189
 
 
190
/*
 
191
 * The testdsp() routine checks the capabilities of a given audio device number
 
192
 * (parameter n) and decides if the test sound needs to be played.
 
193
 */
 
194
 
 
195
/*ARGSUSED*/
 
196
int
 
197
testdsp (char *devnode, int n, int flags)
 
198
{
 
199
  float ratio;
 
200
  struct timeval t1, t2;
 
201
  unsigned long t;
 
202
  int sample_rate;
 
203
  int hd, delay;
 
204
  int test_bytes;
 
205
  int open_flags = O_WRONLY;
 
206
  long long total_bytes = 0;
 
207
  unsigned int tmp, caps;
 
208
 
 
209
  short *test_data, *tmp_buf = NULL;
 
210
 
 
211
/*
 
212
 * Use {!nlink O_EXCL} to bypass virtual mixing and to access the actual
 
213
 * hardware device directly. Note that we also have to use
 
214
 * {!nlink SNDCTL_AUDIOINFO_EX} instead of usual SNDCTL_AUDIOINFO since it
 
215
 * returns information that is valid when the device is opened with 
 
216
 * O_EXCL.
 
217
 *
 
218
 * If the device is busy we will try to open it without O_EXCL. 
 
219
 */
 
220
 
 
221
/*
 
222
 * If the -V option was set then don't use O_EXCL.
 
223
 */
 
224
  if (!(flags & TF_VIRTUAL))
 
225
     open_flags |= O_EXCL;
 
226
 
 
227
  hd = open (devnode, open_flags, 0);
 
228
  if (hd == -1 && errno == EBUSY)
 
229
    {
 
230
      /*
 
231
       * Try without O_EXCL which enables virtual mixing. In this way the device
 
232
       * can almost certainly be opened. However the results may be different
 
233
       * than when the device is used directly.
 
234
       */
 
235
 
 
236
      hd = open (devnode, O_WRONLY, 0);
 
237
    }
 
238
 
 
239
  if (hd == -1)
 
240
    {
 
241
      int err = errno;
 
242
      perror (devnode);
 
243
      errno = err;
 
244
      describe_error ();
 
245
      printf ("Can't open the device\n");
 
246
      return 0;
 
247
    }
 
248
 
 
249
  caps = 0;
 
250
  if (ioctl (hd, SNDCTL_DSP_GETCAPS, &caps) == -1)
 
251
    {
 
252
      perror ("SNDCTL_DSP_GETCAPS");
 
253
      printf ("Couldn't get the device capabilities\n");
 
254
      close (hd);
 
255
      return -1;
 
256
    }
 
257
 
 
258
  test_bytes = ((SHORTER_TEST) ? 2000 : data_len);
 
259
 
 
260
/*
 
261
 * Setup the sample format. Since OSS will support {!nlink AFMT_S16_NE} regardless
 
262
 * of the device we do not need to support any other formats.
 
263
 */
 
264
 
 
265
  tmp = AFMT_S16_NE;
 
266
  if (ioctl (hd, SNDCTL_DSP_SETFMT, &tmp) == -1 || tmp != AFMT_S16_NE)
 
267
    {
 
268
      close (hd);
 
269
      printf ("Device doesn't support the native 16 bit sample format (%x)\n",
 
270
              tmp);
 
271
      return -1;
 
272
    }
 
273
 
 
274
/*
 
275
 * Setup the device for stereo playback. Once again we can simply assume that
 
276
 * stereo will always work before OSS takes care of this by emulation if
 
277
 * necessary.
 
278
 */
 
279
  tmp = 2;
 
280
  if (ioctl (hd, SNDCTL_DSP_CHANNELS, &tmp) == -1 || tmp != 2)
 
281
    {
 
282
      close (hd);
 
283
      printf ("The device doesn't support stereo (%d)\n", tmp);
 
284
      return -2;
 
285
    }
 
286
 
 
287
/*
 
288
 * Set up the sample rate. Convrt the sample rate if necessary.
 
289
 * Note that actually OSS will handle any sample rates by doing the
 
290
 * required conversions on fly. However it's possible that some professional
 
291
 * audio devices are configured so that the sample rate conversions are
 
292
 * not permitted. This is unusual but we wanted the osstest utility to 
 
293
 * work OK even in these cases. This is not necessary in ordinary
 
294
 * applications.
 
295
 */
 
296
 
 
297
  tmp = SAMPLE_RATE;
 
298
  if (ioctl (hd, SNDCTL_DSP_SPEED, &tmp) == -1)
 
299
    {
 
300
      close (hd);
 
301
      perror ("Set speed");
 
302
      return -3;
 
303
    }
 
304
 
 
305
  sample_rate = tmp;
 
306
  if (sample_rate != SAMPLE_RATE)
 
307
    {
 
308
#ifdef SRC_SUPPORT
 
309
/*
 
310
 * We need to do the sample rate conversion because the device
 
311
 * is configured not to do it.
 
312
 */
 
313
      int sz, a, b;
 
314
 
 
315
      printf ("sr=%d Hz ", sample_rate);
 
316
 
 
317
      a = SAMPLE_RATE / 100;
 
318
      b = sample_rate / 100;
 
319
 
 
320
      sz = ((test_bytes + 4096) * b) / a;
 
321
      tmp_buf = test_data = malloc (sz);
 
322
      memset (tmp_buf, 0, sz);
 
323
 
 
324
      test_bytes =
 
325
        src_convert (sample_buf, test_data, test_bytes, sample_rate, sz);
 
326
#else
 
327
      printf ("The device doesn't support %d Hz\n", SAMPLE_RATE);
 
328
      return -3;
 
329
#endif
 
330
    }
 
331
  else
 
332
    test_data = sample_buf;
 
333
 
 
334
  if (skip) goto tend;
 
335
 
 
336
  printf ("\n");
 
337
 
 
338
  /* TF_SNDCONF is used when longer messages should be printed. */
 
339
  if (flags & TF_SNDCONF)
 
340
    printf ("   Performing left channel test on %s\n", devnode);
 
341
  else
 
342
    printf ("  <left> ");
 
343
  fflush (stdout);
 
344
 
 
345
/*
 
346
 * This program will measure the real sampling rate by computing the
 
347
 * total time required to play the sample.
 
348
 *
 
349
 * This is not terribly presice with short test sounds but it can be used
 
350
 * to detect if the sampling rate badly wrong. Errors of few percents
 
351
 * is more likely to be caused by poor accuracy of the system clock
 
352
 * rather than problems with the sampling rate.
 
353
 */
 
354
  gettimeofday (&t1, NULL);
 
355
  if (audio_write (hd, test_data, test_bytes, CH_LEFT) < 0)
 
356
    {
 
357
      printf ("Device returned error: %s\n", strerror (errno));
 
358
      close (hd);
 
359
      return -3;
 
360
    }
 
361
  total_bytes = test_bytes;
 
362
  if (flags & TF_SNDCONF)
 
363
    printf ("    Test completed OK\n");
 
364
  else
 
365
    printf ("OK ");
 
366
 
 
367
  if (skip) goto tend;
 
368
 
 
369
  if (flags & TF_SNDCONF)
 
370
    printf ("   Performing right channel test on %s\n", devnode);
 
371
  else
 
372
    printf ("<right> ");
 
373
  fflush (stdout);
 
374
  if (audio_write (hd, test_data, test_bytes, CH_RIGHT) < 0)
 
375
    {
 
376
      printf ("Device returned error: %s\n", strerror (errno));
 
377
      close (hd);
 
378
      return -3;
 
379
    }
 
380
  total_bytes += test_bytes;
 
381
  if (flags & TF_SNDCONF)
 
382
    printf ("    Test completed OK\n");
 
383
  else
 
384
    printf ("OK ");
 
385
 
 
386
  if (skip) goto tend;
 
387
 
 
388
  if (flags & TF_SNDCONF)
 
389
    printf ("   Performing stereo test on %s\n", devnode);
 
390
  else
 
391
    printf ("<stereo> ");
 
392
  fflush (stdout);
 
393
  if (audio_write (hd, test_data, test_bytes, CH_STEREO) < 0)
 
394
    {
 
395
      printf ("Device returned error: %s\n", strerror (errno));
 
396
      close (hd);
 
397
      return -3;
 
398
    }
 
399
  total_bytes += test_bytes;
 
400
  gettimeofday (&t2, NULL);
 
401
  delay = 0;
 
402
  ioctl (hd, SNDCTL_DSP_GETODELAY, &delay);     /* Ignore errors */
 
403
 
 
404
/*
 
405
 * Perform the time computations using milliseconds.
 
406
 */
 
407
 
 
408
  t = t2.tv_sec - t1.tv_sec;
 
409
  t *= 1000;
 
410
 
 
411
  t += t2.tv_usec / 1000;
 
412
  t -= t1.tv_usec / 1000;
 
413
 
 
414
  total_bytes -= delay;
 
415
  total_bytes *= 1000;
 
416
 
 
417
  total_bytes /= t;
 
418
  total_bytes /= 4;
 
419
 
 
420
  ratio = ((float) total_bytes / (float) sample_rate) * 100.0;
 
421
  if (flags & TF_SNDCONF)
 
422
    printf
 
423
      ("    Test completed OK.\n    Sample rate was %8.2f Hz (%4.2f%%)\n",
 
424
       (float) sample_rate * ratio / 100.0, ratio - 100.0);
 
425
  else
 
426
    printf ("OK <measured srate %8.2f Hz (%4.2f%%)> ",
 
427
            (float) sample_rate * ratio / 100.0, ratio - 100.0);
 
428
tend:
 
429
  skip = 0;
 
430
  printf ("\n");
 
431
  num_devices_tested++;
 
432
 
 
433
  close (hd);
 
434
  if (tmp_buf != NULL)
 
435
    free (tmp_buf);
 
436
  return 1;
 
437
}
 
438
 
 
439
static int
 
440
find_num_devices (void)
 
441
{
 
442
  oss_sysinfo info;
 
443
  struct utsname un;
 
444
/*
 
445
 * Find out the number of available audio devices by calling SNDCTL_SYSINFO.
 
446
 */
 
447
 
 
448
  if (ioctl (mixerfd, SNDCTL_SYSINFO, &info) == -1)
 
449
    {
 
450
      if (errno == ENXIO)
 
451
        {
 
452
          fprintf (stderr,
 
453
                   "OSS has not detected any supported sound hardware\n");
 
454
          fprintf (stderr, "in your system.\n");
 
455
          exit (-1);
 
456
        }
 
457
      else
 
458
        {
 
459
          printf ("SNDCTL_SYSINFO failed: %s\n", strerror (errno));
 
460
          printf
 
461
            ("Cannot get system information. Perhaps you are not running OSS 4.x\nbut some slightly incompatible sound subsystem.\n");
 
462
          exit (-1);
 
463
        }
 
464
    }
 
465
  printf ("Sound subsystem and version: %s %s (0x%08X)\n",
 
466
          info.product, info.version, info.versionnum);
 
467
 
 
468
  if (uname (&un) != -1)
 
469
    printf ("Platform: %s/%s %s %s\n", un.sysname, un.machine, un.release,
 
470
            un.version);
 
471
 
 
472
  return info.numaudios;
 
473
}
 
474
 
 
475
/*
 
476
 * The test_device() routine checks certain information about the device
 
477
 * and calls testdsp() to play the test sound.
 
478
 */
 
479
 
 
480
int
 
481
test_device (int t, int flags)
 
482
{
 
483
  oss_audioinfo ainfo;
 
484
  int code;
 
485
 
 
486
/*
 
487
 * Notice! We use {!nlink SNDCTL_AUDIOINFO_EX} because the device is
 
488
 * going to be opened with {!nlink O_EXCL}. Practically all other
 
489
 * applications should use the normal SNDCTL_AUDIOINFO call instead.
 
490
 */
 
491
  ainfo.dev = t;
 
492
  if (ioctl (mixerfd, SNDCTL_AUDIOINFO_EX, &ainfo) == -1)
 
493
    {
 
494
      perror ("SNDCTL_AUDIOINFO_EX");
 
495
      return 1;
 
496
    }
 
497
 
 
498
  if (ainfo.card_number != cardno)      /* Switched to a new card */
 
499
    {
 
500
      printf ("\n*** Scanning sound adapter #%d ***\n", cardno);
 
501
    }
 
502
 
 
503
  printf ("%s (audio engine %d): %s\n", ainfo.devnode, ainfo.dev, ainfo.name);
 
504
 
 
505
  if (!ainfo.enabled)
 
506
    {
 
507
      printf ("- Device not present - Skipping\n");
 
508
      return 1;
 
509
    }
 
510
 
 
511
  if (!(ainfo.caps & PCM_CAP_OUTPUT))
 
512
    {
 
513
      printf ("- Skipping input only device\n");
 
514
      return 1;
 
515
    }
 
516
 
 
517
/*
 
518
 * By default skip virtual devices except if we have not tested
 
519
 * any devices yet.
 
520
 */
 
521
  if (!(flags & TF_VIRTUAL) && num_devices_tested > 0)
 
522
    if (ainfo.caps & PCM_CAP_VIRTUAL)
 
523
      {
 
524
        printf ("- Skipping virtual device (use -V to force test)\n");
 
525
        return 1;
 
526
      }
 
527
 
 
528
  if ((ainfo.caps & DSP_CH_MASK) == DSP_CH_MULTI)
 
529
    {
 
530
      printf ("- Skipping multi channel device\n");
 
531
      return 1;
 
532
    }
 
533
 
 
534
  if (ainfo.pid != -1)
 
535
    {
 
536
      printf ("Note! Device is in use (by PID %d/%s) but will try anyway\n",
 
537
              ainfo.pid, ainfo.cmd);
 
538
      /* return 1; */
 
539
    }
 
540
 
 
541
  if (flags & TF_QUICK)
 
542
    if (cardno == ainfo.card_number)
 
543
      {
 
544
        printf ("- card already tested\n");
 
545
        return 1;
 
546
      }
 
547
 
 
548
  printf ("- Performing audio playback test... ");
 
549
  fflush (stdout);
 
550
 
 
551
  cardno = ainfo.card_number;
 
552
 
 
553
  code = testdsp (ainfo.devnode, t, flags);
 
554
 
 
555
  return code == 1;
 
556
}
 
557
 
 
558
static void
 
559
skip_handler (int c)
 
560
{
 
561
  skip = 1;
 
562
}
 
563
 
 
564
int
 
565
main (int argc, char *argv[])
 
566
{
 
567
  int t, i;
 
568
  int maxdev;
 
569
  int flags = 0;
 
570
  int status = 0;
 
571
  int dev = -1;
 
572
  extern int optind;
 
573
 
 
574
/*
 
575
 * Simple command line switch handling.
 
576
 */
 
577
 
 
578
  while ((i = getopt (argc, argv, "CVflsg:")) != EOF)
 
579
    {
 
580
      switch (i)
 
581
        {
 
582
          case 'V':
 
583
            flags |= TF_VIRTUAL;
 
584
            break;
 
585
          case 's':
 
586
            flags |= TF_SYSTEST;
 
587
            break;
 
588
          case 'C':
 
589
            flags |= TF_SNDCONF;
 
590
            break;
 
591
          case 'f':
 
592
            flags |= TF_QUICK;
 
593
            break;
 
594
          case 'l':
 
595
            flags |= TF_LOOP;
 
596
            break;
 
597
          case 'g':
 
598
            play_gain = atoi (optarg);
 
599
            break;
 
600
          default:
 
601
            printf ("Usage: osstest [options...] [device number]\n"
 
602
                    "   -V      Test virtual mixer devices as well\n"
 
603
                    "   -l      Loop indefinately until interrupted\n"
 
604
                    "   -g gain Set playback gain (0-100). Default 100.\n"
 
605
                    "   -f      Faster test\n");
 
606
            exit (-1);
 
607
        }
 
608
    }
 
609
 
 
610
   if ((optind < argc) && (sscanf (argv[optind], "%d", &dev) != 1))
 
611
      {
 
612
        fprintf (stderr, "Bad device number %s\n", argv[optind]);
 
613
        exit (-1);
 
614
      }
 
615
 
 
616
  if (flags & TF_SYSTEST)
 
617
    {
 
618
      printf ("++++ osstest results ++++\n");
 
619
    }
 
620
 
 
621
/*
 
622
 * Open the mixer device used for calling SNDCTL_SYSINFO and
 
623
 * SNDCTL_AUDIOINFO.
 
624
 */
 
625
  if ((mixerfd = open ("/dev/mixer", O_RDWR, 0)) == -1)
 
626
    {
 
627
      int err = errno;
 
628
      perror ("/dev/mixer");
 
629
      errno = err;
 
630
      describe_error ();
 
631
      exit (-1);
 
632
    }
 
633
 
 
634
  prepare ();                   /* Prepare the wave data */
 
635
 
 
636
/*
 
637
 * Enumerate all devices and play the test sounds.
 
638
 */
 
639
  maxdev = find_num_devices ();
 
640
  if (maxdev < 1)
 
641
    {
 
642
      printf ("\n\nNOTICE! You don't have any audio devices available.\n"
 
643
              "        It looks like your audio hardware was not recognized\n"
 
644
              "        by OSS.\n"
 
645
              "        \n"
 
646
              "        If you have installed OSS just a moment ago then it may be necessary to.\n"
 
647
              "        to rebot the system before trying to use the device(s).\n");
 
648
      exit (-1);
 
649
    }
 
650
 
 
651
#ifdef SIGQUIT
 
652
  signal (SIGQUIT, skip_handler);
 
653
#endif
 
654
 
 
655
  do {
 
656
    if (dev > -1)
 
657
      {
 
658
        if (dev >= maxdev)
 
659
          {
 
660
            fprintf (stderr, "Bad device number %d\n", dev);
 
661
            exit (-1);
 
662
          }
 
663
        if (!test_device (dev, flags))
 
664
          status++;
 
665
    }
 
666
    else
 
667
      for (t = 0; t < maxdev; t++)
 
668
        if (!test_device (t, flags))
 
669
          status++;
 
670
 
 
671
    if (!(flags & TF_SYSTEST))
 
672
      {
 
673
        if (status == 0)
 
674
          printf ("\n*** All tests completed OK ***\n");
 
675
        else
 
676
          printf ("\n*** Some errors were detected during the tests ***\n");
 
677
      }
 
678
 
 
679
    cardno = -1;
 
680
  } while (flags & TF_LOOP);
 
681
 
 
682
  close (mixerfd);
 
683
 
 
684
  return status;
 
685
}