I need to receive an event when some process starts using the camera. I did this through CMIOObjectGetPropertyData. But it does not work correctly, the correct value is only the first time it is accessed.
I also tried to use the CMIOObjectAddPropertyListenerBlock but he did not work it from me. Tell me please, what am I doing wrong? I will be very grateful.
while (1)
{
UInt32 value = 0;
UInt32 valuePropertySize = sizeof(flag);
CMIOObjectPropertyAddress opa = {kCMIODevicePropertyDeviceIsRunningSomewhere,
kAudioObjectPropertyScopeWildcard, kAudioObjectPropertyElementMaster};
OSStatus result = CMIOObjectGetPropertyData(device, &opa, 0, NULL, sizeof(UInt32), &valuePropertySize, &value);
NSLog(@"%d : %d", result, value);
sleep(1);
}