audio type
This commit is contained in:
parent
b3630ad717
commit
67f5e6cc53
@ -497,6 +497,8 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (m
|
||||
| | [0].revision | X | | | | | revision |
|
||||
| | [0].driver | X | | | | | driver |
|
||||
| | [0].default | | | X | X | | is default |
|
||||
| | [0].channel | X | | X | | | channel e.g. USB, HDMI, ... |
|
||||
| | [0].type | X | | X | X | | type e.g. Speaker |
|
||||
| | [0].in | | | X | X | | is input channel |
|
||||
| | [0].out | | | X | X | | is output channel |
|
||||
| | [0].interfaceType | X | | X | X | | interface type (PCIe, USB, HDMI, ...) |
|
||||
|
||||
@ -136,6 +136,26 @@
|
||||
<td></td>
|
||||
<td>is default</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>[0].channel</td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>channel e.g. HDMI, USB, ...</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>[0].type</td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td>type e.g. Speaker</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>[0].in</td>
|
||||
@ -263,4 +283,4 @@ si.audio().then(data => console.log(data));</code></pre class="example">
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
25
lib/audio.js
25
lib/audio.js
@ -28,6 +28,27 @@ const _openbsd = (_platform === 'openbsd');
|
||||
const _netbsd = (_platform === 'netbsd');
|
||||
const _sunos = (_platform === 'sunos');
|
||||
|
||||
function parseAudioType(str, input, output) {
|
||||
let result = '';
|
||||
|
||||
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 (!result && output) {
|
||||
result = 'Speaker';
|
||||
} else if (!result && input) {
|
||||
result = 'Microphone';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
function getLinuxAudioPci() {
|
||||
let cmd = 'lspci -v 2>/dev/null';
|
||||
let result = [];
|
||||
@ -62,6 +83,7 @@ function parseLinuxAudioPciMM(lines, audioPCI) {
|
||||
result.driver = pciMatch && pciMatch.length === 1 && pciMatch[0].driver ? pciMatch[0].driver : '';
|
||||
result.default = null;
|
||||
result.channel = 'PCIe';
|
||||
result.type = parseAudioType(result.name, null, null);
|
||||
result.in = null;
|
||||
result.out = null;
|
||||
result.status = 'online';
|
||||
@ -93,6 +115,7 @@ function parseDarwinAudio(audioObject, id) {
|
||||
result.driver = null;
|
||||
result.default = !!(audioObject.coreaudio_default_audio_input_device || '') || !!(audioObject.coreaudio_default_audio_output_device || '');
|
||||
result.channel = parseDarwinChannel(channelStr);
|
||||
result.type = parseAudioType(result.name, !!(audioObject.coreaudio_device_input || ''), !!(audioObject.coreaudio_device_output || ''));
|
||||
result.in = !!(audioObject.coreaudio_device_input || '');
|
||||
result.out = !!(audioObject.coreaudio_device_output || '');
|
||||
result.status = 'online';
|
||||
@ -111,6 +134,8 @@ function parseWindowsAudio(lines) {
|
||||
result.revision = null;
|
||||
result.driver = null;
|
||||
result.default = null;
|
||||
result.channel = null;
|
||||
result.type = parseAudioType(result.name, null, null);
|
||||
result.in = null;
|
||||
result.out = null;
|
||||
result.status = status;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user