Improve alsa usage
- added command handler to check devices
This commit is contained in:
@@ -25,4 +25,25 @@ export default async function executeAsyncConsoleCommand(consoleCommand) {
|
||||
|
||||
// TODO add some error checking
|
||||
return output;
|
||||
}
|
||||
|
||||
export async function returnAlsaDeviceObject() {
|
||||
const listAlsaDevicesCommand = "arecord -L";
|
||||
const commandResponse = await executeAsyncConsoleCommand(listAlsaDevicesCommand);
|
||||
const brokenCommand = String(commandResponse).split('\n');
|
||||
var devices = [];
|
||||
var i = 0;
|
||||
|
||||
for (const responseLine of brokenCommand) {
|
||||
if (!String(responseLine).match(/^\s/g)) {
|
||||
const tempDevice = {
|
||||
id: i,
|
||||
name: responseLine
|
||||
}
|
||||
devices.push(tempDevice);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return devices;
|
||||
}
|
||||
Reference in New Issue
Block a user