diff --git a/src/detection/brightness/brightness_apple.c b/src/detection/brightness/brightness_apple.c index 4c58b5e6a..52b0cee32 100644 --- a/src/detection/brightness/brightness_apple.c +++ b/src/detection/brightness/brightness_apple.c @@ -61,24 +61,27 @@ static const char* detectWithDdcci(FF_MAYBE_UNUSED const FFDisplayServerResult* if(IOServiceGetMatchingServices(MACH_PORT_NULL, IOServiceMatching("DCPAVServiceProxy"), &iterator) != kIOReturnSuccess) return "IOServiceGetMatchingServices() failed"; - FF_STRBUF_AUTO_DESTROY location = ffStrbufCreate(); - io_registry_entry_t registryEntry; while((registryEntry = IOIteratorNext(iterator)) != 0) { - CFMutableDictionaryRef properties; - if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess) { - IOObjectRelease(registryEntry); - continue; + FF_CFTYPE_AUTO_RELEASE CFBooleanRef IOAVServiceUserInterfaceSupported = IORegistryEntryCreateCFProperty(registryEntry, CFSTR("IOAVServiceUserInterfaceSupported"), kCFAllocatorDefault, kNilOptions); + if (IOAVServiceUserInterfaceSupported && !CFBooleanGetValue(IOAVServiceUserInterfaceSupported)) + { + // IOAVServiceCreateWithService won't work + IOObjectRelease(registryEntry); + continue; + } } - ffStrbufClear(&location); - if(ffCfDictGetString(properties, CFSTR("Location"), &location) || ffStrbufEqualS(&location, "Embedded")) { - // Builtin display should be handled by DisplayServices - IOObjectRelease(registryEntry); - continue; + FF_CFTYPE_AUTO_RELEASE CFStringRef location = IORegistryEntryCreateCFProperty(registryEntry, CFSTR("Location"), kCFAllocatorDefault, kNilOptions); + if (location && CFStringCompare(location, CFSTR("Embedded"), 0) == 0) + { + // Builtin display should be handled by DisplayServices + IOObjectRelease(registryEntry); + continue; + } } FF_CFTYPE_AUTO_RELEASE IOAVServiceRef service = IOAVServiceCreateWithService(kCFAllocatorDefault, (io_service_t) registryEntry);