'kAudioHardwarePropertySleepingIsAllowed' does not work..?

I'm working on a macOS audio recording app and users are reporting that the app prevents their computer from sleeping. In the CoreAudio headers there's a property ('kAudioHardwarePropertySleepingIsAllowed' in AudioHardware.h) on the global system object that should fix this problem, but when I set the property to '1', it doesn't do anything. I've tried setting it at different points in the app setup and it never works. I've tried setting other properties (like the power saver hint) and they do work, so I don't think there's a problem with how I'm setting properties.


I've been digging into this and the 'coreaudiod' background process is setting an IO Power Manager assertion to prevent the computer from sleeping. It doesn't matter if I use AVAudioEngine or AVCaptureSession for audio input, the same background process sets the same assertion. I've tried deactivating the PreventIdleSleep assertion, but even though it's set "on behalf of my process id", my process doesn't seem to have privileges to deactivate it. (I get the error 'kIOReturnNotPermitted' when trying to change the assertion level.)


Does anyone know how to make kAudioHardwarePropertySleepingIsAllowed work? Or a way to deactivate a power manager assertion that was set "on your process' behalf"? Thanks to anyone who can help!

Replies

I filed a bug for this in 2015. The ticket was closed with "There are no plans to address this. We are now closing this report."

Part of my bug report was a request to at the very least update the documentation to indicate that this property is no longer supported. Imagine my shock to find out that 5 years later this still hasn't been properly addressed.