public BluetoothAudioKeeperUpper() { NCI = new NotificationClientImplementation(); NC = NCI; deviceEnum.RegisterEndpointNotificationCallback(NC); System.IO.Stream Sound = Properties.Res.Silence; Player = new SoundPlayer(Sound); }
public CommunicationDeviceSwitcherService() { _loggerFactory = new LoggerFactory(); _logger = _loggerFactory.CreateLogger <CommunicationDeviceSwitcherService>(); var logger = _loggerFactory.CreateLogger <DefaultCommunicateDeviceSwitchNotificationClient>(); _notificationClient = new DefaultCommunicateDeviceSwitchNotificationClient(logger); InitializeComponent(); }
public override void Enable() { _enumerator = new MMDeviceEnumerator(); _notificationClient = new INotificationClient(); _notifyClient = (IMMNotificationClient)_notificationClient; _notificationClient.DefaultDeviceChanged += NotificationClient_DefaultDeviceChanged; _enumerator.RegisterEndpointNotificationCallback(_notifyClient); UpdatePlaybackDevice(true); AddTimedUpdate(TimeSpan.FromMilliseconds(10), UpdatePeakVolume); }
/// <summary> /// Deletes the registration of a notification interface that the client registered in a previous call to the <see cref="RegisterEndpointNotificationCallback"/> method. /// </summary> /// <param name="notificationClient">Implementation of the <see cref="IMMNotificationClient"/> which should be unregistered from any notifications.</param> /// <returns>HRESULT</returns> public unsafe int UnregisterEndpointNotificationCallbackNative(IMMNotificationClient notificationClient) { int result = 0; if (_notificationClients.Contains(notificationClient)) { result = LocalInterop.Calli(UnsafeBasePtr, notificationClient, ((void **)(*(void **)UnsafeBasePtr))[7]); _notificationClients.Remove(notificationClient); } return(result); }
/// <summary> /// Registers a client's notification callback interface. /// </summary> /// <param name="notificationClient">Implementation of the <see cref="IMMNotificationClient"/> which is should receive the notificaitons.</param> /// <returns>HRESULT</returns> public unsafe int RegisterEndpointNotificationCallbackNative(IMMNotificationClient notificationClient) { int result = 0; if (!_notificationClients.Contains(notificationClient)) { result = InteropCalls.CallI(UnsafeBasePtr, notificationClient, ((void **)(*(void **)UnsafeBasePtr))[6]); _notificationClients.Add(notificationClient); } return(result); }
public MainWindow() { InitializeComponent(); this.StateChanged += MainWindow_StateChanged; DataContext = this; using (Stream stream = Application.GetResourceStream(new Uri("/mic.ico", UriKind.Relative)).Stream) { unmutedIcon = new Icon(stream); } using (Stream stream = Application.GetResourceStream(new Uri("/mutedmic.ico", UriKind.Relative)).Stream) { mutedIcon = new Icon(stream); } tbi.LeftClickCommand = new ShowMessageCommand(ShowWindow); var showUiMenuItem = new MenuItem(); showUiMenuItem.Header = "Show UI"; showUiMenuItem.Click += ShowUiMenuItem_Click; var exitMenuItem = new MenuItem(); exitMenuItem.Header = "Exit"; exitMenuItem.Click += ExitMenuItem_Click; tbi.ContextMenu = new ContextMenu(); tbi.ContextMenu.Items.Add(showUiMenuItem); tbi.ContextMenu.Items.Add(exitMenuItem); inputDevicesComboBox.ItemsSource = inputDeviceNames; inputDevicesComboBox.SelectionChanged += InputDevicesComboBox_SelectionChanged; notificationClient = new DeviceChangedClient(new Action(() => { Application.Current.Dispatcher.Invoke(new Action(() => { RefreshDeviceList(""); })); })); var deviceEnumerator = new MMDeviceEnumerator(); deviceEnumerator.RegisterEndpointNotificationCallback(notificationClient); RefreshDeviceList(Properties.Settings.Default.LastDeviceName); Console.WriteLine($"Selected index: {inputDevicesComboBox.SelectedIndex}"); }
/// <summary> /// Deletes the registration of a notification interface that the client registered in a previous call to the <see cref="RegisterEndpointNotificationCallback"/> method. /// </summary> /// <param name="notificationClient">Implementation of the <see cref="IMMNotificationClient"/> which should be unregistered from any notifications.</param> /// <returns>HRESULT</returns> public unsafe int UnregisterEndpointNotificationCallbackNative(IMMNotificationClient notificationClient) { int result = 0; if (_notificationClients.Contains(notificationClient)) { result = InteropCalls.CallI(UnsafeBasePtr, Marshal.GetComInterfaceForObject(notificationClient, typeof(IMMNotificationClient)), ((void **)(*(void **)UnsafeBasePtr))[7]); //result = InteropCalls.CallI(UnsafeBasePtr, notificationClient, ((void**)(*(void**)UnsafeBasePtr))[7]); _notificationClients.Remove(notificationClient); } return(result); }
/// <summary> /// Unregisters a call back for Device Events /// </summary> /// <param name="client">Object implementing IMMNotificationClient type casted as IMMNotificationClient interface </param> /// <returns></returns> public int UnregisterEndpointNotificationCallback([In][MarshalAs(UnmanagedType.Interface)] IMMNotificationClient client) { if (!_notificationClients.Contains(client)) { return(0); } var hresult = _mmDeviceEnumerator.UnregisterEndpointNotificationCallback(client); Marshal.ThrowExceptionForHR(hresult); _notificationClients.Remove(client); return(hresult); }
private AudioInterfaceCollection() { _Context = SynchronizationContext.Current; _NotificationCallback = new AudioEndpointNotificationCallback(_Context); _NotificationClient = (IMMNotificationClient)_NotificationCallback; string installDirectory = InstallPath(); string runningDirectory = AppDomain.CurrentDomain.BaseDirectory; bool isInstalledVersion = installDirectory != null && runningDirectory == installDirectory; appdataPath = isInstalledVersion switch { true => Path.GetDirectoryName(ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath) + "\\", false => runningDirectory }; Initialise(); }
/// <summary> /// Deletes the registration of a notification interface that the client registered in a previous call to the <see cref="RegisterEndpointNotificationCallback"/> method. /// </summary> /// <param name="notificationClient">Implementation of the <see cref="IMMNotificationClient"/> which should be unregistered from any notifications.</param> public void UnregisterEndpointNotificationCallback(IMMNotificationClient notificationClient) { CoreAudioAPIException.Try(UnregisterEndpointNotificationCallbackNative(notificationClient), InterfaceName, "UnregisterEndpointNotificationCallback"); }
public void RegisterEndpointNotificationCallback(IMMNotificationClient pClient) { _realEnumerator.RegisterEndpointNotificationCallback(pClient); }
internal static unsafe int Calli(void *_basePtr, IMMNotificationClient client, void *p) { throw new NotImplementedException(); }
public void RegisterEndpointNotificationCallback(IMMNotificationClient client) { CoreAudioAPIException.Try(RegisterEndpointNotificationCallbackNative(client), c, "RegisterEndpointNotificationCallback"); }
public unsafe int RegisterEndpointNotificationCallbackNative(IMMNotificationClient client) { int result = InteropCalls.CallI(_basePtr, client, ((void **)(*(void **)_basePtr))[6]); return(result); }
public void UnregisterEndpointNotificationCallback(IMMNotificationClient pClient) { Marshal.ThrowExceptionForHR(((IMMDeviceEnumerator)_realEnumerator).UnregisterEndpointNotificationCallback(pClient)); }
public Worker(ILogger <Worker> logger, IMMNotificationClient notificationClient) { _logger = logger; _notificationClient = notificationClient; }
public static void RegisterEndpointNotificationCallback(IMMNotificationClient notificationClient) { _Enumerator.RegisterEndpointNotificationCallback(notificationClient); }
public void UnregisterEndpointNotificationCallback(IMMNotificationClient client) { _inner.UnregisterEndpointNotificationCallback(client); }
/// <summary> /// Deletes the registration of a notification interface that the client registered in a previous call /// to the <see cref="IMMDeviceEnumerator.RegisterEndpointNotificationCallback"/> method. /// </summary> /// <param name="client">A <see cref="IMMNotificationClient"/> interface that was previously registered for notification callbacks.</param> /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns> public void UnregisterEndpointNotificationCallback(IMMNotificationClient client) { Marshal.ThrowExceptionForHR(_realEnumerator.UnregisterEndpointNotificationCallback(client)); }
/// <summary> /// Registers a call back for Device Events /// </summary> /// <param name="client">Object implementing IMMNotificationClient type casted as IMMNotificationClient interface</param> /// <returns></returns> private int RegisterEndpointNotificationCallback([In][MarshalAs(UnmanagedType.Interface)] IMMNotificationClient client) { return(_enumerator.RegisterEndpointNotificationCallback(client)); }
public int RegisterEndpointNotificationCallback([MarshalAs(UnmanagedType.Interface)][In] IMMNotificationClient client) { return(this.realEnumerator.RegisterEndpointNotificationCallback(client)); }
public unsafe int UnregisterEndpointNotificationCallbackNative(IMMNotificationClient client) { return(InteropCalls.CallI(_basePtr, client, ((void **)(*(void **)_basePtr))[7])); }
public void UnregisterEndpointNotificationCallback(IMMNotificationClient client) { CoreAudioAPIException.Try(UnregisterEndpointNotificationCallbackNative(client), c, "UnregisterEndpointNotificationCallback"); }
internal static unsafe int CallI(void* _basePtr, IMMNotificationClient client, void* p) { throw new NotImplementedException(); }
public void UnregisterEndpointNotificationCallback(IMMNotificationClient client) { _realEnumerator.UnregisterEndpointNotificationCallback(client); }
/// <summary> /// Registers a client's notification callback interface. /// </summary> /// <param name="notificationClient">Implementation of the <see cref="IMMNotificationClient"/> which is should receive the notificaitons.</param> /// <returns>HRESULT</returns> public unsafe int RegisterEndpointNotificationCallbackNative(IMMNotificationClient notificationClient) { int result = InteropCalls.CallI(UnsafeBasePtr, notificationClient, ((void**) (*(void**) UnsafeBasePtr))[6]); return result; }
/// <summary> /// Deletes the registration of a notification interface that the client registered in a previous call to the <see cref="RegisterEndpointNotificationCallback"/> method. /// </summary> /// <param name="notificationClient">Implementation of the <see cref="IMMNotificationClient"/> which should be unregistered from any notifications.</param> /// <returns>HRESULT</returns> public unsafe int UnregisterEndpointNotificationCallbackNative(IMMNotificationClient notificationClient) { return InteropCalls.CallI(UnsafeBasePtr, notificationClient, ((void**) (*(void**) UnsafeBasePtr))[7]); }
/// <summary> /// Unregisters a call back for Device Events /// </summary> /// <param name="client">Object implementing IMMNotificationClient type casted as IMMNotificationClient interface </param> /// <returns></returns> public int UnregisterEndpointNotificationCallback( [In][MarshalAs(UnmanagedType.Interface)] IMMNotificationClient client) { return(realEnumerator.UnregisterEndpointNotificationCallback(client)); }
public static void RegisterCallback(IMMNotificationClient notificationClient) { var devEnm = new MMDeviceEnumerator(); devEnm.RegisterEndpointNotificationCallback(notificationClient); }