private string GetAudioDevice(string description) { var audioDevicesAoutNames = new string[] { "directsound", "directx" }; var vlcObj = _wrapper.ExpandedLibVLCNew(null); var audioDevicePtr = _wrapper.ExpandedAudioOutputListGet(vlcObj); var audioDevicesPtr = IntPtr.Zero; var audioDeviceName = string.Empty; var audioDevice = new AudioDescription { NextDescription = audioDevicePtr, Description = null, Name = null }; while (audioDevice.NextDescription != IntPtr.Zero) { audioDevice = (AudioDescription)Marshal.PtrToStructure(audioDevice.NextDescription, typeof(AudioDescription)); for (int i = 0; i < audioDevicesAoutNames.Length; i += 2) { if (audioDevice.Name.Contains(audioDevicesAoutNames[i])) { audioDevicesPtr = _wrapper.ExpandedAudioOutputDeviceListGet(vlcObj, audioDevicesAoutNames[i + 1]); break; } } } if (audioDevicesPtr == IntPtr.Zero) { Debug.Log("GetAudioDevice: Can't get audio output device list for " + audioDevice.Name); return(audioDeviceName); } AudioOutputDevice outputDevice = new AudioOutputDevice { NextDevice = audioDevicesPtr, Description = null, Device = null }; try { while (outputDevice.NextDevice != IntPtr.Zero) { outputDevice = (AudioOutputDevice)Marshal.PtrToStructure(outputDevice.NextDevice, typeof(AudioOutputDevice)); if (outputDevice.Description.Contains(description)) { Debug.Log("GetAudioDevice: New audio output device \n" + "Device: " + outputDevice.Device + "\n" + "Description: " + outputDevice.Description); audioDeviceName = outputDevice.Device; } } } finally { if (audioDevicePtr != IntPtr.Zero) { _wrapper.ExpandedAudioOutputListRelease(audioDevicePtr); } if (audioDevicesPtr != IntPtr.Zero) { _wrapper.ExpandedAudioOutputDeviceListRelease(audioDevicesPtr); } _wrapper.ExpandedLibVLCRelease(vlcObj); } if (string.IsNullOrEmpty(audioDeviceName)) { Debug.Log("GetAudioDevice: Can't find audio output device - switched to Default"); } return(audioDeviceName); }