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
|
/* pmlist.c -- list portmidi devices and numbers
*
* This program lists devices. When you type return, it
* restarts portmidi and lists devices again. It is mainly
* a test for shutting down and restarting.
*
* Roger B. Dannenberg, Feb 2022
*/
#include "portmidi.h"
#include "porttime.h"
#include "stdlib.h"
#include "stdio.h"
#include "string.h"
#include "assert.h"
#define DEVICE_INFO NULL
#define DRIVER_INFO NULL
#define TIME_START Pt_Start(1, 0, 0) /* timer started w/millisecond accuracy */
#define STRING_MAX 80 /* used for console input */
void show_usage()
{
printf("Usage: pmlist [-h]\n -h means help.\n"
" Type return to rescan and list devices, q<ret> to quit\n");
}
int main(int argc, char *argv[])
{
if (argc > 1) {
show_usage();
exit(0);
}
while (1) {
char input[STRING_MAX];
const char *deflt;
const char *in_or_out;
int default_in, default_out, i;
// Pm_Initialize();
/* list device information */
default_in = Pm_GetDefaultInputDeviceID();
default_out = Pm_GetDefaultOutputDeviceID();
for (i = 0; i < Pm_CountDevices(); i++) {
const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
printf("%d: %s, %s", i, info->interf, info->name);
deflt = "";
if (i == default_out || i == default_in) {
deflt = "default ";
}
in_or_out = (info->input ? "input" : "output");
printf(" (%s%s)\n", deflt, in_or_out);
}
if (fgets(input, STRING_MAX, stdin) && input[0] == 'q') {
return 0;
}
Pm_Terminate();
}
return 0;
}
|