/// <summary> /// Unregisters a previously registered callback for the device volume change event. /// </summary> /// <returns> /// MLResult.Result will be <c>MLResult.Code.Ok</c> if successful. /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to internal error. /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if a parameter is invalid. /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if <c>AudioCaptureMic</c> privilege is denied. /// MLResult.Result will be <c>MLResult.Code.AudioNotImplemented</c> if the function is not implemented. /// </returns> private MLResult.Code UnregisterOnVolumeChangeCallback() { MLResult.Code result; try { // Unregister the native callback for the volume change event. result = NativeBindings.MLAudioSetMasterVolumeCallback(null, IntPtr.Zero); if (result != MLResult.Code.Ok) { MLPluginLog.ErrorFormat("MLAudio.UnregisterOnVolumeChangeCallback failed to register callback. Reason: {0}", result); } } catch (System.DllNotFoundException) { MLPluginLog.Error(this.DllNotFoundError); throw; } return(result); }
/// <summary> /// Registers a callback for the device volume change event. /// </summary> /// <returns> /// MLResult.Result will be <c>MLResult.Code.Ok</c> if successful. /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to internal error. /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if a parameter is invalid. /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if <c>AudioCaptureMic</c> privilege is denied. /// MLResult.Result will be <c>MLResult.Code.AudioNotImplemented</c> if the function is not implemented. /// </returns> private MLResult.Code RegisterOnVolumeChangeCallback() { MLResult.Code result; try { // Attempt to register the native callback for the volume change event. result = NativeBindings.MLAudioSetMasterVolumeCallback(HandleOnMLAudioSetMasterVolumeCallback, IntPtr.Zero); if (result != MLResult.Code.Ok) { MLPluginLog.ErrorFormat("MLAudio.RegisterOnVolumeChangeCallback failed to register callback. Reason: {0}", result); } } catch (System.DllNotFoundException) { // Exception is caught in the Singleton BaseStart(). throw; } return(result); }