summaryrefslogtreecommitdiffstats
path: root/xbmc/windowing/osx/OSScreenSaverOSX.cpp
blob: 019f86cfb4d78c60461d47ea3482a89b0fa7f7fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 *  Copyright (C) 2017-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#include "OSScreenSaverOSX.h"

#include <CoreFoundation/CoreFoundation.h>

void COSScreenSaverOSX::Inhibit()
{
  // see Technical Q&A QA1340
  if (m_assertionID == 0)
  {
    CFStringRef reasonForActivity= CFSTR("XBMC requested disable system screen saver");
    IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep,
      kIOPMAssertionLevelOn, reasonForActivity, &m_assertionID);
  }
}

void COSScreenSaverOSX::Uninhibit()
{
  if (m_assertionID != 0)
  {
    IOPMAssertionRelease(m_assertionID);
    m_assertionID = 0;
  }
}