private Dictionary<string, List<AudioLineInfo>> getDeviceNames(MMDeviceCollection deviceCollection, Dictionary<string, List<AudioLineInfo>> deviceDictionary)
        {
            // Clear dictionary of previously added data (in case some devices have been unplugged or new ones have been plugged in)
            deviceDictionary.Clear() ;

            for (int i = 0; i < deviceCollection.Count; i++)
            {
                MMDevice device = deviceCollection[i];

                // Get the device's interface name
                string deviceInterfaceFriendlyName = getDeviceInterfaceFriendlyName(device);

                // Which is set as a dictionary key if a different line already exists for it...
                if (!deviceDictionary.ContainsKey(deviceInterfaceFriendlyName))
                {
                    // If this device interface name hasn't already set as a dictionary key, then create a new entry for its
                    deviceDictionary[deviceInterfaceFriendlyName] = new List<AudioLineInfo>();
                }

                // Get the guid of the device.
                string deviceGuid = device.ID.Substring(device.ID.LastIndexOf("{") + 1, device.ID.LastIndexOf("}") - device.ID.LastIndexOf("{") -1);

                // Associate to the device's interface name a pair consisting of line name (confusingly known as the device friendly name) and the device's friendly name (the REAL friendly name)
                string realDeviceFriendlyName = getDeviceFriendlyName(new Guid(deviceGuid), true);

                // Gather device line properties to associate with the device's interface name.
                AudioLineInfo audioLineInfo = new AudioLineInfo();

                // Line name is confusingly known as the device friendly name.
                audioLineInfo.LineName = device.FriendlyName;

                // The device's friendly name (the REAL friendly name).
                audioLineInfo.FriendlyName = realDeviceFriendlyName;

                // Device line is always mutable.
                audioLineInfo.Mutable = true;

                // Associate the device's interface name with device line properties.
                deviceDictionary[deviceInterfaceFriendlyName].Add(audioLineInfo);

            }

            return deviceDictionary;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="deviceCollection"></param>
        /// <returns></returns>
        private MMDevice getDevice(MMDeviceCollection deviceCollection, string deviceInterface, string deviceLine)
        {
            bool deviceInterfaceFound = false;

            for (int i = 0; i < deviceCollection.Count; i++)
            {
                MMDevice device = deviceCollection[i];
                string currentDeviceInterface = getDeviceInterfaceFriendlyName(device);

                if (currentDeviceInterface == deviceInterface)
                {
                    deviceInterfaceFound = true;
                    if (device.FriendlyName == deviceLine)
                    {
                        // Set the device id
                        deviceId = i;

                        // return the device.
                        return device;
                    }
                }
            }

            if (!deviceInterfaceFound)
            {
                throw new DeviceInterfaceException(deviceInterface, "The " + deviceInterface + " device interface was not found.");
            }
            else
            {
                throw new DeviceLineException(deviceInterface, deviceLine, "The " + deviceLine + " device line was not found for the " + deviceInterface + " interface.");
            }
        }