systeminformation 5.9.5 → 5.9.9
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 +8 -4
- package/README.md +4 -0
- package/lib/audio.js +219 -219
- package/lib/battery.js +309 -309
- package/lib/bluetooth.js +183 -183
- package/lib/cpu.js +87 -56
- package/lib/docker.js +6 -1
- package/lib/dockerSocket.js +1 -1
- package/lib/filesystem.js +28 -27
- package/lib/graphics.js +42 -43
- package/lib/index.d.ts +31 -7
- package/lib/memory.js +30 -27
- package/lib/network.js +1589 -1589
- package/lib/osinfo.js +1151 -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
|
@@ -40,7 +40,7 @@ We had to make **several interface changes** to keep systeminformation as consis
|
|
|
40
40
|
|
|
41
41
|
#### Other Improvements and Changes
|
|
42
42
|
|
|
43
|
-
- `baseboard()
|
|
43
|
+
- `baseboard()`: added memMax, memSlots
|
|
44
44
|
- `bios()`: added language and features (linux)
|
|
45
45
|
- `cpu()`: extended AMD processor list
|
|
46
46
|
- `cpu()`: extended socket list (win)
|
|
@@ -80,9 +80,13 @@ 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.9 | 2021-10-27 | `graphics` fixed screen resolution issue (windows) |
|
|
84
|
+
| 5.9.8 | 2021-10-22 | `wmic` fixed code page issues (windows) |
|
|
85
|
+
| 5.9.7 | 2021-10-09 | `battery()` fixed typo seperator (windows) |
|
|
86
|
+
| 5.9.6 | 2021-10-08 | `system()` fixed virtual on WSL2 |
|
|
83
87
|
| 5.9.5 | 2021-10-08 | `battery()` fixed isCharging (windows) |
|
|
84
88
|
| 5.9.4 | 2021-09-23 | `processes()` fixed memVsz, Memrss (macOS M1) |
|
|
85
|
-
| 5.9.3 | 2021-09-17 | `cpuTemperature()` improved tdie detection (
|
|
89
|
+
| 5.9.3 | 2021-09-17 | `cpuTemperature()` improved tdie detection (linux) |
|
|
86
90
|
| 5.9.2 | 2021-09-16 | `graohics()` (macOS), `memLayout()` (win) improvements |
|
|
87
91
|
| 5.9.1 | 2021-09-15 | `diskLayout()` fix size (macOS) |
|
|
88
92
|
| 5.9.0 | 2021-09-15 | `graphics()` new XML parser, added properties (macOS) |
|
|
@@ -238,9 +242,9 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
|
|
|
238
242
|
| 4.24.1 | 2020-05-03 | `processes()` fix parsing command and params |
|
|
239
243
|
| 4.24.0 | 2020-05-01 | `networkInterfaces()` added subnet mask ip4 and ip6 |
|
|
240
244
|
| 4.23.10 | 2020-05-01 | `cpuTemperature()` optimized parsing linux |
|
|
241
|
-
| 4.23.9 | 2020-04-29 | `currentLoad()`
|
|
245
|
+
| 4.23.9 | 2020-04-29 | `currentLoad()` workaround for no os.cpus info |
|
|
242
246
|
| 4.23.8 | 2020-04-26 | `getMacAddresses()` fix added try catch |
|
|
243
|
-
| 4.23.7 | 2020-04-26 | `getCpuCurrentSpeedSync()`
|
|
247
|
+
| 4.23.7 | 2020-04-26 | `getCpuCurrentSpeedSync()` workaround fix |
|
|
244
248
|
| 4.23.6 | 2020-04-25 | `networkGatewayDefault()` bug fix no interfaces |
|
|
245
249
|
| 4.23.5 | 2020-04-20 | updated docs |
|
|
246
250
|
| 4.23.4 | 2020-04-20 | `users()` optimized parseDateTime function |
|
package/README.md
CHANGED
|
@@ -888,6 +888,8 @@ To be able to measure temperature on macOS I created a little additional package
|
|
|
888
888
|
in NPM with `optionalDependencies` I unfortunately was getting unexpected warnings on other platforms.
|
|
889
889
|
So I decided to drop this optional dependency for macOS - so by default, you will not get correct values.
|
|
890
890
|
|
|
891
|
+
This additional package will unfortunately NOT work on Apple Silicon M1 machines.
|
|
892
|
+
|
|
891
893
|
But if you need to detect macOS temperature just run the following additional
|
|
892
894
|
installation command:
|
|
893
895
|
|
|
@@ -976,6 +978,8 @@ Written by Sebastian Hildebrandt [sebhildebrandt](https://github.com/sebhildebra
|
|
|
976
978
|
- Miłosz Dźwigała [mily20001](https://github.com/mily20001)
|
|
977
979
|
- cconley717 [cconley717](https://github.com/cconley717)
|
|
978
980
|
- Maria Camila Cubides [MariaCamilaCubides](https://github.com/MariaCamilaCubides)
|
|
981
|
+
- Aleksander Krasnicki [plakak](https://github.com/plakak)
|
|
982
|
+
- Alexis Tyler [OmgImAlexis](https://github.com/OmgImAlexis)
|
|
979
983
|
|
|
980
984
|
OSX Temperature: credits here are going to:
|
|
981
985
|
|
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;
|