示例#1
0
SDP_PlugIn::SDP_PlugIn(const AudioDriverPlugInHostInfo& inHostInfo)
:
	HP_DriverPlugIn(inHostInfo),
	mEngineConnection(IO_OBJECT_NULL),
	mConnectionNotificationPort(NULL)
{
	//	create the Mach port for connection notifications
	mConnectionNotificationPort = new CACFMachPort((CFMachPortCallBack)MachPortCallBack, this);

	//  add the run loop source for the connection notifications
	AudioHardwareAddRunLoopSource(mConnectionNotificationPort->GetRunLoopSource());
	
	//	open a connection to the engine
	kern_return_t theKernelError = IOServiceOpen(mHostInfo.mIOAudioEngine, mach_task_self(), 0, &mEngineConnection);
	ThrowIfKernelError(theKernelError, CAException(theKernelError), "SDP_PlugIn::SDP_PlugIn: Cannot connect to the IOAudioEngine.");
	
	//	tell the connection about our notification mach_port_t
	theKernelError = IOConnectSetNotificationPort(mEngineConnection, 0, mConnectionNotificationPort->GetMachPort(), 0);
	ThrowIfKernelError(theKernelError, CAException(theKernelError), "SDP_PlugIn::SDP_PlugIn: Cannot set the device's notification port.");
}
示例#2
0
static inline void	HLCPUInfo_GetCPULoads(natural_t& outNumberCPUs, processor_cpu_load_info_t& outCPULoads, mach_msg_type_number_t& outCPULoadsSize)
{
	kern_return_t theError = host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &outNumberCPUs, (processor_info_array_t*)&outCPULoads, &outCPULoadsSize);
	ThrowIfKernelError(theError, CAException(theError), "HLCPUInfo_GetCPULoads: got an error getting the CPU load");
}