| 5.28.7 |
diff --git a/docs/index.html b/docs/index.html
index c435740..c785b5f 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -170,7 +170,7 @@
systeminformation
- New Version: 5.28.8
+ New Version: 5.28.9
diff --git a/lib/audio.js b/lib/audio.js
index dd930bc..fb45234 100644
--- a/lib/audio.js
+++ b/lib/audio.js
@@ -19,32 +19,60 @@ const util = require('./util');
let _platform = process.platform;
-const _linux = (_platform === 'linux' || _platform === 'android');
-const _darwin = (_platform === 'darwin');
-const _windows = (_platform === 'win32');
-const _freebsd = (_platform === 'freebsd');
-const _openbsd = (_platform === 'openbsd');
-const _netbsd = (_platform === 'netbsd');
-const _sunos = (_platform === 'sunos');
+const _linux = _platform === 'linux' || _platform === 'android';
+const _darwin = _platform === 'darwin';
+const _windows = _platform === 'win32';
+const _freebsd = _platform === 'freebsd';
+const _openbsd = _platform === 'openbsd';
+const _netbsd = _platform === 'netbsd';
+const _sunos = _platform === 'sunos';
function parseAudioType(str, input, output) {
str = str.toLowerCase();
let result = '';
- if (str.indexOf('input') >= 0) { result = 'Microphone'; }
- if (str.indexOf('display audio') >= 0) { result = 'Speaker'; }
- if (str.indexOf('speak') >= 0) { result = 'Speaker'; }
- if (str.indexOf('laut') >= 0) { result = 'Speaker'; }
- if (str.indexOf('loud') >= 0) { result = 'Speaker'; }
- if (str.indexOf('head') >= 0) { result = 'Headset'; }
- if (str.indexOf('mic') >= 0) { result = 'Microphone'; }
- if (str.indexOf('mikr') >= 0) { result = 'Microphone'; }
- if (str.indexOf('phone') >= 0) { result = 'Phone'; }
- if (str.indexOf('controll') >= 0) { result = 'Controller'; }
- if (str.indexOf('line o') >= 0) { result = 'Line Out'; }
- if (str.indexOf('digital o') >= 0) { result = 'Digital Out'; }
- if (str.indexOf('smart sound technology') >= 0) { result = 'Digital Signal Processor'; }
- if (str.indexOf('high definition audio') >= 0) { result = 'Sound Driver'; }
+ if (str.indexOf('input') >= 0) {
+ result = 'Microphone';
+ }
+ if (str.indexOf('display audio') >= 0) {
+ result = 'Speaker';
+ }
+ if (str.indexOf('speak') >= 0) {
+ result = 'Speaker';
+ }
+ if (str.indexOf('laut') >= 0) {
+ result = 'Speaker';
+ }
+ if (str.indexOf('loud') >= 0) {
+ result = 'Speaker';
+ }
+ if (str.indexOf('head') >= 0) {
+ result = 'Headset';
+ }
+ if (str.indexOf('mic') >= 0) {
+ result = 'Microphone';
+ }
+ if (str.indexOf('mikr') >= 0) {
+ result = 'Microphone';
+ }
+ if (str.indexOf('phone') >= 0) {
+ result = 'Phone';
+ }
+ if (str.indexOf('controll') >= 0) {
+ result = 'Controller';
+ }
+ if (str.indexOf('line o') >= 0) {
+ result = 'Line Out';
+ }
+ if (str.indexOf('digital o') >= 0) {
+ result = 'Digital Out';
+ }
+ if (str.indexOf('smart sound technology') >= 0) {
+ result = 'Digital Signal Processor';
+ }
+ if (str.indexOf('high definition audio') >= 0) {
+ result = 'Sound Driver';
+ }
if (!result && output) {
result = 'Speaker';
@@ -54,13 +82,12 @@ function parseAudioType(str, input, output) {
return result;
}
-
function getLinuxAudioPci() {
let cmd = 'lspci -v 2>/dev/null';
let result = [];
try {
const parts = execSync(cmd, util.execOptsLinux).toString().split('\n\n');
- parts.forEach(element => {
+ parts.forEach((element) => {
const lines = element.split('\n');
if (lines && lines.length && lines[0].toLowerCase().indexOf('audio') >= 0) {
const audio = {};
@@ -75,11 +102,27 @@ function getLinuxAudioPci() {
}
}
+function parseWinAudioStatus(n) {
+ let status = n;
+ if (n === 1) {
+ status = 'other';
+ } else if (n === 2) {
+ status = 'unknown';
+ } else if (n === 3) {
+ status = 'enabled';
+ } else if (n === 4) {
+ status = 'disabled';
+ } else if (n === 5) {
+ status = 'not applicable';
+ }
+ return status;
+}
+
function parseLinuxAudioPciMM(lines, audioPCI) {
const result = {};
const slotId = util.getValue(lines, 'Slot');
- const pciMatch = audioPCI.filter(function (item) { return item.slotId === slotId; });
+ const pciMatch = audioPCI.filter((item) => item.slotId === slotId);
result.id = slotId;
result.name = util.getValue(lines, 'SDevice');
@@ -99,12 +142,24 @@ function parseLinuxAudioPciMM(lines, audioPCI) {
function parseDarwinChannel(str) {
let result = '';
- if (str.indexOf('builtin') >= 0) { result = 'Built-In'; }
- if (str.indexOf('extern') >= 0) { result = 'Audio-Jack'; }
- if (str.indexOf('hdmi') >= 0) { result = 'HDMI'; }
- if (str.indexOf('displayport') >= 0) { result = 'Display-Port'; }
- if (str.indexOf('usb') >= 0) { result = 'USB'; }
- if (str.indexOf('pci') >= 0) { result = 'PCIe'; }
+ if (str.indexOf('builtin') >= 0) {
+ result = 'Built-In';
+ }
+ if (str.indexOf('extern') >= 0) {
+ result = 'Audio-Jack';
+ }
+ if (str.indexOf('hdmi') >= 0) {
+ result = 'HDMI';
+ }
+ if (str.indexOf('displayport') >= 0) {
+ result = 'Display-Port';
+ }
+ if (str.indexOf('usb') >= 0) {
+ result = 'USB';
+ }
+ if (str.indexOf('pci') >= 0) {
+ result = 'PCIe';
+ }
return result;
}
@@ -130,7 +185,7 @@ function parseDarwinAudio(audioObject, id) {
function parseWindowsAudio(lines) {
const result = {};
- const status = util.getValue(lines, 'StatusInfo', ':');
+ const status = parseWinAudioStatus(util.getValue(lines, 'StatusInfo', ':'));
result.id = util.getValue(lines, 'DeviceID', ':'); // PNPDeviceID??
result.name = util.getValue(lines, 'name', ':');
@@ -148,18 +203,17 @@ function parseWindowsAudio(lines) {
}
function audio(callback) {
-
return new Promise((resolve) => {
process.nextTick(() => {
- let result = [];
+ const result = [];
if (_linux || _freebsd || _openbsd || _netbsd) {
- let cmd = 'lspci -vmm 2>/dev/null';
- exec(cmd, function (error, stdout) {
+ const cmd = 'lspci -vmm 2>/dev/null';
+ exec(cmd, (error, stdout) => {
// PCI
if (!error) {
const audioPCI = getLinuxAudioPci();
const parts = stdout.toString().split('\n\n');
- parts.forEach(element => {
+ parts.forEach((element) => {
const lines = element.split('\n');
if (util.getValue(lines, 'class', ':', true).toLowerCase().indexOf('audio') >= 0) {
const audio = parseLinuxAudioPciMM(lines, audioPCI);
@@ -174,8 +228,8 @@ function audio(callback) {
});
}
if (_darwin) {
- let cmd = 'system_profiler SPAudioDataType -json';
- exec(cmd, function (error, stdout) {
+ const cmd = 'system_profiler SPAudioDataType -json';
+ exec(cmd, (error, stdout) => {
if (!error) {
try {
const outObj = JSON.parse(stdout.toString());
@@ -199,7 +253,7 @@ function audio(callback) {
util.powerShell('Get-CimInstance Win32_SoundDevice | select DeviceID,StatusInfo,Name,Manufacturer | fl').then((stdout, error) => {
if (!error) {
const parts = stdout.toString().split(/\n\s*\n/);
- parts.forEach(element => {
+ parts.forEach((element) => {
const lines = element.split('\n');
if (util.getValue(lines, 'name', ':')) {
result.push(parseWindowsAudio(lines));