//-- /// <summary> /// Registers the application to receive ducking notifications. /// <seealso cref="RegisterDuckNotification"/> /// </summary> /// <param name="sessionId">A string that contains a session instance identifier. Applications that are playing a media stream and want to provide custom stream attenuation or ducking behavior, pass their own session instance identifier. /// Other applications that do not want to alter their streams but want to get all the ducking notifications must pass NULL.</param> /// <param name="sessionNotification">Instance of any object which implements the <see cref="IAudioVolumeDuckNotification"/> and which should receive duck notifications.</param> /// <returns>HRESULT</returns> public unsafe int RegisterDuckNotificationNative(string sessionId, IAudioVolumeDuckNotification sessionNotification) { int result = 0; if (!_volumeDuckNotifications.Contains(sessionNotification)) { IntPtr ptr = sessionNotification != null ? Marshal.GetComInterfaceForObject(sessionNotification, typeof(IAudioVolumeDuckNotification)) : IntPtr.Zero; IntPtr ptr0 = sessionId != null?Marshal.StringToHGlobalUni(sessionId) : IntPtr.Zero; try { result = InteropCalls.CallI(UnsafeBasePtr, (void *)ptr0, (void *)ptr, ((void **)(*(void **)UnsafeBasePtr))[8]); } finally { if (ptr != IntPtr.Zero) { Marshal.Release(ptr); } if (ptr0 != IntPtr.Zero) { Marshal.FreeHGlobal(ptr0); } } _volumeDuckNotifications.Add(sessionNotification); } return(result); }
/// <summary> /// Deletes the registration to receive ducking notifications. /// <seealso cref="UnregisterDuckNotification"/> /// </summary> /// <param name="sessionNotification"> /// The <see cref="IAudioVolumeDuckNotification"/> interface that is implemented by the application. Pass the same interface pointer that was specified to the session manager in a previous call to the <see cref="RegisterDuckNotification"/> method. /// </param> /// <returns>HRESULT</returns> public unsafe int UnregisterDuckNotificationNative(IAudioVolumeDuckNotification sessionNotification) { int result = 0; if (_volumeDuckNotifications.Contains(sessionNotification)) { IntPtr ptr = sessionNotification != null ? Marshal.GetComInterfaceForObject(sessionNotification, typeof(IAudioVolumeDuckNotification)) : IntPtr.Zero; try { result = InteropCalls.CallI(UnsafeBasePtr, (void *)ptr, ((void **)(*(void **)UnsafeBasePtr))[9]); } finally { if (ptr != IntPtr.Zero) { Marshal.Release(ptr); } } _volumeDuckNotifications.Remove(sessionNotification); } return(result); }
/// <summary> /// Deletes the registration to receive ducking notifications. /// </summary> /// <param name="sessionNotification"> /// The <see cref="IAudioVolumeDuckNotification"/> interface that is implemented by the application. Pass the same interface pointer that was specified to the session manager in a previous call to the <see cref="RegisterDuckNotification"/> method. /// </param> public void UnregisterDuckNotification(IAudioVolumeDuckNotification sessionNotification) { CoreAudioAPIException.Try(UnregisterDuckNotificationNative(sessionNotification), InterfaceName, "UnregisterDuckNotification"); }
/// <summary> /// Registers the application to receive ducking notifications. /// </summary> /// <param name="sessionId">A string that contains a session instance identifier. Applications that are playing a media stream and want to provide custom stream attenuation or ducking behavior, pass their own session instance identifier. /// Other applications that do not want to alter their streams but want to get all the ducking notifications must pass NULL.</param> /// <param name="sessionNotification">Instance of any object which implements the <see cref="IAudioVolumeDuckNotification"/> and which should receive duck notifications.</param> public void RegisterDuckNotification(string sessionId, IAudioVolumeDuckNotification sessionNotification) { CoreAudioAPIException.Try(RegisterDuckNotificationNative(sessionId, sessionNotification), InterfaceName, "RegisterDuckNotification"); }
/// <summary> /// Deletes the registration to receive ducking notifications. /// <seealso cref="UnregisterDuckNotification"/> /// </summary> /// <param name="sessionNotification"> /// The <see cref="IAudioVolumeDuckNotification"/> interface that is implemented by the application. Pass the same interface pointer that was specified to the session manager in a previous call to the <see cref="RegisterDuckNotification"/> method. /// </param> /// <returns>HRESULT</returns> public unsafe int UnregisterDuckNotificationNative(IAudioVolumeDuckNotification sessionNotification) { int result = 0; if (_volumeDuckNotifications.Contains(sessionNotification)) { IntPtr ptr = sessionNotification != null ? Marshal.GetComInterfaceForObject(sessionNotification, typeof(IAudioVolumeDuckNotification)) : IntPtr.Zero; try { result = InteropCalls.CallI(UnsafeBasePtr, (void*)ptr, ((void**)(*(void**)UnsafeBasePtr))[9]); } finally { if (ptr != IntPtr.Zero) { Marshal.Release(ptr); } } _volumeDuckNotifications.Remove(sessionNotification); } return result; }
//-- /// <summary> /// Registers the application to receive ducking notifications. /// <seealso cref="RegisterDuckNotification"/> /// </summary> /// <param name="sessionId">A string that contains a session instance identifier. Applications that are playing a media stream and want to provide custom stream attenuation or ducking behavior, pass their own session instance identifier. /// Other applications that do not want to alter their streams but want to get all the ducking notifications must pass NULL.</param> /// <param name="sessionNotification">Instance of any object which implements the <see cref="IAudioVolumeDuckNotification"/> and which should receive duck notifications.</param> /// <returns>HRESULT</returns> public unsafe int RegisterDuckNotificationNative(string sessionId, IAudioVolumeDuckNotification sessionNotification) { int result = 0; if (!_volumeDuckNotifications.Contains(sessionNotification)) { IntPtr ptr = sessionNotification != null ? Marshal.GetComInterfaceForObject(sessionNotification, typeof(IAudioVolumeDuckNotification)) : IntPtr.Zero; IntPtr ptr0 = sessionId != null ? Marshal.StringToHGlobalUni(sessionId) : IntPtr.Zero; try { result = InteropCalls.CallI(UnsafeBasePtr, (void*)ptr0, (void*)ptr, ((void**)(*(void**)UnsafeBasePtr))[8]); } finally { if (ptr != IntPtr.Zero) Marshal.Release(ptr); if (ptr0 != IntPtr.Zero) Marshal.FreeHGlobal(ptr0); } _volumeDuckNotifications.Add(sessionNotification); } return result; }
/// <summary> /// Deletes the registration to receive ducking notifications. /// </summary> /// <param name="sessionNotification"> /// The <see cref="IAudioVolumeDuckNotification"/> interface that is implemented by the application. Pass the same interface pointer that was specified to the session manager in a previous call to the <see cref="RegisterDuckNotification"/> method. /// </param> public void UnregisterDuckNotification(IAudioVolumeDuckNotification sessionNotification) { UnregisterDuckNotificationNative(sessionNotification); }