Skip to content

Commit

Permalink
Fix input devices logic (#844)
Browse files Browse the repository at this point in the history
  • Loading branch information
karaggeorge authored May 1, 2020
1 parent b3c37ec commit 9cdafe9
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions main/common/aperture.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const startRecording = async options => {
if (audioInputDeviceId) {
apertureOptions.audioDeviceId = audioInputDeviceId;
} else {
const [defaultAudioDevice] = await audioDevices();
const [defaultAudioDevice] = await getAudioDevices();
apertureOptions.audioDeviceId = defaultAudioDevice && defaultAudioDevice.id;
}
}
Expand Down Expand Up @@ -208,23 +208,28 @@ const stopRecording = async () => {
}
};

module.exports = {
startRecording,
stopRecording,
getAudioDevices: async () => {
if (hasMicrophoneAccess()) {
try {
let devices = await audioDevices();
if (!Array.isArray(devices)) {
devices = await getInputDevices();
return devices.map(({uid, name}) => ({id: uid, name}));
}
} catch (error) {
showError(error, {reportToSentry: true});
return [];
const getAudioDevices = async () => {
if (hasMicrophoneAccess()) {
try {
let devices = await audioDevices();

if (Array.isArray(devices)) {
return devices;
}
}

return [];
devices = await getInputDevices();
return devices.map(({uid, name}) => ({id: uid, name}));
} catch (error) {
showError(error, {reportToSentry: true});
return [];
}
}

return [];
};

module.exports = {
startRecording,
stopRecording,
getAudioDevices
};

0 comments on commit 9cdafe9

Please sign in to comment.