systeminformation 5.9.7 → 5.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -2
- package/lib/audio.js +219 -219
- package/lib/battery.js +309 -309
- package/lib/bluetooth.js +183 -183
- package/lib/cpu.js +43 -41
- package/lib/dockerSocket.js +1 -1
- package/lib/filesystem.js +1265 -1264
- package/lib/graphics.js +41 -42
- package/lib/index.d.ts +1 -1
- package/lib/memory.js +24 -21
- package/lib/network.js +1589 -1589
- package/lib/osinfo.js +1150 -1150
- package/lib/printer.js +212 -212
- package/lib/processes.js +1240 -1240
- package/lib/system.js +839 -841
- package/lib/usb.js +305 -305
- package/lib/users.js +187 -81
- package/lib/util.js +21 -6
- package/lib/wifi.js +15 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -80,6 +80,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
|
|
|
80
80
|
|
|
81
81
|
| Version | Date | Comment |
|
|
82
82
|
| -------------- | -------------- | -------- |
|
|
83
|
+
| 5.9.8 | 2021-10-22 | `wmic` fixed code page issues (windows) |
|
|
83
84
|
| 5.9.7 | 2021-10-09 | `battery()` fixed typo seperator (windows) |
|
|
84
85
|
| 5.9.6 | 2021-10-08 | `system()` fixed virtual on WSL2 |
|
|
85
86
|
| 5.9.5 | 2021-10-08 | `battery()` fixed isCharging (windows) |
|
|
@@ -240,9 +241,9 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
|
|
|
240
241
|
| 4.24.1 | 2020-05-03 | `processes()` fix parsing command and params |
|
|
241
242
|
| 4.24.0 | 2020-05-01 | `networkInterfaces()` added subnet mask ip4 and ip6 |
|
|
242
243
|
| 4.23.10 | 2020-05-01 | `cpuTemperature()` optimized parsing linux |
|
|
243
|
-
| 4.23.9 | 2020-04-29 | `currentLoad()`
|
|
244
|
+
| 4.23.9 | 2020-04-29 | `currentLoad()` workaround for no os.cpus info |
|
|
244
245
|
| 4.23.8 | 2020-04-26 | `getMacAddresses()` fix added try catch |
|
|
245
|
-
| 4.23.7 | 2020-04-26 | `getCpuCurrentSpeedSync()`
|
|
246
|
+
| 4.23.7 | 2020-04-26 | `getCpuCurrentSpeedSync()` workaround fix |
|
|
246
247
|
| 4.23.6 | 2020-04-25 | `networkGatewayDefault()` bug fix no interfaces |
|
|
247
248
|
| 4.23.5 | 2020-04-20 | updated docs |
|
|
248
249
|
| 4.23.4 | 2020-04-20 | `users()` optimized parseDateTime function |
|
package/lib/audio.js
CHANGED
|
@@ -1,219 +1,219 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
// @ts-check
|
|
3
|
-
// ==================================================================================
|
|
4
|
-
// audio.js
|
|
5
|
-
// ----------------------------------------------------------------------------------
|
|
6
|
-
// Description: System Information - library
|
|
7
|
-
// for Node.js
|
|
8
|
-
// Copyright: (c) 2014 - 2021
|
|
9
|
-
// Author: Sebastian Hildebrandt
|
|
10
|
-
// ----------------------------------------------------------------------------------
|
|
11
|
-
// License: MIT
|
|
12
|
-
// ==================================================================================
|
|
13
|
-
// 16. audio
|
|
14
|
-
// ----------------------------------------------------------------------------------
|
|
15
|
-
|
|
16
|
-
const exec = require('child_process').exec;
|
|
17
|
-
const execSync = require('child_process').execSync;
|
|
18
|
-
const util = require('./util');
|
|
19
|
-
// const fs = require('fs');
|
|
20
|
-
|
|
21
|
-
let _platform = process.platform;
|
|
22
|
-
|
|
23
|
-
const _linux = (_platform === 'linux');
|
|
24
|
-
const _darwin = (_platform === 'darwin');
|
|
25
|
-
const _windows = (_platform === 'win32');
|
|
26
|
-
const _freebsd = (_platform === 'freebsd');
|
|
27
|
-
const _openbsd = (_platform === 'openbsd');
|
|
28
|
-
const _netbsd = (_platform === 'netbsd');
|
|
29
|
-
const _sunos = (_platform === 'sunos');
|
|
30
|
-
|
|
31
|
-
function parseAudioType(str, input, output) {
|
|
32
|
-
let result = '';
|
|
33
|
-
|
|
34
|
-
if (str.indexOf('speak') >= 0) { result = 'Speaker'; }
|
|
35
|
-
if (str.indexOf('laut') >= 0) { result = 'Speaker'; }
|
|
36
|
-
if (str.indexOf('loud') >= 0) { result = 'Speaker'; }
|
|
37
|
-
if (str.indexOf('head') >= 0) { result = 'Headset'; }
|
|
38
|
-
if (str.indexOf('mic') >= 0) { result = 'Microphone'; }
|
|
39
|
-
if (str.indexOf('mikr') >= 0) { result = 'Microphone'; }
|
|
40
|
-
if (str.indexOf('phone') >= 0) { result = 'Phone'; }
|
|
41
|
-
if (str.indexOf('controll') >= 0) { result = 'Controller'; }
|
|
42
|
-
if (str.indexOf('line o') >= 0) { result = 'Line Out'; }
|
|
43
|
-
if (str.indexOf('digital o') >= 0) { result = 'Digital Out'; }
|
|
44
|
-
|
|
45
|
-
if (!result && output) {
|
|
46
|
-
result = 'Speaker';
|
|
47
|
-
} else if (!result && input) {
|
|
48
|
-
result = 'Microphone';
|
|
49
|
-
}
|
|
50
|
-
return result;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
function getLinuxAudioPci() {
|
|
55
|
-
let cmd = 'lspci -v 2>/dev/null';
|
|
56
|
-
let result = [];
|
|
57
|
-
try {
|
|
58
|
-
const parts = execSync(cmd).toString().split('\n\n');
|
|
59
|
-
for (let i = 0; i < parts.length; i++) {
|
|
60
|
-
const lines = parts[i].split('\n');
|
|
61
|
-
if (lines && lines.length && lines[0].toLowerCase().indexOf('audio') >= 0) {
|
|
62
|
-
const audio = {};
|
|
63
|
-
audio.slotId = lines[0].split(' ')[0];
|
|
64
|
-
audio.driver = util.getValue(lines, 'Kernel driver in use', ':', true) || util.getValue(lines, 'Kernel modules', ':', true);
|
|
65
|
-
result.push(audio);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return result;
|
|
69
|
-
} catch (e) {
|
|
70
|
-
return result;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function parseLinuxAudioPciMM(lines, audioPCI) {
|
|
75
|
-
const result = {};
|
|
76
|
-
const slotId = util.getValue(lines, 'Slot');
|
|
77
|
-
|
|
78
|
-
const pciMatch = audioPCI.filter(function (item) { return item.slotId === slotId; });
|
|
79
|
-
|
|
80
|
-
result.id = slotId;
|
|
81
|
-
result.name = util.getValue(lines, 'SDevice');
|
|
82
|
-
// result.type = util.getValue(lines, 'Class');
|
|
83
|
-
result.manufacturer = util.getValue(lines, 'SVendor');
|
|
84
|
-
result.revision = util.getValue(lines, 'Rev');
|
|
85
|
-
result.driver = pciMatch && pciMatch.length === 1 && pciMatch[0].driver ? pciMatch[0].driver : '';
|
|
86
|
-
result.default = null;
|
|
87
|
-
result.channel = 'PCIe';
|
|
88
|
-
result.type = parseAudioType(result.name, null, null);
|
|
89
|
-
result.in = null;
|
|
90
|
-
result.out = null;
|
|
91
|
-
result.status = 'online';
|
|
92
|
-
|
|
93
|
-
return result;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function parseDarwinChannel(str) {
|
|
97
|
-
let result = '';
|
|
98
|
-
|
|
99
|
-
if (str.indexOf('builtin') >= 0) { result = 'Built-In'; }
|
|
100
|
-
if (str.indexOf('extern') >= 0) { result = 'Audio-Jack'; }
|
|
101
|
-
if (str.indexOf('hdmi') >= 0) { result = 'HDMI'; }
|
|
102
|
-
if (str.indexOf('displayport') >= 0) { result = 'Display-Port'; }
|
|
103
|
-
if (str.indexOf('usb') >= 0) { result = 'USB'; }
|
|
104
|
-
if (str.indexOf('pci') >= 0) { result = 'PCIe'; }
|
|
105
|
-
|
|
106
|
-
return result;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function parseDarwinAudio(audioObject, id) {
|
|
110
|
-
const result = {};
|
|
111
|
-
const channelStr = ((audioObject.coreaudio_device_transport || '') + ' ' + (audioObject._name || '')).toLowerCase();
|
|
112
|
-
|
|
113
|
-
result.id = id;
|
|
114
|
-
result.name = audioObject._name;
|
|
115
|
-
result.manufacturer = audioObject.coreaudio_device_manufacturer;
|
|
116
|
-
result.revision = null;
|
|
117
|
-
result.driver = null;
|
|
118
|
-
result.default = !!(audioObject.coreaudio_default_audio_input_device || '') || !!(audioObject.coreaudio_default_audio_output_device || '');
|
|
119
|
-
result.channel = parseDarwinChannel(channelStr);
|
|
120
|
-
result.type = parseAudioType(result.name, !!(audioObject.coreaudio_device_input || ''), !!(audioObject.coreaudio_device_output || ''));
|
|
121
|
-
result.in = !!(audioObject.coreaudio_device_input || '');
|
|
122
|
-
result.out = !!(audioObject.coreaudio_device_output || '');
|
|
123
|
-
result.status = 'online';
|
|
124
|
-
|
|
125
|
-
return result;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function parseWindowsAudio(lines) {
|
|
129
|
-
const result = {};
|
|
130
|
-
const status = util.getValue(lines, 'StatusInfo', '
|
|
131
|
-
// const description = util.getValue(lines, 'Description', '
|
|
132
|
-
|
|
133
|
-
result.id = util.getValue(lines, 'DeviceID', '
|
|
134
|
-
result.name = util.getValue(lines, 'name', '
|
|
135
|
-
result.manufacturer = util.getValue(lines, 'manufacturer', '
|
|
136
|
-
result.revision = null;
|
|
137
|
-
result.driver = null;
|
|
138
|
-
result.default = null;
|
|
139
|
-
result.channel = null;
|
|
140
|
-
result.type = parseAudioType(result.name, null, null);
|
|
141
|
-
result.in = null;
|
|
142
|
-
result.out = null;
|
|
143
|
-
result.status = status;
|
|
144
|
-
|
|
145
|
-
return result;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function audio(callback) {
|
|
149
|
-
|
|
150
|
-
return new Promise((resolve) => {
|
|
151
|
-
process.nextTick(() => {
|
|
152
|
-
let result = [];
|
|
153
|
-
if (_linux || _freebsd || _openbsd || _netbsd) {
|
|
154
|
-
let cmd = 'lspci -vmm 2>/dev/null';
|
|
155
|
-
exec(cmd, function (error, stdout) {
|
|
156
|
-
// PCI
|
|
157
|
-
if (!error) {
|
|
158
|
-
const audioPCI = getLinuxAudioPci();
|
|
159
|
-
const parts = stdout.toString().split('\n\n');
|
|
160
|
-
for (let i = 0; i < parts.length; i++) {
|
|
161
|
-
const lines = parts[i].split('\n');
|
|
162
|
-
if (util.getValue(lines, 'class', ':', true).toLowerCase().indexOf('audio') >= 0) {
|
|
163
|
-
const audio = parseLinuxAudioPciMM(lines, audioPCI);
|
|
164
|
-
result.push(audio);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
if (callback) {
|
|
169
|
-
callback(result);
|
|
170
|
-
}
|
|
171
|
-
resolve(result);
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
if (_darwin) {
|
|
175
|
-
let cmd = 'system_profiler SPAudioDataType -json';
|
|
176
|
-
exec(cmd, function (error, stdout) {
|
|
177
|
-
if (!error) {
|
|
178
|
-
try {
|
|
179
|
-
const outObj = JSON.parse(stdout.toString());
|
|
180
|
-
if (outObj.SPAudioDataType && outObj.SPAudioDataType.length && outObj.SPAudioDataType[0] && outObj.SPAudioDataType[0]['_items'] && outObj.SPAudioDataType[0]['_items'].length) {
|
|
181
|
-
for (let i = 0; i < outObj.SPAudioDataType[0]['_items'].length; i++) {
|
|
182
|
-
const audio = parseDarwinAudio(outObj.SPAudioDataType[0]['_items'][i], i);
|
|
183
|
-
result.push(audio);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
} catch (e) {
|
|
187
|
-
util.noop();
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (callback) {
|
|
191
|
-
callback(result);
|
|
192
|
-
}
|
|
193
|
-
resolve(result);
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
if (_windows) {
|
|
197
|
-
util.
|
|
198
|
-
if (!error) {
|
|
199
|
-
const parts = stdout.toString().split(/\n\s*\n/);
|
|
200
|
-
for (let i = 0; i < parts.length; i++) {
|
|
201
|
-
if (util.getValue(parts[i].split('\n'), 'name', '
|
|
202
|
-
result.push(parseWindowsAudio(parts[i].split('\n')));
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (callback) {
|
|
207
|
-
callback(result);
|
|
208
|
-
}
|
|
209
|
-
resolve(result);
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
if (_sunos) {
|
|
213
|
-
resolve(null);
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
exports.audio = audio;
|
|
1
|
+
'use strict';
|
|
2
|
+
// @ts-check
|
|
3
|
+
// ==================================================================================
|
|
4
|
+
// audio.js
|
|
5
|
+
// ----------------------------------------------------------------------------------
|
|
6
|
+
// Description: System Information - library
|
|
7
|
+
// for Node.js
|
|
8
|
+
// Copyright: (c) 2014 - 2021
|
|
9
|
+
// Author: Sebastian Hildebrandt
|
|
10
|
+
// ----------------------------------------------------------------------------------
|
|
11
|
+
// License: MIT
|
|
12
|
+
// ==================================================================================
|
|
13
|
+
// 16. audio
|
|
14
|
+
// ----------------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
const exec = require('child_process').exec;
|
|
17
|
+
const execSync = require('child_process').execSync;
|
|
18
|
+
const util = require('./util');
|
|
19
|
+
// const fs = require('fs');
|
|
20
|
+
|
|
21
|
+
let _platform = process.platform;
|
|
22
|
+
|
|
23
|
+
const _linux = (_platform === 'linux');
|
|
24
|
+
const _darwin = (_platform === 'darwin');
|
|
25
|
+
const _windows = (_platform === 'win32');
|
|
26
|
+
const _freebsd = (_platform === 'freebsd');
|
|
27
|
+
const _openbsd = (_platform === 'openbsd');
|
|
28
|
+
const _netbsd = (_platform === 'netbsd');
|
|
29
|
+
const _sunos = (_platform === 'sunos');
|
|
30
|
+
|
|
31
|
+
function parseAudioType(str, input, output) {
|
|
32
|
+
let result = '';
|
|
33
|
+
|
|
34
|
+
if (str.indexOf('speak') >= 0) { result = 'Speaker'; }
|
|
35
|
+
if (str.indexOf('laut') >= 0) { result = 'Speaker'; }
|
|
36
|
+
if (str.indexOf('loud') >= 0) { result = 'Speaker'; }
|
|
37
|
+
if (str.indexOf('head') >= 0) { result = 'Headset'; }
|
|
38
|
+
if (str.indexOf('mic') >= 0) { result = 'Microphone'; }
|
|
39
|
+
if (str.indexOf('mikr') >= 0) { result = 'Microphone'; }
|
|
40
|
+
if (str.indexOf('phone') >= 0) { result = 'Phone'; }
|
|
41
|
+
if (str.indexOf('controll') >= 0) { result = 'Controller'; }
|
|
42
|
+
if (str.indexOf('line o') >= 0) { result = 'Line Out'; }
|
|
43
|
+
if (str.indexOf('digital o') >= 0) { result = 'Digital Out'; }
|
|
44
|
+
|
|
45
|
+
if (!result && output) {
|
|
46
|
+
result = 'Speaker';
|
|
47
|
+
} else if (!result && input) {
|
|
48
|
+
result = 'Microphone';
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
function getLinuxAudioPci() {
|
|
55
|
+
let cmd = 'lspci -v 2>/dev/null';
|
|
56
|
+
let result = [];
|
|
57
|
+
try {
|
|
58
|
+
const parts = execSync(cmd).toString().split('\n\n');
|
|
59
|
+
for (let i = 0; i < parts.length; i++) {
|
|
60
|
+
const lines = parts[i].split('\n');
|
|
61
|
+
if (lines && lines.length && lines[0].toLowerCase().indexOf('audio') >= 0) {
|
|
62
|
+
const audio = {};
|
|
63
|
+
audio.slotId = lines[0].split(' ')[0];
|
|
64
|
+
audio.driver = util.getValue(lines, 'Kernel driver in use', ':', true) || util.getValue(lines, 'Kernel modules', ':', true);
|
|
65
|
+
result.push(audio);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
} catch (e) {
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function parseLinuxAudioPciMM(lines, audioPCI) {
|
|
75
|
+
const result = {};
|
|
76
|
+
const slotId = util.getValue(lines, 'Slot');
|
|
77
|
+
|
|
78
|
+
const pciMatch = audioPCI.filter(function (item) { return item.slotId === slotId; });
|
|
79
|
+
|
|
80
|
+
result.id = slotId;
|
|
81
|
+
result.name = util.getValue(lines, 'SDevice');
|
|
82
|
+
// result.type = util.getValue(lines, 'Class');
|
|
83
|
+
result.manufacturer = util.getValue(lines, 'SVendor');
|
|
84
|
+
result.revision = util.getValue(lines, 'Rev');
|
|
85
|
+
result.driver = pciMatch && pciMatch.length === 1 && pciMatch[0].driver ? pciMatch[0].driver : '';
|
|
86
|
+
result.default = null;
|
|
87
|
+
result.channel = 'PCIe';
|
|
88
|
+
result.type = parseAudioType(result.name, null, null);
|
|
89
|
+
result.in = null;
|
|
90
|
+
result.out = null;
|
|
91
|
+
result.status = 'online';
|
|
92
|
+
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function parseDarwinChannel(str) {
|
|
97
|
+
let result = '';
|
|
98
|
+
|
|
99
|
+
if (str.indexOf('builtin') >= 0) { result = 'Built-In'; }
|
|
100
|
+
if (str.indexOf('extern') >= 0) { result = 'Audio-Jack'; }
|
|
101
|
+
if (str.indexOf('hdmi') >= 0) { result = 'HDMI'; }
|
|
102
|
+
if (str.indexOf('displayport') >= 0) { result = 'Display-Port'; }
|
|
103
|
+
if (str.indexOf('usb') >= 0) { result = 'USB'; }
|
|
104
|
+
if (str.indexOf('pci') >= 0) { result = 'PCIe'; }
|
|
105
|
+
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function parseDarwinAudio(audioObject, id) {
|
|
110
|
+
const result = {};
|
|
111
|
+
const channelStr = ((audioObject.coreaudio_device_transport || '') + ' ' + (audioObject._name || '')).toLowerCase();
|
|
112
|
+
|
|
113
|
+
result.id = id;
|
|
114
|
+
result.name = audioObject._name;
|
|
115
|
+
result.manufacturer = audioObject.coreaudio_device_manufacturer;
|
|
116
|
+
result.revision = null;
|
|
117
|
+
result.driver = null;
|
|
118
|
+
result.default = !!(audioObject.coreaudio_default_audio_input_device || '') || !!(audioObject.coreaudio_default_audio_output_device || '');
|
|
119
|
+
result.channel = parseDarwinChannel(channelStr);
|
|
120
|
+
result.type = parseAudioType(result.name, !!(audioObject.coreaudio_device_input || ''), !!(audioObject.coreaudio_device_output || ''));
|
|
121
|
+
result.in = !!(audioObject.coreaudio_device_input || '');
|
|
122
|
+
result.out = !!(audioObject.coreaudio_device_output || '');
|
|
123
|
+
result.status = 'online';
|
|
124
|
+
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function parseWindowsAudio(lines) {
|
|
129
|
+
const result = {};
|
|
130
|
+
const status = util.getValue(lines, 'StatusInfo', ':');
|
|
131
|
+
// const description = util.getValue(lines, 'Description', ':');
|
|
132
|
+
|
|
133
|
+
result.id = util.getValue(lines, 'DeviceID', ':'); // PNPDeviceID??
|
|
134
|
+
result.name = util.getValue(lines, 'name', ':');
|
|
135
|
+
result.manufacturer = util.getValue(lines, 'manufacturer', ':');
|
|
136
|
+
result.revision = null;
|
|
137
|
+
result.driver = null;
|
|
138
|
+
result.default = null;
|
|
139
|
+
result.channel = null;
|
|
140
|
+
result.type = parseAudioType(result.name, null, null);
|
|
141
|
+
result.in = null;
|
|
142
|
+
result.out = null;
|
|
143
|
+
result.status = status;
|
|
144
|
+
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function audio(callback) {
|
|
149
|
+
|
|
150
|
+
return new Promise((resolve) => {
|
|
151
|
+
process.nextTick(() => {
|
|
152
|
+
let result = [];
|
|
153
|
+
if (_linux || _freebsd || _openbsd || _netbsd) {
|
|
154
|
+
let cmd = 'lspci -vmm 2>/dev/null';
|
|
155
|
+
exec(cmd, function (error, stdout) {
|
|
156
|
+
// PCI
|
|
157
|
+
if (!error) {
|
|
158
|
+
const audioPCI = getLinuxAudioPci();
|
|
159
|
+
const parts = stdout.toString().split('\n\n');
|
|
160
|
+
for (let i = 0; i < parts.length; i++) {
|
|
161
|
+
const lines = parts[i].split('\n');
|
|
162
|
+
if (util.getValue(lines, 'class', ':', true).toLowerCase().indexOf('audio') >= 0) {
|
|
163
|
+
const audio = parseLinuxAudioPciMM(lines, audioPCI);
|
|
164
|
+
result.push(audio);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (callback) {
|
|
169
|
+
callback(result);
|
|
170
|
+
}
|
|
171
|
+
resolve(result);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
if (_darwin) {
|
|
175
|
+
let cmd = 'system_profiler SPAudioDataType -json';
|
|
176
|
+
exec(cmd, function (error, stdout) {
|
|
177
|
+
if (!error) {
|
|
178
|
+
try {
|
|
179
|
+
const outObj = JSON.parse(stdout.toString());
|
|
180
|
+
if (outObj.SPAudioDataType && outObj.SPAudioDataType.length && outObj.SPAudioDataType[0] && outObj.SPAudioDataType[0]['_items'] && outObj.SPAudioDataType[0]['_items'].length) {
|
|
181
|
+
for (let i = 0; i < outObj.SPAudioDataType[0]['_items'].length; i++) {
|
|
182
|
+
const audio = parseDarwinAudio(outObj.SPAudioDataType[0]['_items'][i], i);
|
|
183
|
+
result.push(audio);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
} catch (e) {
|
|
187
|
+
util.noop();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (callback) {
|
|
191
|
+
callback(result);
|
|
192
|
+
}
|
|
193
|
+
resolve(result);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
if (_windows) {
|
|
197
|
+
util.powerShell('Get-WmiObject Win32_SoundDevice | fl *').then((stdout, error) => {
|
|
198
|
+
if (!error) {
|
|
199
|
+
const parts = stdout.toString().split(/\n\s*\n/);
|
|
200
|
+
for (let i = 0; i < parts.length; i++) {
|
|
201
|
+
if (util.getValue(parts[i].split('\n'), 'name', ':')) {
|
|
202
|
+
result.push(parseWindowsAudio(parts[i].split('\n')));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (callback) {
|
|
207
|
+
callback(result);
|
|
208
|
+
}
|
|
209
|
+
resolve(result);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
if (_sunos) {
|
|
213
|
+
resolve(null);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
exports.audio = audio;
|