1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
|
/*
* Purpose: The ossinfo program that is included in the OSS package.
*
* Description:
* The {!xlink ossinfo} program is a replacement of the old
* {!code /dev/sndstat} device file.
*
* The program can be used to list all possible information about the sound
* devices available in the system. It uses the OSS Device Discovery API
* introduced in OSS 4.0 (see the "{!link device_discovery}" section of the
* OSS 4.0 Developer's guide for more info).
*
* The best way to find out what this program does is executing
* {!shell ossinfo -v8}. Then look at the result and try to figure out
* how this program gets that information.
*
* In short the program calls {!nlink SNDCTL_SYSINFO} to find out
* how many {!nlink audio}, {!nlink MIDI} and {!nlink mixer} devices there
* are in the system. Then it uses the {!nlink SNDCTL_AUDIOINFO},
* {!nlink SNDCTL_MIDIINFO} and {!nlink SNDCTL_MIXERINFO} calls to obtain
* device information for all devices in the system.
*/
/*
*
* This file is part of Open Sound System.
*
* Copyright (C) 4Front Technologies 1996-2008.
*
* This this source file is released under GPL v2 license (no other versions).
* See the COPYING file included in the main directory of this source
* distribution for the license terms and conditions.
*
*/
#ifndef LOCAL_BUILD
#include <local_config.h>
#endif
#include <soundcard.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/utsname.h>
#include <sys/ioctl.h>
static int mixerfd = -1, phys_only = 0, show_engines = 0, show_ex = 0, verbose = 0;
static oss_sysinfo sysinfo;
static void
print_symlink(const char *link)
{
char devname[256];
ssize_t len;
if ((len = readlink(link, devname, sizeof(devname)-1)) != -1)
{
devname[len] = '\0';
printf(" %s -> %s\n", link, devname);
}
}
/*
* Display filters for selecting what to print.
*/
static unsigned int action_mask = 0;
#define ACT_GLOBAL 0x00000001
#define ACT_AUDIO 0x00000002
#define ACT_MIDI 0x00000004
#define ACT_MIXER 0x00000008
#define ACT_CARDS 0x00000010
/*
* The print_global_info() routine prints the information returned by the
* {!nlink SNDCTL_SYSINFO} call (in the main program).
*/
static void
print_global_info (void)
{
struct utsname un;
printf ("Version info: %s %s (0x%08X) %s\n",
sysinfo.product, sysinfo.version, sysinfo.versionnum,
sysinfo.license);
if (sysinfo.revision_info[0] != 0)
printf ("Hg revision: %s\n", sysinfo.revision_info);
if (uname (&un) != -1)
printf ("Platform: %s/%s %s %s (%s)\n", un.sysname, un.machine,
un.release, un.version, un.nodename);
printf ("\n");
printf ("Number of audio devices: %d\n", sysinfo.numaudios);
printf ("Number of audio engines: %d\n", sysinfo.numaudioengines);
#ifdef CONFIG_OSS_MIDI
printf ("Number of MIDI devices: %d\n", sysinfo.nummidis);
#endif
printf ("Number of mixer devices: %d\n", sysinfo.nummixers);
printf ("\n");
}
/*
* The print_verbose_formats() routine print's verbose descriptions of all the
* formats that are reported in the {!code mask} parameter. The mask can
* be obtained by calling {!nlink SNDCTL_AUDIOINFO} or
* {!nlink SNDCTL_DSP_GETFMTS}.
*/
static void
print_verbose_formats (unsigned long mask)
{
if (mask & AFMT_MU_LAW)
printf (" AFMT_MU_LAW\t\t- mu-Law encoded\n");
if (mask & AFMT_A_LAW)
printf (" AFMT_A_LAW\t\t- A-Law encoded\n");
if (mask & AFMT_IMA_ADPCM)
printf (" AFMT_IMA_ADPCM\t- IMA ADPCM encoded\n");
if (mask & AFMT_U8)
printf (" AFMT_U8\t\t- 8 bit unsigned\n");
if (mask & AFMT_S16_LE)
printf (" AFMT_S16_LE\t- 16 bit signed little endian\n");
if (mask & AFMT_S16_BE)
printf (" AFMT_S16_BE\t- 16 bit signed big endian\n");
if (mask & AFMT_S8)
printf (" AFMT_S8\t\t- 8 bit signed\n");
if (mask & AFMT_U16_LE)
printf (" AFMT_U16_LE\t- 16 bit unsigned little endian\n");
if (mask & AFMT_U16_BE)
printf (" AFMT_U16_BE\t- 16 bit unsigned big endian\n");
if (mask & AFMT_MPEG)
printf (" AFMT_MPEG\t- MPEG (MP2/MP3) encoded audio\n");
if (mask & AFMT_AC3)
printf (" AFMT_AC3\t\t- AC3 (Dolby Digital) encoded audio\n");
if (mask & AFMT_VORBIS)
printf (" AFMT_VORBIS\t- Vorbis encoded audio\n");
if (mask & AFMT_S32_LE)
printf (" AFMT_S32_LE\t- 32 bit signed little endian\n");
if (mask & AFMT_S32_BE)
printf (" AFMT_S32_BE\t- 32 bit signed big endian\n");
if (mask & AFMT_FLOAT)
printf
(" AFMT_FLOAT\t- Single precision floating point (native endianess)\n");
if (mask & AFMT_S24_LE)
printf (" AFMT_S24_LE\t- 24/32 bit signed little endian\n");
if (mask & AFMT_S24_BE)
printf (" AFMT_S24_BE\t- 24/32 bit signed big endian\n");
if (mask & AFMT_S24_PACKED)
printf (" AFMT_S24_PACKED\t- 24 bit packed (3 byte)\n");
if (mask & AFMT_SPDIF_RAW)
printf (" AFMT_SPDIF_RAW\t- Raw S/PDIF frames\n");
}
static void
print_engine_info (oss_audioinfo * ainfo, int num)
{
const char * lbl = "Engine ";
if (!(ainfo->caps & DSP_CAP_INPUT))
lbl = "Out engine";
else if (!(ainfo->caps & DSP_CAP_OUTPUT))
lbl = "In engine ";
printf (" %s %2d: ", lbl, num);
if (verbose > 1)
printf ("%d/%s\n ", ainfo->dev, ainfo->name);
switch (ainfo->busy)
{
case OSS_OPEN_READ:
printf ("Busy (IN) ");
break;
case OSS_OPEN_WRITE:
printf ("Busy (OUT) ");
break;
case OSS_OPEN_READWRITE:
printf ("Busy (IN/OUT) ");
break;
default:
printf ("Available for use ");
}
if (ainfo->pid > 0)
printf ("by PID %d / %s ", ainfo->pid, ainfo->cmd);
if (*ainfo->song_name)
printf ("songname '%s' ", ainfo->song_name);
if (*ainfo->label)
printf ("label '%s' ", ainfo->label);
printf ("\n");
}
/*
* The print_audio_info() routine prints all possible information available
* for an audio device. The verbose level defines what to print.
*/
static void
print_audio_info (void)
{
int i;
int n = sysinfo.numaudios;
unsigned int cmd = SNDCTL_AUDIOINFO;
if (show_engines)
{
n = sysinfo.numaudioengines;
cmd = SNDCTL_ENGINEINFO;
printf ("\nAudio engines\n");
}
else
{
if (show_ex)
cmd = SNDCTL_AUDIOINFO_EX;
printf ("\nAudio devices\n");
}
for (i = 0; i < n; i++)
{
oss_audioinfo ainfo;
int acc;
memset (&ainfo, 0, sizeof (ainfo));
ainfo.dev = i;
if (ioctl (mixerfd, cmd, &ainfo) == -1)
{
int e = errno;
printf ("Can't get device info for /dev/dsp%d (SNDCTL_AUDIOINFO)\n",
i);
printf ("errno = %d: %s\n\n", e, strerror (e));
continue;
}
if (phys_only)
if (ainfo.caps & PCM_CAP_VIRTUAL)
continue;
if (show_engines)
{
printf ("%02d: ", i);
if (!ainfo.enabled)
printf ("(");
printf ("%s", ainfo.name);
if (!ainfo.enabled)
printf (")");
printf(" ");
printf ("(device file %s)\n", ainfo.devnode);
}
else
{
if (!ainfo.enabled)
printf ("(");
printf ("%-32s ", ainfo.name);
printf ("%s ", ainfo.devnode);
if (!ainfo.enabled)
printf (")");
printf (" (device index %d)\n", i);
}
if (verbose == 0)
continue;
if (ainfo.legacy_device >= 0)
printf (" Legacy device /dev/dsp%d\n", ainfo.legacy_device);
else
printf (" Legacy device NONE\n");
printf (" Caps: ");
if (ainfo.caps & PCM_CAP_DUPLEX)
printf ("DUPLEX ");
if (ainfo.caps & PCM_CAP_REALTIME)
printf ("REALTIME ");
if (ainfo.caps & PCM_CAP_BATCH)
printf ("BATCH ");
if (ainfo.caps & PCM_CAP_COPROC)
printf ("COPROC ");
if (ainfo.caps & PCM_CAP_TRIGGER)
printf ("TRIGGER ");
if (ainfo.caps & PCM_CAP_MMAP)
printf ("MMAP ");
if (ainfo.caps & PCM_CAP_MULTI)
printf ("MULTI ");
if (ainfo.caps & PCM_CAP_BIND)
printf ("BIND ");
if (ainfo.caps & PCM_CAP_VIRTUAL)
printf ("VIRTUAL ");
if (ainfo.caps & PCM_CAP_SHADOW)
printf ("SHADOW ");
if (ainfo.caps & PCM_CAP_HIDDEN)
printf ("HIDDEN ");
printf ("\n");
printf (" Modes: ");
/* Check if the device supports input and/or output */
acc = ainfo.caps & (PCM_CAP_INPUT | PCM_CAP_OUTPUT);
switch (acc)
{
case PCM_CAP_INPUT:
printf ("INPUT ");
break;
case PCM_CAP_OUTPUT:
printf ("OUTPUT ");
break;
case PCM_CAP_INPUT | PCM_CAP_OUTPUT:
printf ("IN/OUT ");
break;
}
printf ("\n");
/* Check if the device is currently busy or not */
if (!ainfo.enabled)
{
/*
* The device is disconnected for some reason. For example an
* USB or FireWire device can be powered off or unplugged.
*/
printf (" ******* DEVICE NOT PLUGGED IN *******\n");
}
else
{
oss_audioinfo ai;
int next, n;
ai.dev = i;
ioctl (mixerfd, SNDCTL_AUDIOINFO_EX, &ai);
print_engine_info (&ai, 1);
n = 2;
/*
* Show all playback/duplex engines
*/
next = ainfo.next_play_engine;
if (!show_engines)
while (next > 0)
{
ai.dev = next;
if (ioctl (mixerfd, SNDCTL_ENGINEINFO, &ai) == -1)
{
int e = errno;
printf
("Can't get device info for /dev/dsp%d (SNDCTL_AUDIOINFO)\n",
i);
printf ("errno = %d: %s\n\n", e, strerror (e));
continue;
}
print_engine_info (&ai, n++);
next = ai.next_play_engine;
}
/*
* Show all recording engines
*/
next = ainfo.next_rec_engine;
if (!show_engines)
if (ainfo.next_rec_engine != ainfo.next_play_engine)
while (next > 0)
{
ai.dev = next;
if (ioctl (mixerfd, SNDCTL_ENGINEINFO, &ai) == -1)
{
int e = errno;
printf
("Can't get device info for /dev/dsp%d (SNDCTL_AUDIOINFO)\n",
i);
printf ("errno = %d: %s\n\n", e, strerror (e));
continue;
}
print_engine_info (&ai, n++);
next = ai.next_play_engine;
}
}
if (verbose < 2)
continue;
if (verbose > 2)
{
printf (" Input formats (0x%08x):\n", ainfo.iformats);
print_verbose_formats (ainfo.iformats);
printf (" Output formats (0x%08x):\n", ainfo.oformats);
print_verbose_formats (ainfo.oformats);
}
else
printf (" Formats: 0x%x in, 0x%x out\n", ainfo.iformats,
ainfo.oformats);
printf (" Device handle: %s\n", ainfo.handle);
printf (" Related mixer dev: %d\n", ainfo.mixer_dev);
printf (" Sample rate source: %d\n", ainfo.rate_source);
printf (" Preferred channel configuration: ");
switch (ainfo.caps & DSP_CH_MASK)
{
case DSP_CH_ANY:
printf ("Not indicated\n");
break;
case DSP_CH_MONO:
printf ("MONO\n");
break;
case DSP_CH_STEREO:
printf ("STEREO\n");
break;
case DSP_CH_MULTI:
printf ("MULTICH\n");
break;
}
printf (" Supported number of channels (min - max): %d - %d\n",
ainfo.min_channels, ainfo.max_channels);
printf (" Native sample rates (min - max): %d - %d",
ainfo.min_rate, ainfo.max_rate);
if (ainfo.nrates > 0)
{
unsigned int j;
printf (" (");
for (j = 0; j < ainfo.nrates; j++)
{
if (j > 0)
printf (",");
printf ("%d", ainfo.rates[j]);
}
printf (")");
}
printf ("\n");
printf (" HW Type: ");
if (ainfo.caps & PCM_CAP_ANALOGOUT)
printf ("ANALOG_OUT ");
if (ainfo.caps & PCM_CAP_ANALOGIN)
printf ("ANALOG_IN ");
if (ainfo.caps & PCM_CAP_DIGITALOUT)
printf ("DIGITAL_OUT ");
if (ainfo.caps & PCM_CAP_DIGITALIN)
printf ("DIGITAL_IN ");
if (!
(ainfo.
caps & (PCM_CAP_ANALOGOUT | PCM_CAP_ANALOGIN | PCM_CAP_DIGITALOUT |
PCM_CAP_DIGITALIN)))
printf ("Not indicated.\n");
printf (" Minimum latency: ");
if (ainfo.latency == -1)
printf ("Not indicated");
else
printf ("%d usec", ainfo.latency);
printf ("\n");
printf ("\n");
}
printf ("\nNodes\n");
print_symlink ("/dev/dsp");
print_symlink ("/dev/dsp_in");
print_symlink ("/dev/dsp_out");
print_symlink ("/dev/dsp_ac3");
print_symlink ("/dev/dsp_mmap");
print_symlink ("/dev/dsp_multich");
print_symlink ("/dev/dsp_spdifout");
print_symlink ("/dev/dsp_spdifin");
print_symlink ("/dev/mixer");
print_symlink ("/dev/sndstat");
}
#ifdef CONFIG_OSS_MIDI
/*
* The print_midi_info() routine prints all possible information available
* for a MIDI device. The verbose level defines what to print.
*/
static void
print_midi_info (void)
{
int i;
printf ("MIDI devices (/dev/midi*)\n");
for (i = 0; i < sysinfo.nummidis; i++)
{
oss_midi_info minfo;
int acc;
minfo.dev = i;
if (ioctl (mixerfd, SNDCTL_MIDIINFO, &minfo) == -1)
{
perror ("SNDCTL_MIDIINFO");
exit (-1);
}
if (phys_only)
if (minfo.caps & MIDI_CAP_VIRTUAL)
continue;
printf ("%d: ", i);
printf ("%s ", minfo.name);
printf ("(MIDI port %d of device object %d)\n", minfo.port_number,
minfo.card_number);
if (verbose == 0)
continue;
printf (" Device file %s, Legacy device /dev/midi%02d\n",
minfo.devnode, minfo.legacy_device);
printf (" Modes: ");
/* Check if the device supports input and/or output */
acc = minfo.caps & MIDI_CAP_INOUT;
switch (acc)
{
case MIDI_CAP_INPUT:
printf ("INPUT ");
break;
case MIDI_CAP_OUTPUT:
printf ("OUTPUT ");
break;
case MIDI_CAP_INOUT:
printf ("IN/OUT ");
break;
}
printf (", ");
/* Check if the device is currently busy or not */
if (!minfo.enabled)
{
/*
* The device is disconnected for some reason. For example an
* USB or FireWire device can be powered off or unplugged.
*/
printf (" ******* DEVICE NOT PLUGGED IN *******\n");
}
else
{
switch (minfo.busy)
{
case OSS_OPEN_READ:
printf ("Busy (IN) ");
break;
case OSS_OPEN_WRITE:
printf ("Busy (OUT) ");
break;
case OSS_OPEN_READWRITE:
printf ("Busy (IN/OUT) ");
break;
default:
printf ("Available for use ");
}
if (minfo.pid > 0)
printf ("by PID %d / %s ", minfo.pid, minfo.cmd);
if (*minfo.song_name != 0)
printf ("(%s) ", minfo.song_name);
if (*minfo.label != 0)
printf ("(label=%s) ", minfo.label);
printf ("\n");
}
if (verbose < 2)
continue;
printf (" Caps: ");
if (minfo.caps & MIDI_CAP_VIRTUAL)
printf ("VIRTUAL ");
if (minfo.caps & MIDI_CAP_CLIENT)
printf ("CLIENT ");
if (minfo.caps & MIDI_CAP_SERVER)
printf ("SERVER ");
if (minfo.caps & MIDI_CAP_INTERNAL)
printf ("INTERNAL ");
if (minfo.caps & MIDI_CAP_EXTERNAL)
printf ("EXTERNAL ");
if (minfo.caps & MIDI_CAP_PTOP)
printf ("PTOP ");
if (minfo.caps & MIDI_CAP_MTC)
printf ("MTC ");
printf ("\n");
printf (" Minimum latency: ");
if (minfo.latency == -1)
printf ("Not indicated");
else
printf ("%d usec", minfo.latency);
printf ("\n");
printf (" Device handle: %s\n", minfo.handle);
printf ("\n");
}
}
#endif
/*
* The print_mixer_info() routine prints all possible information available
* for a mixer device. The verbose level defines what to print.
*/
static void
print_mixer_info (void)
{
int i;
printf ("\nMixer devices\n");
for (i = 0; i < sysinfo.nummixers; i++)
{
oss_mixerinfo minfo;
minfo.dev = i;
if (ioctl (mixerfd, SNDCTL_MIXERINFO, &minfo) == -1)
{
if (errno == ENXIO || errno == ENODEV)
{
printf ("%2d: Device not available\n", i);
continue;
}
perror ("SNDCTL_MIXERINFO");
exit (-1);
}
if (phys_only)
if (minfo.caps & MIXER_CAP_VIRTUAL)
continue;
printf ("%2d: ", i);
if (!minfo.enabled)
printf ("(");
printf ("%s ", minfo.name);
if (!minfo.enabled)
printf (")");
printf ("(Mixer %d of device object %d)\n", minfo.port_number,
minfo.card_number);
if (verbose == 0)
continue;
printf (" Device file %s, Legacy device /dev/mixer%d\n",
minfo.devnode, minfo.legacy_device);
/* Check if the device is currently busy or not */
if (!minfo.enabled)
{
/*
* The device is disconnected for some reason. For example an
* USB or FireWire device can be powered off or unplugged.
*/
printf (" ******* DEVICE NOT PLUGGED IN *******\n");
}
if (verbose < 1)
continue;
printf (" Priority: %d\n", minfo.priority);
printf (" Caps: ");
if (minfo.caps & MIXER_CAP_VIRTUAL)
printf ("VIRTUAL ");
if (minfo.caps & MIXER_CAP_LAYOUT_B)
printf ("LAYOUT_B ");
if (minfo.caps & MIXER_CAP_NARROW)
printf ("NARROW ");
printf ("\n");
if (verbose < 2)
continue;
printf (" Device handle: %s\n", minfo.handle);
printf (" Device priority: %d\n", minfo.priority);
printf ("\n");
}
}
/*
* Helper function for printing HW information.
*/
static void
print_hwinfo (char *hw_info)
{
while (*hw_info != 0)
{
char *s = hw_info;
while (*s && *s != '\n')
s++;
if (*s != 0)
*s++ = 0;
printf (" %s\n", hw_info);
hw_info = s;
}
}
/*
* Print list of device objects/cards
*/
static void
print_card_info (void)
{
int i;
printf ("\nDevice objects\n");
for (i = 0; i < sysinfo.numcards; i++)
{
oss_card_info cinfo;
cinfo.card = i;
if (ioctl (mixerfd, SNDCTL_CARDINFO, &cinfo) == -1)
{
perror ("SNDCTL_CARDINFO");
exit (-1);
}
printf ("%2d: %s %s", i, cinfo.shortname, cinfo.longname);
if (cinfo.intr_count > 0)
printf (" interrupts=%d (%d)", cinfo.ack_count, cinfo.intr_count);
printf ("\n");
if (*cinfo.hw_info != 0)
print_hwinfo (cinfo.hw_info);
}
printf ("\n");
}
static void
usage (char *progname)
{
printf ("Usage: %s [options]\n", progname);
printf ("\n");
printf ("Options:\n");
printf ("\t-h\t\tHelp (this message)\n");
printf ("\t-g\t\tPrint global info\n");
printf ("\t-a\t\tPrint audio devicefile info\n");
printf ("\t-A\t\tPrint audio devicefile info (for O_EXCL applications)\n");
printf ("\t-e\t\tPrint audio engine info\n");
printf ("\t-x\t\tPrint mixer info\n");
#ifdef CONFIG_OSS_MIDI
printf ("\t-m\t\tPrint MIDI info\n");
#endif
printf ("\t-d\t\tPrint device object (\"card\")list\n");
printf ("\t-v[0-9]\t\tSet verbose level\n");
}
static void
bad_usage (char *progname)
{
fprintf (stderr, "Bad usage \n");
usage (progname);
exit (-1);
}
int
main (int argc, char *argv[])
{
const char * devmixer;
int i;
if ((devmixer = getenv("OSS_MIXERDEV")) == NULL)
devmixer = "/dev/mixer";
if ((mixerfd = open (devmixer, O_RDWR, 0)) == -1)
{
switch (errno)
{
case ENXIO:
case ENODEV:
fprintf (stderr,
"Open Sound System is not running in your system.\n");
break;
case ENOENT:
fprintf (stderr,
"No %s device available in your system.\n", devmixer);
fprintf (stderr,
"Perhaps Open Sound System is not installed or running.\n");
break;
default:
perror (devmixer);
}
exit (-1);
}
if (ioctl (mixerfd, SNDCTL_SYSINFO, &sysinfo) == -1)
{
if (errno == ENXIO)
{
fprintf (stderr,
"OSS has not detected any supported sound hardware ");
fprintf (stderr, "in your system.\n");
exit (-1);
}
else
{
perror ("SNDCTL_SYSINFO");
if (errno == EINVAL)
fprintf (stderr, "Error: OSS version 4.0 or later is required\n");
exit (-1);
}
}
/*
* Simple and brutal command line argument parsing. We do not use
* getopt() because it causes dependency problems in some environments.
*/
for (i = 1; i < argc; i++)
if (argv[i][0] == '-')
{
switch (argv[i][1])
{
case 'v':
if (argv[i][2])
verbose = atoi (&argv[i][2]);
else
verbose++;
break;
case 'p':
phys_only = 1;
break;
case 'g':
action_mask |= ACT_GLOBAL;
break;
case 'a':
action_mask |= ACT_AUDIO;
break;
case 'A':
action_mask |= ACT_AUDIO;
show_ex = 1;
break;
case 'e':
action_mask |= ACT_AUDIO;
show_engines = 1;
break;
case 'm':
#ifdef CONFIG_OSS_MIDI
action_mask |= ACT_MIDI;
#else
fprintf (stderr, "Note! MIDI support is available in the current version of OSS so -m has no effect.\n");
#endif
break;
case 'x':
action_mask |= ACT_MIXER;
break;
case 'd':
action_mask |= ACT_CARDS;
break;
case 'h':
usage (argv[0]);
exit (0);
break;
default:
bad_usage (argv[0]);
}
}
else
bad_usage (argv[0]);
/*
* Finally print the information that was requested. By default
* all device types will be shown.
*/
if (action_mask == 0)
action_mask = 0xffffffff;
if (action_mask & ACT_GLOBAL)
print_global_info ();
if (action_mask & ACT_CARDS)
print_card_info ();
#ifdef CONFIG_OSS_MIDI
if (action_mask & ACT_MIDI)
print_midi_info ();
#endif
if (action_mask & ACT_MIXER)
print_mixer_info ();
if (action_mask & ACT_AUDIO)
print_audio_info ();
close (mixerfd);
return 0;
}
|