Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/modules/slaudio/slaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#ifdef WIN32
#include <windows.h>
#endif
#ifdef DARWIN
#include <IOKit/pwr_mgt/IOPMLib.h>
#endif
#include <webapp.h>

#define BUFFER_LEN 19200 /* max buffer_len = 192kHz*2ch*25ms*2frames */
Expand Down Expand Up @@ -1601,6 +1604,21 @@ static int slaudio_init(void)
/* Activate windows low latency timer */
timeBeginPeriod(1);
#endif

#ifdef DARWIN
/* Prevent DisplaySleep - usefull for backup applications
/* IOPMAssertionCreateWithName limits the string to 128 characters. */
CFStringRef reasonForActivity = CFSTR("Studio Link - Audio");
IOPMAssertionID assertionID;

if (kIOReturnSuccess ==
IOPMAssertionCreateWithName(
kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn,
reasonForActivity, &assertionID))
warning("macOS suspend prevent active\n");
else
warning("macOS suspend prevent failed\n");
#endif
info("slaudio ready\n");

return err;
Expand Down