Commit a9ec6654 authored by Martin Finkel's avatar Martin Finkel

MediaPlayer: Add audio output device get binding and rename setter

parent 51bde738
......@@ -272,6 +272,10 @@ namespace LibVLCSharp.Shared
EntryPoint = "libvlc_audio_output_device_set")]
internal static extern void LibVLCAudioOutputDeviceSet(IntPtr mediaPlayer, IntPtr module, IntPtr deviceId);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_output_device_get")]
internal static extern IntPtr LibVLCAudioOutputDeviceGet(IntPtr mediaPlayer);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_output_set")]
internal static extern int LibVLCAudioOutputSet(IntPtr mediaPlayer, IntPtr name);
......@@ -1048,19 +1052,43 @@ namespace LibVLCSharp.Shared
return MarshalUtils.PerformInteropAndFree(() => Native.LibVLCAudioOutputSet(NativeReference, nameUtf8), nameUtf8);
/// <summary>
/// Gets a list of potential audio output devices,.
/// </summary>
public AudioOutputDescription[] OutputDeviceEnum
return new AudioOutputDescription[0];
public void OutputDeviceSet(string deviceId, string module = null)
/// Get the current audio output device identifier.
/// This complements SetOutputDevice()
/// warning The initial value for the current audio output device identifier
/// may not be set or may be some unknown value.A LibVLC application should
/// compare this value against the known device identifiers (e.g.those that
/// were previously retrieved by a call to libvlc_audio_output_device_enum or
/// libvlc_audio_output_device_list_get) to find the current audio output device.
/// It is possible that the selected audio output device changes(an external
/// change) without a call to libvlc_audio_output_device_set.That may make this
/// method unsuitable to use if a LibVLC application is attempting to track
/// dynamic audio device changes as they happen.
/// </summary>
/// <returns>the current audio output device identifier, or NULL if no device is selected or in case of error.</returns>
public string OutputDevice => Native.LibVLCAudioOutputDeviceGet(NativeReference).FromUtf8(libvlcFree: true);
/// <summary>
/// Configures an explicit audio output device.
/// If the module paramater is NULL, audio output will be moved to the device
/// specified by the device identifier string immediately.This is the
/// recommended usage.
/// A list of adequate potential device strings can be obtained with
/// libvlc_audio_output_device_enum().
/// However passing NULL is supported in LibVLC version 2.2.0 and later only;
/// in earlier versions, this function would have no effects when the module
/// parameter was NULL.
/// If the module parameter is not NULL, the device parameter of the
/// corresponding audio output, if it exists, will be set to the specified
/// string.
/// A list of adequate potential device strings can be obtained with
/// LibVLC.AudioOutputDevices().
/// </summary>
/// <param name="deviceId">device identifier string</param>
/// <param name="module">If NULL, current audio output module. if non-NULL, name of audio output module</param>
public void SetOutputDevice(string deviceId, string module = null)
var deviceIdUtf8 = deviceId.ToUtf8();
var moduleUtf8 = module.ToUtf8();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment