Returns a (device-addr, service-channel, service-name) tuple from the given
        IOBluetoothSDPServiceRecord.

def _getservicetuple(servicerecord):
    """
        Returns a (device-addr, service-channel, service-name) tuple from the given
        IOBluetoothSDPServiceRecord.
        """
    addr = _macutil.formatdevaddr(servicerecord.getDevice().getAddressString())
    name = servicerecord.getServiceName()
    try:
        result, channel = servicerecord.getRFCOMMChannelID_(None) # pyobjc 2.0
    except TypeError:
        result, channel = servicerecord.getRFCOMMChannelID_()
    if result != _macutil.kIOReturnSuccess:
        try:
            result, channel = servicerecord.getL2CAPPSM_(None) # pyobjc 2.0
        except:
            result, channel = servicerecord.getL2CAPPSM_()
        if result != _macutil.kIOReturnSuccess:
            channel = None
    return (addr, channel, name)