BackgroundMusic/SharedSource/BGM_Utils.h
Kyle Neideck 33b6b17115 Add an XPC helper. Sync BGMApp and BGMDriver with it while starting IO.
The BGMApp project now builds an XPC service bundle called BGMXPCHelper,
which vends a Mach service that BGMApp and BGMDriver can use to
communicate. This will hopefully be useful for some of the tasks HAL
notifications aren't suited to.

In this commit, BGMDriver uses the XPC helper when starting IO, to wait
until BGMApp is ready for playthrough. BGMApp can only start playthrough
when the output hardware is ready for IO. BGMDriver can now tell the HAL
when we're ready for IO, which means we don't have to keep the output
hardware running all the time (or drop frames or increase latency).

The end result is that playthrough doesn't waste CPU time while idle any
more. This also means that now playthrough won't prevent the system from
sleeping when idle.
2016-03-31 11:42:24 +11:00

55 lines
1.6 KiB
C++

// This file is part of Background Music.
//
// Background Music is free software: you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 2 of the
// License, or (at your option) any later version.
//
// Background Music is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Background Music. If not, see <http://www.gnu.org/licenses/>.
//
// BGM_Utils.h
// SharedSource
//
// Copyright © 2016 Kyle Neideck
//
#ifndef __SharedSource__BGM_Utils__
#define __SharedSource__BGM_Utils__
// PublicUtility Includes
#include "CADebugMacros.h"
#include "CAException.h"
// System Includes
#include <mach/mach_error.h>
class BGM_Utils
{
public:
// Similar to ThrowIfKernErr, but also logs the Mach error string that corresponds to inError
static void ThrowIfMachError(const char* inCallingMethod, const char* inErrorReturnedBy, kern_return_t inError)
{
#if !DEBUG
#pragma unused (inCallingMethod, inErrorReturnedBy)
#endif
if(inError != KERN_SUCCESS)
{
DebugMsg("%s: %s returned an error (%d): %s", inCallingMethod, inErrorReturnedBy, inError, mach_error_string(inError));
Throw(CAException(inError));
}
}
};
#endif /* __SharedSource__BGM_Utils__ */