Ejemplo n.º 1
0
void transferData(IOUSBInterfaceInterface245 **intf, UInt8 inPipeRef, UInt8 outPipeRef)
{
    IOReturn			err;
    CFRunLoopSourceRef		cfSource;
    int				i;
    
    err = (*intf)->CreateInterfaceAsyncEventSource(intf, &cfSource);
    if (err)
    {
	printf("transferData: unable to create event source, err = %08x\n", err);
	return;
    }
    CFRunLoopAddSource(CFRunLoopGetCurrent(), cfSource, kCFRunLoopDefaultMode);
    for (i=0; i < 12; i++)
	outBuf[i] = 'R';
    err = (*intf)->WritePipeAsync(intf, outPipeRef, outBuf, 12, (IOAsyncCallback1)MyCallBackFunction, (void*)(UInt32)inPipeRef);
    if (err)
    {
	printf("transferData: WritePipeAsyncFailed, err = %08x\n", err);
	CFRunLoopRemoveSource(CFRunLoopGetCurrent(), cfSource, kCFRunLoopDefaultMode);
	return;
    }
    printf("transferData: calling CFRunLoopRun\n");
    CFRunLoopRun();
    printf("transferData: returned from  CFRunLoopRun\n");
    CFRunLoopRemoveSource(CFRunLoopGetCurrent(), cfSource, kCFRunLoopDefaultMode);
}
Ejemplo n.º 2
0
void CCocoaPowerSyscall::DeleteOSPowerCallBacks(void)
{
#if !defined(TARGET_DARWIN_IOS)
  CCocoaAutoPool autopool;
  // we no longer want sleep/wake notifications
  // remove the sleep notification port from the application runloop
  CFRunLoopRemoveSource( CFRunLoopGetCurrent(),
    IONotificationPortGetRunLoopSource(m_notify_port), kCFRunLoopDefaultMode );
  // deregister for system sleep notifications
  IODeregisterForSystemPower(&m_notifier_object);
  // IORegisterForSystemPower implicitly opens the Root Power Domain IOService
  // so we close it here
  IOServiceClose(m_root_port);
  // destroy the notification port allocated by IORegisterForSystemPower
  IONotificationPortDestroy(m_notify_port);
  
  // we no longer want power source change notifications
  if (m_HasBattery)
  {
    if (m_power_source)
    {
      CFRunLoopRemoveSource( CFRunLoopGetCurrent(), m_power_source, kCFRunLoopDefaultMode );
      CFRelease(m_power_source);
    }
  }
#endif
}
Ejemplo n.º 3
0
void SocketStreamHandle::removePACRunLoopSource()
{
    ASSERT(m_pacRunLoopSource);

    CFRunLoopSourceInvalidate(m_pacRunLoopSource.get());
#if PLATFORM(WIN)
    CFRunLoopRemoveSource(loaderRunLoop(), m_pacRunLoopSource.get(), kCFRunLoopDefaultMode);
#else
    CFRunLoopRemoveSource(CFRunLoopGetCurrent(), m_pacRunLoopSource.get(), kCFRunLoopCommonModes);
#endif
    m_pacRunLoopSource = 0;
}
Ejemplo n.º 4
0
void CFRunLoopRemoveMIDIRunLoopSource( CFRunLoopRef rl, struct CFMIDIRunLoopSource * source, CFStringRef mode ) {
  int i;
  if( source->cfrlt != NULL ) CFRunLoopRemoveTimer( rl, source->cfrlt, mode );
  for( i=0; i<source->length; i++ ) {
    if( source->cfrls[i] != NULL ) CFRunLoopRemoveSource( rl, source->cfrls[i], mode );
  }
}
Ejemplo n.º 5
0
    void mac_sleep_stop()
    {
      if (root_port)
	{
	  // remove the sleep notification port from the application runloop
	  CFRunLoopRemoveSource(CFRunLoopGetCurrent(),
				IONotificationPortGetRunLoopSource(notifyPortRef),
				kCFRunLoopCommonModes);

	  // deregister for system sleep notifications
	  IODeregisterForSystemPower(&notifierObject);

	  // IORegisterForSystemPower implicitly opens the Root Power Domain IOService
	  // so we close it here
	  IOServiceClose(root_port);

	  // destroy the notification port allocated by IORegisterForSystemPower
	  IONotificationPortDestroy(notifyPortRef);

	  // reset object members
	  root_port = 0;
	  notifyPortRef = NULL;
	  notifierObject = 0;
	}
    }
Ejemplo n.º 6
0
/*
 * CFRunloop callback that calls DNSServiceProcessResult() when
 * there's new data on the socket.
 */
static void
socket_callback(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void *data, void *context)
{
	struct cbinfo *info = context;
	DNSServiceErrorType err;

	if (callbackType == kCFSocketNoCallBack) {
		printf("socket_callback: kCFSocketNoCallBack?\n");
		return;
	}

	if ((err = DNSServiceProcessResult(info->sdref)) != kDNSServiceErr_NoError) {
		printf("DNSServiceProcessResult() returned an error! %d\n", err);
		if (err == kDNSServiceErr_BadReference) {
			printf("bad reference?: %p, %d, %p, %p %p\n", s, (int)callbackType, address, data, context);
			return;
		}
		if ((context == &nfsinfo) || (context == &mountdinfo)) {
			/* bail if there's a problem with the main browse connection */
			exit(1);
		}
		/* dump the troublesome service connection */
		CFRunLoopRemoveSource(CFRunLoopGetCurrent(), info->rls, kCFRunLoopDefaultMode);
		CFRelease(info->rls);
		CFSocketInvalidate(info->sockref);
		CFRelease(info->sockref);
		DNSServiceRefDeallocate(info->sdref);
		free(info);
	}
}
Ejemplo n.º 7
0
void IOKitEventPublisher::stop() {
  if (run_loop_ == nullptr) {
    // If there is no run loop then the publisher thread has not started.
    return;
  }

  // Stop the run loop.
  WriteLock lock(mutex_);
  CFRunLoopStop(run_loop_);

  // Stop the run loop before operating on containers.
  // Destroy the IOPort.
  if (port_ != nullptr) {
    auto source = IONotificationPortGetRunLoopSource(port_);
    if (CFRunLoopContainsSource(run_loop_, source, kCFRunLoopDefaultMode)) {
      CFRunLoopRemoveSource(run_loop_, source, kCFRunLoopDefaultMode);
    }
    // And destroy the port.
    IONotificationPortDestroy(port_);
    port_ = nullptr;
  }

  // Clear all devices and their notifications.
  for (const auto& device : devices_) {
    IOObjectRelease(device->notification);
  }
  devices_.clear();
}
Ejemplo n.º 8
0
void
xmmsc_mainloop_cf_shutdown (xmmsc_connection_t *c, CFRunLoopSourceRef source)
{
	CFRunLoopRef runLoopRef = CFRunLoopGetCurrent ();

	CFRunLoopRemoveSource (runLoopRef, source, kCFRunLoopDefaultMode);
}
Ejemplo n.º 9
0
void AoEProperties::matched_callback(void* pRefcon, io_iterator_t iterator)
{	
	io_registry_entry_t Object = IOIteratorNext(iterator);
	
	AoEProperties* pThis = (AoEProperties*) pRefcon;

	if ( Object )
	{
		//debug("AOEINTERFACE ONLINE!\n");
		if ( pThis )
			pThis->m_fMatched = TRUE;
	
		if ( pThis->m_OurObject )
			IOObjectRelease(pThis->m_OurObject);
		 
		 pThis->m_OurObject = Object;

		// Since we have matched, we remove our source from the run loop
		CFRunLoopRemoveSource(CFRunLoopGetCurrent(), ms_IOKitNotificationRunLoopSource, kCFRunLoopDefaultMode);
	}
	
	// Empty the remaining devices in the list (don't release the iterator though, or we won't get our callback)
	while( 0 != (Object=IOIteratorNext(iterator)) )
		IOObjectRelease(Object);
}
Ejemplo n.º 10
0
/* Cleanup of the open ports */
void PortsCleanup()
{
	CFRunLoopRemoveSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notifyPortRef), kCFRunLoopCommonModes);    /* Remove the notification port from the runloop */
	IODeregisterForSystemPower(&notifierObject);                                                                               /* Deregister from power notifications */
	IOServiceClose(root_power_port);                                                                                           /* Close the Root Power Domain IOService port */
	IONotificationPortDestroy(notifyPortRef);                                                                                  /* Destroy the notification port */
}
Ejemplo n.º 11
0
void DeviceNotification(void *		refCon,
                        io_service_t 	service,
                        natural_t 	messageType,
                        void *		messageArgument )
{
    UPSDataRef		upsDataRef = (UPSDataRef) refCon;

    if ( (upsDataRef != NULL) &&
         (messageType == kIOMessageServiceIsTerminated) )
    {
        upsDataRef->isPresent = FALSE;
        
        SCDynamicStoreRemoveValue(upsDataRef->upsStore, upsDataRef->upsStoreKey);

        if ( upsDataRef->upsEventSource )
        {
            CFRunLoopRemoveSource(CFRunLoopGetCurrent(), upsDataRef->upsEventSource, kCFRunLoopDefaultMode);
            CFRelease(upsDataRef->upsEventSource);
            upsDataRef->upsEventSource = NULL;
        }

        if ( upsDataRef->upsEventTimer )
        {
            CFRunLoopRemoveTimer(CFRunLoopGetCurrent(), upsDataRef->upsEventTimer, kCFRunLoopDefaultMode);
            CFRelease(upsDataRef->upsEventTimer);
            upsDataRef->upsEventTimer = NULL;
        }

        if (upsDataRef->upsPlugInInterface != NULL)
        {
            (*(upsDataRef->upsPlugInInterface))->Release (upsDataRef->upsPlugInInterface);
            upsDataRef->upsPlugInInterface = NULL;
        }
        
        if (upsDataRef->notification != MACH_PORT_NULL)
        {
            IOObjectRelease(upsDataRef->notification);
            upsDataRef->notification = MACH_PORT_NULL;
        }

        if (upsDataRef->upsStoreKey)
        {
            CFRelease(upsDataRef->upsStoreKey);
            upsDataRef->upsStoreKey = NULL;
        }

        if (upsDataRef->upsStoreDict)
        {
            CFRelease(upsDataRef->upsStoreDict);
            upsDataRef->upsStoreDict = NULL;
        }

        if (upsDataRef->upsStore)
        {
            CFRelease(upsDataRef->upsStore);
            upsDataRef->upsStore = NULL;
        }
    }
}
Ejemplo n.º 12
0
/*
    Removes the loop source for the given socket from the current run loop.
*/
void qt_mac_remove_socket_from_runloop(const CFSocketRef socket, CFRunLoopSourceRef runloop)
{
    Q_ASSERT(runloop);
    CFRunLoopRemoveSource(CFRunLoopGetCurrent(), runloop, kCFRunLoopCommonModes);
    CFSocketDisableCallBacks(socket, kCFSocketReadCallBack);
    CFSocketDisableCallBacks(socket, kCFSocketWriteCallBack);
    CFRunLoopSourceInvalidate(runloop);
}
Ejemplo n.º 13
0
void GSocketGUIFunctionsTableConcrete::Disable_Events(GSocket *socket)
{
    struct MacGSocketData* data = _GSocket_Get_Mac_Socket(socket);
    if (!data) return;

    /* CFSocketInvalidate does CFRunLoopRemoveSource anyway */
    CFRunLoopRemoveSource(s_mainRunLoop, data->source, kCFRunLoopCommonModes);
    CFSocketInvalidate(data->socket);
}
void* SC_MachMessagePort::Run()
{
    CFRunLoopSourceRef source = CFMessagePortCreateRunLoopSource(NULL, mServerPort, 0);
    CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopDefaultMode);
    CFRunLoopRun();
    CFRunLoopRemoveSource(CFRunLoopGetCurrent(), source, kCFRunLoopDefaultMode);
    CFRelease(source);
    delete this;
    return NULL;
}
Ejemplo n.º 15
0
/*! Deregisters the daemon with the kernel to no longer receive power events. */
void iSCSIDDeregisterForPowerEvents()
{
    CFRunLoopRemoveSource(CFRunLoopGetCurrent(),
                          IONotificationPortGetRunLoopSource(powerNotifyPortRef),
                          kCFRunLoopDefaultMode);

    IODeregisterForSystemPower(&powerNotifier);
    IOServiceClose(powerPlaneRoot);
    IONotificationPortDestroy(powerNotifyPortRef);
}
Ejemplo n.º 16
0
Archivo: app.cpp Proyecto: hgwells/tive
void wxApp::CleanUp()
{
#if wxUSE_TOOLTIPS
    wxToolTip::RemoveToolTips() ;
#endif

#ifdef __WXMAC_OSX__
    if (m_macEventPosted)
    {
        CFRunLoopRemoveSource(CFRunLoopGetCurrent(), m_macEventPosted, kCFRunLoopCommonModes);
        m_macEventPosted = NULL;
    }
#endif

    // One last chance for pending objects to be cleaned up
    wxTheApp->DeletePendingObjects();

    wxMacDestroyNotifierTable() ;

#ifndef __DARWIN__
#  if __option(profile)
    ProfilerDump( (StringPtr)"\papp.prof" ) ;
    ProfilerTerm() ;
#  endif
#endif

    UMACleanupToolbox() ;

    if (!sm_isEmbedded)
        RemoveEventHandler( (EventHandlerRef)(wxTheApp->m_macEventHandler) );

    if (!sm_isEmbedded)
    {
        AERemoveEventHandler( kCoreEventClass , kAEOpenDocuments ,
                              sODocHandler , FALSE ) ;
        AERemoveEventHandler( kCoreEventClass , kAEOpenApplication ,
                              sOAppHandler , FALSE ) ;
        AERemoveEventHandler( kCoreEventClass , kAEPrintDocuments ,
                              sPDocHandler , FALSE ) ;
        AERemoveEventHandler( kCoreEventClass , kAEReopenApplication ,
                              sRAppHandler , FALSE ) ;
        AERemoveEventHandler( kCoreEventClass , kAEQuitApplication ,
                              sQuitHandler , FALSE ) ;

        DisposeAEEventHandlerUPP( sODocHandler ) ;
        DisposeAEEventHandlerUPP( sOAppHandler ) ;
        DisposeAEEventHandlerUPP( sPDocHandler ) ;
        DisposeAEEventHandlerUPP( sRAppHandler ) ;
        DisposeAEEventHandlerUPP( sQuitHandler ) ;
    }

    wxAppBase::CleanUp();
}
Ejemplo n.º 17
0
static void DestroyInterfaceChangedObserver_MacDesktop(OsContext* aContext)
{
    if (NULL != aContext->iInterfaceChangedObserver)
    {
        CFRunLoopRef runLoop = CFRunLoopGetMain();
        CFRunLoopRemoveSource(runLoop, aContext->iInterfaceChangedObserver->iRunLoopSource, kCFRunLoopCommonModes);
        CFRelease(aContext->iInterfaceChangedObserver->iStore);
        CFRelease(aContext->iInterfaceChangedObserver->iRunLoopSource);
        free(aContext->iInterfaceChangedObserver);
        aContext->iInterfaceChangedObserver = NULL;
    }
}
Ejemplo n.º 18
0
void
COSXScreen::watchSystemPowerThread(void*)
{
	io_object_t				notifier;
	IONotificationPortRef	notificationPortRef;
	CFRunLoopSourceRef		runloopSourceRef = 0;

	m_pmRunloop = CFRunLoopGetCurrent();
	// install system power change callback
	m_pmRootPort = IORegisterForSystemPower(this, &notificationPortRef,
											powerChangeCallback, &notifier);
	if (m_pmRootPort == 0) {
		LOG((CLOG_WARN "IORegisterForSystemPower failed"));
	}
	else {
		runloopSourceRef =
			IONotificationPortGetRunLoopSource(notificationPortRef);
		CFRunLoopAddSource(m_pmRunloop, runloopSourceRef,
								kCFRunLoopCommonModes);
	}
	
	// thread is ready
	{
		CLock lock(m_pmMutex);
		*m_pmThreadReady = true;
		m_pmThreadReady->signal();
	}

	// if we were unable to initialize then exit.  we must do this after
	// setting m_pmThreadReady to true otherwise the parent thread will
	// block waiting for it.
	if (m_pmRootPort == 0) {
		return;
	}

	// start the run loop
	LOG((CLOG_DEBUG "started watchSystemPowerThread"));
	CFRunLoopRun();
	
	// cleanup
	if (notificationPortRef) {
		CFRunLoopRemoveSource(m_pmRunloop,
								runloopSourceRef, kCFRunLoopDefaultMode);
		CFRunLoopSourceInvalidate(runloopSourceRef);
		CFRelease(runloopSourceRef);
	}

	CLock lock(m_pmMutex);
	IODeregisterForSystemPower(&notifier);
	m_pmRootPort = 0;
	LOG((CLOG_DEBUG "stopped watchSystemPowerThread"));
}
Ejemplo n.º 19
0
static void unsetup_runloop(mailstream_low * s)
{
  struct mailstream_cfstream_data * cfstream_data;
  
  cfstream_data = (struct mailstream_cfstream_data *) s->data;
  
  pthread_mutex_lock(&cfstream_data->runloop_lock);
  
  if (cfstream_data->idleInterruptedSource != NULL) {
    CFRunLoopRemoveSource(cfstream_data->runloop, cfstream_data->idleInterruptedSource, kCFRunLoopDefaultMode);
  }
  if (cfstream_data->cancelSource != NULL) {
    CFRunLoopRemoveSource(cfstream_data->runloop, cfstream_data->cancelSource, kCFRunLoopDefaultMode);
  }
  if (cfstream_data->runloop != NULL) {
    CFRelease(cfstream_data->runloop);
    cfstream_data->runloop = NULL;
  }
  
  
  pthread_mutex_unlock(&cfstream_data->runloop_lock);
}
Ejemplo n.º 20
0
void fxPerformJob(void* it) 
{
	txJob* job = it;
	txMachine* the = job->the;
	fxBeginHost(the);
	{
		fxRunPromiseJobs(the);
	}
	fxEndHost(the);
#if mxMacOSX
	CFRunLoopRemoveSource(CFRunLoopGetCurrent(), job->source, gxRunLoopMode);
#endif
	c_free(job);
}
Ejemplo n.º 21
0
//------------------------------------------------------------------------------
// IOMIGMachPortUnscheduleFromRunLoop
//------------------------------------------------------------------------------
void IOMIGMachPortUnscheduleFromRunLoop(IOMIGMachPortRef migPort, CFRunLoopRef runLoop, CFStringRef runLoopMode)
{
    if ( !runLoop || !runLoopMode || !migPort->runLoop || !migPort->runLoopMode)
        return;
        
    if ( !CFEqual(runLoop, migPort->runLoop) || !CFEqual(runLoopMode, migPort->runLoopMode) )
        return;
        
    migPort->runLoop     = NULL;
    migPort->runLoopMode = NULL;
    
    if ( migPort->source )
        CFRunLoopRemoveSource(runLoop, migPort->source, runLoopMode);
}
Ejemplo n.º 22
0
IOReturn asyncTransferData(IOUSBInterfaceInterface300 ***intf, char *outBuf, int len){
	
    IOReturn				err;
    CFRunLoopSourceRef		cfSource;
    

    err = (**intf)->CreateInterfaceAsyncEventSource(*intf, &cfSource);
    IO_ERR(3, "transferData: Create Interface Async Event Source", err);

    CFRunLoopAddSource(CFRunLoopGetCurrent(), cfSource, kCFRunLoopDefaultMode);
  
    err = (**intf)->WritePipeAsync(*intf, 2, outBuf, 8, (IOAsyncCallback1)asyncWriteCB, (void*)(UInt32)1);
    IO_ERR(3, "transferData: Write Async Pipe", err);
	if (err) {
		CFRunLoopRemoveSource(CFRunLoopGetCurrent(), cfSource, kCFRunLoopDefaultMode);
		return err;
	}
    CFRunLoopRun();
    displayError(3, "returned from CFRunLoopRun", "transferData");
	CFRunLoopRemoveSource(CFRunLoopGetCurrent(), cfSource, kCFRunLoopDefaultMode);
	
	return err;
}
void SystemEventsManager::stopLoop(bool forceStop) {
    if (systemEventLoopRunning && (forceStop || allEventsDisabled())) {
        CFRunLoopRemoveSource(CFRunLoopGetCurrent(),
                              IONotificationPortGetRunLoopSource(notifyPortRef),
                              kCFRunLoopCommonModes);
        IODeregisterForSystemPower(&notifierObject);
        IOServiceClose(rootPort);
        IONotificationPortDestroy(notifyPortRef);
        
        CFRunLoopStop(CFRunLoopGetCurrent());
        
        systemEventLoopRunning = false;
    }
}
Ejemplo n.º 24
0
static void
cleanupKicker(kickeeRef target)
{
	CFStringRef		name	= CFDictionaryGetValue(target->dict, CFSTR("name"));

	SCLog(TRUE, LOG_NOTICE,
	      CFSTR("  target=%@: disabled"),
	      name);
	CFRunLoopRemoveSource(target->rl, target->rls, kCFRunLoopDefaultMode);
	CFRelease(target->rls);
	CFRelease(target->store);
	if (target->dict)		CFRelease(target->dict);
	if (target->changedKeys)	CFRelease(target->changedKeys);
	CFAllocatorDeallocate(NULL, target);
}
Ejemplo n.º 25
0
CF_EXPORT void
rwsched_tasklet_CFRunLoopRemoveSource(rwsched_tasklet_ptr_t sched_tasklet,
                                      rwsched_CFRunLoopRef rl,
                                      rwsched_CFRunLoopSourceRef source,
                                      CFStringRef mode)
{
    // Validate input paraemters
    RW_CF_TYPE_VALIDATE(sched_tasklet, rwsched_tasklet_ptr_t);
    rwsched_instance_ptr_t instance = sched_tasklet->instance;
    RW_CF_TYPE_VALIDATE(instance, rwsched_instance_ptr_t);
    // RW_CF_TYPE_VALIDATE(rl, rwsched_CFRunLoopRef);
    RW_CF_TYPE_VALIDATE(source, rwsched_CFRunLoopSourceRef);

    // Call the native CFRunLoop function
    CFRunLoopRemoveSource(rl, source->cf_object, mode);
}
Ejemplo n.º 26
0
int
key_cleanup(void)
{
	if (eventTap == NULL) {
		warnx("key cleanup called with nothing to cleanup");
		return -1;
	}

	CFRunLoopRemoveSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes);

	CFRelease(eventTap);
	CFRelease(runLoopSource);
	eventTap = NULL;

	return 0;
}
Ejemplo n.º 27
0
HostPowerServiceDarwin::~HostPowerServiceDarwin()
{
    /* Jump out of the run loop. */
    CFRunLoopStop(mRunLoop);
    /* Remove the sleep notification port from the application runloop. */
    CFRunLoopRemoveSource(CFRunLoopGetCurrent(),
                          IONotificationPortGetRunLoopSource(mNotifyPort),
                          kCFRunLoopCommonModes);
    /* Deregister for system sleep notifications. */
    IODeregisterForSystemPower(&mNotifierObject);
    /* IORegisterForSystemPower implicitly opens the Root Power Domain
     * IOService so we close it here. */
    IOServiceClose(mRootPort);
    /* Destroy the notification port allocated by IORegisterForSystemPower */
    IONotificationPortDestroy(mNotifyPort);
}
Ejemplo n.º 28
0
void DestroyApplicationNotifications()
{
    if(!KWMFocus.Observer)
        return;

    AXObserverRemoveNotification(KWMFocus.Observer, KWMFocus.Application, kAXWindowMiniaturizedNotification);
    AXObserverRemoveNotification(KWMFocus.Observer, KWMFocus.Application, kAXWindowMovedNotification);
    AXObserverRemoveNotification(KWMFocus.Observer, KWMFocus.Application, kAXWindowResizedNotification);
    AXObserverRemoveNotification(KWMFocus.Observer, KWMFocus.Application, kAXTitleChangedNotification);
    CFRunLoopRemoveSource(CFRunLoopGetCurrent(), AXObserverGetRunLoopSource(KWMFocus.Observer), kCFRunLoopDefaultMode);

    CFRelease(KWMFocus.Observer);
    KWMFocus.Observer = NULL;
    CFRelease(KWMFocus.Application);
    KWMFocus.Application = NULL;
}
/**
 * Destroys a keyboard cache entry.
 *
 * @param   pKeyboardEntry      The entry.
 */
static void darwinHIDKeyboardCacheDestroyEntry(struct KeyboardCacheData *pKeyboardEntry)
{
    unsigned long cRefs;

    /*
     * Destroy the queue
     */
    if (pKeyboardEntry->ppHidQueueInterface)
    {
        IOHIDQueueInterface **ppHidQueueInterface = pKeyboardEntry->ppHidQueueInterface;
        pKeyboardEntry->ppHidQueueInterface = NULL;

        /* stop it just in case we haven't done so. doesn't really matter I think. */
        (*ppHidQueueInterface)->stop(ppHidQueueInterface);

        /* deal with the run loop source. */
        CFRunLoopSourceRef RunLoopSrcRef = (*ppHidQueueInterface)->getAsyncEventSource(ppHidQueueInterface);
        if (RunLoopSrcRef)
        {
            CFRunLoopRef RunLoopRef = (CFRunLoopRef)GetCFRunLoopFromEventLoop(GetMainEventLoop());
            CFRunLoopRemoveSource(RunLoopRef, RunLoopSrcRef, kCFRunLoopDefaultMode);

            CFRelease(RunLoopSrcRef);
        }

        /* dispose of and release the queue. */
        (*ppHidQueueInterface)->dispose(ppHidQueueInterface);
        cRefs = (*ppHidQueueInterface)->Release(ppHidQueueInterface); MY_CHECK_CREFS(cRefs);
    }

    /*
     * Release the removal hook?
     */
    /** @todo */

    /*
     * Close and release the device interface.
     */
    if (pKeyboardEntry->ppHidDeviceInterface)
    {
        IOHIDDeviceInterface **ppHidDeviceInterface = pKeyboardEntry->ppHidDeviceInterface;
        pKeyboardEntry->ppHidDeviceInterface = NULL;

        (*ppHidDeviceInterface)->close(ppHidDeviceInterface);
        cRefs = (*ppHidDeviceInterface)->Release(ppHidDeviceInterface); MY_CHECK_CREFS(cRefs);
    }
}
Ejemplo n.º 30
0
void IOFireWireSBP2LibLUN::removeIODispatcherFromRunLoop( void )
{
    if( fCFRunLoopSource != NULL )
    {
        CFRunLoopRemoveSource( fCFRunLoop, fCFRunLoopSource, kCFRunLoopCommonModes );
        CFRelease( fCFRunLoopSource );
        fCFRunLoopSource = NULL;
    }

    if( fCFAsyncPort != NULL )
    {
        FWLOG(( "IOFireWireSBP2LibLUN : release fCFAsyncPort\n" ));
        CFMachPortInvalidate( fCFAsyncPort );
        CFRelease( fCFAsyncPort );
        fCFAsyncPort = NULL;
    }
}