コード例 #1
0
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	// DeviceRemoved()
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	void PlugIn::DeviceRemoved(Device& device)
	{
		// Suspend the device
		device.Unplug();

		// Save it's settings if necessary
		if (DALA::System::IsMaster())
			DP::DeviceSettings::SaveToPrefs(device, DP::DeviceSettings::sStandardControlsToSave, DP::DeviceSettings::kStandardNumberControlsToSave);

		{
			// Unlock the mutex since CMIOObjectsPublishedAndDied() can callout to property listeners
			CAMutex::Unlocker unlocker(GetStateMutex());

			// Tell the DAL that the device has gone away
			CMIOObjectID objectID = device.GetObjectID();
			OSStatus err = CMIOObjectsPublishedAndDied(GetInterface(), kCMIOObjectSystemObject, 0, 0, 1, &objectID);
			AssertNoError(err, "CMIO::DP::Sample::PlugIn::Teardown: got an error telling the DAL a device died");
		}
						
		// Remove it from the device list
		RemoveDevice(device);

		// Get rid of the device object
		device.Teardown();
		delete &device;
	}