     public class func allDevices() -> [AMAudioDevice] {
         let deviceIDs = allDeviceIDs()
 
-        let devices = deviceIDs.map { (let deviceID) -> AMAudioDevice in
-            return AMAudioDevice.lookupByID(deviceID)
-        }
+        let devices = deviceIDs.map { deviceID -> AMAudioDevice? in
+            AMAudioDevice.lookupByID(deviceID)
+        }.flatMap { $0 }
 
         return devices
     }


        if let preferredStereoChannels = preferredStereoChannelsForDirection(direction) {

            let canSetVolumeCount = preferredStereoChannels.filter { (channel) -> Bool in
                return canSetVolumeForChannel(channel, andDirection: direction)
            }.count

            return canSetVolumeCount == preferredStereoChannels.count

    public class func allInputDevices() -> [AMAudioDevice] {
        let devices = allDevices()

        return devices.filter { device -> Bool in
            device.channelsForDirection(.Recording) > 0
        }
    }

    /**
