-
Notifications
You must be signed in to change notification settings - Fork 835
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Microphone option in cog menu (#859)
- Loading branch information
1 parent
bd0ff3f
commit 3788a42
Showing
13 changed files
with
257 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
'use strict'; | ||
|
||
const audioDevices = require('macos-audio-devices'); | ||
const aperture = require('aperture'); | ||
|
||
const {showError} = require('./errors'); | ||
const {hasMicrophoneAccess} = require('../common/system-permissions'); | ||
|
||
const getAudioDevices = async () => { | ||
if (!hasMicrophoneAccess()) { | ||
return []; | ||
} | ||
|
||
try { | ||
const devices = await audioDevices.getInputDevices(); | ||
|
||
return devices.sort((a, b) => { | ||
if (a.transportType === b.transportType) { | ||
return a.name.localeCompare(b.name); | ||
} | ||
|
||
if (a.transportType === 'builtin') { | ||
return -1; | ||
} | ||
|
||
if (b.transportType === 'builtin') { | ||
return 1; | ||
} | ||
|
||
return 0; | ||
}).map(device => ({id: device.uid, name: device.name})); | ||
} catch (error) { | ||
const devices = await aperture.audioDevices(); | ||
|
||
if (!Array.isArray(devices)) { | ||
const Sentry = require('./sentry'); | ||
Sentry.captureException(new Error(`devices is not an array: ${JSON.stringify(devices)}`)); | ||
showError(error, {reportToSentry: true}); | ||
return []; | ||
} | ||
} | ||
}; | ||
|
||
const getDefaultInputDevice = () => { | ||
const device = audioDevices.getDefaultInputDevice.sync(); | ||
return { | ||
id: device.uid, | ||
name: device.name | ||
}; | ||
}; | ||
|
||
module.exports = {getAudioDevices, getDefaultInputDevice}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.