public void ScheduleInCFRunLoop (CFRunLoop runloop, NSString mode) { if (notifying) return; notifying = true; Notify (CFStreamEventType.HasBytesAvailable); notifying = false; }
/// <summary> /// Removes a CFRunLoopSource. Necessary because we can't directly construct CFRunLoopSource from native IntPtr values in MonoMac. /// </summary> /// <param name="loop">The CFRunLoop from which the source is to be removed.</param> /// <param name="source">The CFRunLoopSource to remove.</param> /// <param name="mode">The mode for the run loop.</param> /// <returns><c>true</c> if the CFRunLoopSource was removed.</returns> public static bool CFRunLoopRemoveSource(CFRunLoop loop, System.IntPtr source, NSString mode) { if (mode == null) { throw new System.ArgumentNullException("mode"); } return(CFRunLoopRemoveSource(loop.Handle, source, mode.Handle)); }
/// <summary> /// Adds a CFRunLoopSource. Necessary because we can't directly construct CFRunLoopSource from native IntPtr values in MonoMac. /// </summary> /// <param name="loop">The CFRunLoop to which the source is to be added.</param> /// <param name="source">The CFRunLoopSource to add.</param> /// <param name="mode">The mode for the run loop.</param> public static void CFRunLoopAddSource(CFRunLoop loop, System.IntPtr source, NSString mode) { if (mode == null) { throw new System.ArgumentNullException("mode"); } CFRunLoopAddSource(loop.Handle, source, mode.Handle); }
public void ScheduleInCFRunLoop(CFRunLoop runloop, NSString mode) { if (notifying) { return; } notifying = true; Notify(CFStreamEventType.HasBytesAvailable); notifying = false; }
public bool Schedule(CFRunLoop runLoop, string mode) { if (runLoop == null) { throw new ArgumentNullException("runLoop"); } // new CFString already does a null check using (var cfstring = new CFString(mode)){ return(SCNetworkReachabilityScheduleWithRunLoop(handle, runLoop.Handle, cfstring.Handle)); } }
public void UnscheduleFromRunLoop(CFRunLoop runLoop, NSString mode) { ThrowIfDisposed(); if (runLoop == null) { throw new ArgumentNullException("runLoop"); } if (mode == null) { throw new ArgumentNullException("mode"); } IOHIDManagerUnscheduleFromRunLoop(Handle, runLoop.Handle, mode.Handle); }
public void ScheduleWithRunLoop(CFRunLoop runLoop, NSString runLoopMode) { ThrowIfDisposed(); if (runLoop == null) { throw new ArgumentNullException("runLoop"); } if (runLoopMode == null) { throw new ArgumentNullException("runLoopMode"); } IOHIDDeviceScheduleWithRunLoop(Handle, runLoop.Handle, runLoopMode.Handle); }
public AudioServicesError AddSystemSoundCompletion(Action routine, CFRunLoop runLoop = null) { if (gc_handle.IsAllocated) { throw new ArgumentException("Only single completion routine is supported"); } gc_handle = GCHandle.Alloc(this); completionRoutine = routine; return(AudioServicesAddSystemSoundCompletion(soundId, runLoop == null ? IntPtr.Zero : runLoop.Handle, IntPtr.Zero, // runLoopMode should be enum runLoopMode == null ? IntPtr.Zero : runLoopMode.Handle, SoundCompletionCallback, GCHandle.ToIntPtr(gc_handle))); }
public bool Unschedule(CFRunLoop runLoop, string mode) { if (runLoop == null) { throw new ArgumentNullException("runLoop"); } if (mode == null) { throw new ArgumentNullException("mode"); } using (var cfstring = new CFString(mode)){ return(SCNetworkReachabilityUnscheduleFromRunLoop(handle, runLoop.Handle, cfstring.Handle) != 0); } }
public static void Initialize(CFRunLoop runLoop, string runMode) { CFString s = runMode == null ? null : new CFString(runMode); int k = AudioSessionInitialize(runLoop == null ? IntPtr.Zero : runLoop.Handle, s == null ? IntPtr.Zero : s.Handle, Interruption, IntPtr.Zero); if (k != 0 && k != (int)AudioSessionErrors.AlreadyInitialized) { throw new AudioSessionException(k); } if (initialized) { return; } IntPtr lib = Dlfcn.dlopen(Constants.AudioToolboxLibrary, 0); AudioRouteKey_Inputs = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSession_AudioRouteKey_Inputs")); AudioRouteKey_Outputs = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSession_AudioRouteKey_Outputs")); AudioRouteKey_Type = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSession_AudioRouteKey_Type")); InputRoute_LineIn = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSessionInputRoute_LineIn")); InputRoute_BuiltInMic = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSessionInputRoute_BuiltInMic")); InputRoute_HeadsetMic = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSessionInputRoute_HeadsetMic")); InputRoute_BluetoothHFP = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSessionInputRoute_BluetoothHFP")); InputRoute_USBAudio = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSessionInputRoute_USBAudio")); OutputRoute_LineOut = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSessionOutputRoute_LineOut")); OutputRoute_Headphones = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSessionOutputRoute_Headphones")); OutputRoute_BluetoothHFP = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSessionOutputRoute_BluetoothHFP")); OutputRoute_BluetoothA2DP = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSessionOutputRoute_BluetoothA2DP")); OutputRoute_BuiltInReceiver = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSessionOutputRoute_BuiltInReceiver")); OutputRoute_BuiltInSpeaker = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSessionOutputRoute_BuiltInSpeaker")); OutputRoute_USBAudio = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSessionOutputRoute_USBAudio")); OutputRoute_HDMI = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSessionOutputRoute_HDMI")); OutputRoute_AirPlay = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSessionOutputRoute_AirPlay")); InputSourceKey_ID = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSession_InputSourceKey_ID")); InputSourceKey_Description = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSession_InputSourceKey_Description")); OutputDestinationKey_ID = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSession_OutputDestinationKey_ID")); OutputDestinationKey_Description = new NSString(Dlfcn.GetIntPtr(lib, "kAudioSession_OutputDestinationKey_Description")); Dlfcn.dlclose(lib); initialized = true; }
public static void Initialize(CFRunLoop runLoop, string runMode) { if (initialized) { return; } CFString s = runMode == null ? null : new CFString(runMode); int k = AudioSessionInitialize(runLoop == null ? IntPtr.Zero : runLoop.Handle, s == null ? IntPtr.Zero : s.Handle, Interruption, IntPtr.Zero); if (k != 0) { throw new AudioSessionException(k); } initialized = true; }
public void Main() { source = new Source(this); loop = CFRunLoop.Current; loop.AddSource(source, CFRunLoop.ModeDefault); context = new Context(this); SynchronizationContext.SetSynchronizationContext(context); readyEvent.Set(); loop.Run(); cts.Dispose(); source.Dispose(); }
public OutputAudioQueue(AudioStreamBasicDescription desc, CFRunLoop runLoop, CFString runMode) { IntPtr h; GCHandle gch = GCHandle.Alloc(this); var code = AudioQueueNewOutput(ref desc, dOutputCallback, GCHandle.ToIntPtr(gch), runLoop == null ? IntPtr.Zero : runLoop.Handle, runMode == null ? IntPtr.Zero : runMode.Handle, 0, out h); if (code != 0) { gch.Free(); throw new AudioQueueException(code); } this.gch = gch; handle = h; }
public void StopWatchingMediaKeys() { if (tapThread != null) { tapThread.Stop(); tapThread = null; } if (eventPort != null) { eventPort.Invalidate(); eventPort.Dispose(); eventPort = null; } if (eventPortSource != null) { eventPortSource.Invalidate(); eventPortSource.Dispose(); eventPortSource = null; } }
public InputAudioQueue(AudioStreamBasicDescription desc, CFRunLoop runLoop, string runMode) { IntPtr h; GCHandle mygch = GCHandle.Alloc(this); CFString s = runMode == null ? null : new CFString(runMode); var code = AudioQueueNewInput(ref desc, dInputCallback, GCHandle.ToIntPtr(mygch), runLoop == null ? IntPtr.Zero : runLoop.Handle, s == null ? IntPtr.Zero : s.Handle, 0, out h); if (s != null) { s.Dispose(); } if (code == 0) { handle = h; gch = mygch; return; } gch.Free(); throw new AudioQueueException(code); }
protected abstract void ScheduleWithRunLoop(CFRunLoop loop, NSString mode);
public void EnableEvents(CFRunLoop runLoop, NSString runLoopMode) { if (open || closed || (loop != null)) throw new InvalidOperationException (); CheckHandle (); loop = runLoop; loopMode = runLoopMode; var ctx = new CFStreamClientContext (); ctx.Info = GCHandle.ToIntPtr (gch); var args = CFStreamEventType.OpenCompleted | CFStreamEventType.CanAcceptBytes | CFStreamEventType.HasBytesAvailable | CFStreamEventType.CanAcceptBytes | CFStreamEventType.ErrorOccurred | CFStreamEventType.EndEncountered; var ptr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (CFStreamClientContext))); try { Marshal.StructureToPtr (ctx, ptr, false); if (!DoSetClient (OnCallback, (int)args, ptr)) throw new InvalidOperationException ("Stream does not support async events."); } finally { Marshal.FreeHGlobal (ptr); } ScheduleWithRunLoop (runLoop, runLoopMode); }
public void Close() { if (!open) return; CheckHandle (); if (loop != null) { DoSetClient (null, 0, IntPtr.Zero); UnscheduleFromRunLoop (loop, loopMode); loop = null; loopMode = null; } try { DoClose (); } finally { open = false; closed = true; } }
public TestInputAudioQueue(AudioStreamBasicDescription desc, CFRunLoop runLoop, string runMode) : base(desc, runLoop, runMode) { }
protected override void OnCancel(CFRunLoop loop, CFRunLoopModeString mode) { ; }
protected override void OnSchedule(CFRunLoop loop, CFRunLoopModeString mode) { ; }
public OutputAudioQueue(AudioStreamBasicDescription desc, CFRunLoop runLoop, string runMode) : this(desc, runLoop, runMode == null ? null : new CFString(runMode)) { }
protected override void OnCancel(CFRunLoop loop, CFRunLoopString mode) { DebugOutput("IOService.FileSystemNotifcationPort.OnCancel()"); }
public override void ScheduleInCFRunLoop (CFRunLoop runloop, NSString mode) { Notify (CFStreamEventType.HasBytesAvailable); }
public void UnscheduleInCFRunLoop(CFRunLoop runloop, NSString mode) { // Nothing to do here }
public void ScheduleInCFRunLoop(CFRunLoop runloop, NSString mode) { Notify(CFStreamEventType.HasBytesAvailable); }
public override void UnscheduleInCFRunLoop (CFRunLoop runloop, NSString mode) { // Nothing to do here }
protected abstract void UnscheduleFromRunLoop(CFRunLoop loop, NSString mode);
public bool Schedule (CFRunLoop runLoop, string mode) { if (runLoop == null) throw new ArgumentNullException ("runLoop"); // new CFString already does a null check using (var cfstring = new CFString (mode)){ return SCNetworkReachabilityScheduleWithRunLoop (handle, runLoop.Handle, cfstring.Handle); } }
public void ScheduleWithRunLoop(CFRunLoop runLoop) { ScheduleWithRunLoop(runLoop, CFRunLoop.ModeDefault); }
public static extern void IOHIDManagerScheduleWithRunLoop( IOHIDManagerRef inIOHIDManagerRef, CFRunLoop inCFRunLoop, CFString inCFRunLoopMode);
public bool Unschedule (CFRunLoop runLoop, string mode) { if (runLoop == null) throw new ArgumentNullException ("runLoop"); if (mode == null) throw new ArgumentNullException ("mode"); using (var cfstring = new CFString (mode)){ return SCNetworkReachabilityUnscheduleFromRunLoop (handle, runLoop.Handle, cfstring.Handle) != 0; } }
public void ScheduleWithRunLoop(CFRunLoop runLoop, NSString runLoopMode) { CheckDisposed(); FSEventStreamScheduleWithRunLoop(handle, runLoop.Handle, runLoopMode.Handle); }
public static extern void IOHIDDeviceScheduleWithRunLoop( IOHIDDeviceRef device, CFRunLoop inCFRunLoop, CFString inCFRunLoopMode);
public void Stop() { CFRunLoop.Stop(); }
public CFSocket (AddressFamily family, SocketType type, ProtocolType proto, CFRunLoop loop) : this (CFSocketSignature.AddressFamilyToInt (family), CFSocketSignature.SocketTypeToInt (type), CFSocketSignature.ProtocolToInt (proto), loop) { }
void eventTapThread() { tapThread = CFRunLoop.Current; tapThread.AddSource(eventPortSource, CFRunLoop.ModeCommon); tapThread.Run(); }
public void WakeUp() { CFRunLoop.WakeUp(); }
public static extern void IOHIDManagerUnscheduleFromRunLoop( IOHIDManagerRef inIOHIDManagerRef, CFRunLoop inCFRunLoop, CFString inCFRunLoopMode);
public static extern void IOHIDDeviceUnscheduleWithRunLoop( IOHIDDeviceRef device, CFRunLoop inCFRunLoop, CFString inCFRunLoopMode);
public static extern void IOHIDDeviceUnscheduleFromRunLoop( IOHIDDeviceRef device, CFRunLoop inCFRunLoop, CFString inCFRunLoopMode);
public HIDInput() { Debug.Print("Using HIDInput."); RunLoop = CF.CFRunLoopGetMain(); if (RunLoop == IntPtr.Zero) RunLoop = CF.CFRunLoopGetCurrent(); if (RunLoop == IntPtr.Zero) { Debug.Print("[Error] No CFRunLoop found for {0}", GetType().FullName); throw new InvalidOperationException(); } CF.CFRetain(RunLoop); HandleDeviceAdded = DeviceAdded; HandleDeviceRemoved = DeviceRemoved; HandleDeviceValueReceived = DeviceValueReceived; // For retrieving input directly from the hardware hidmanager = CreateHIDManager(); if (hidmanager == IntPtr.Zero) { Debug.Print("[Mac] Failed to create IO HID manager, HIDInput driver not supported."); throw new NotSupportedException(); } RegisterHIDCallbacks(hidmanager); // For retrieving the global cursor position RegisterMouseMonitor(); }
CFSocket (int family, int type, int proto, CFRunLoop loop) { var cbTypes = CFSocketCallBackType.DataCallBack | CFSocketCallBackType.ConnectCallBack; gch = GCHandle.Alloc (this); var ctx = new CFStreamClientContext (); ctx.Info = GCHandle.ToIntPtr (gch); var ptr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof(CFStreamClientContext))); try { Marshal.StructureToPtr (ctx, ptr, false); handle = CFSocketCreate ( IntPtr.Zero, family, type, proto, cbTypes, OnCallback, ptr); } finally { Marshal.FreeHGlobal (ptr); } if (handle == IntPtr.Zero) throw new CFSocketException (CFSocketError.Error); gch = GCHandle.Alloc (this); var source = new CFRunLoopSource (CFSocketCreateRunLoopSource (IntPtr.Zero, handle, 0)); loop.AddSource (source, CFRunLoop.CFDefaultRunLoopMode); }