Path: blob/master/dep/cubeb/src/cubeb_osx_run_loop.cpp
4246 views
/*1* Copyright © 2016 Mozilla Foundation2*3* This program is made available under an ISC-style license. See the4* accompanying file LICENSE for details.5*/67#include "cubeb_osx_run_loop.h"8#include "cubeb_log.h"9#include <AudioUnit/AudioUnit.h>10#include <CoreAudio/AudioHardware.h>11#include <CoreAudio/HostTime.h>12#include <CoreFoundation/CoreFoundation.h>13#include <cubeb/cubeb.h>1415void16cubeb_set_coreaudio_notification_runloop()17{18/* This is needed so that AudioUnit listeners get called on this thread, and19* not the main thread. If we don't do that, they are not called, or a crash20* occur, depending on the OSX version. */21AudioObjectPropertyAddress runloop_address = {22kAudioHardwarePropertyRunLoop, kAudioObjectPropertyScopeGlobal,23kAudioObjectPropertyElementMaster};2425CFRunLoopRef run_loop = nullptr;2627OSStatus r;28r = AudioObjectSetPropertyData(kAudioObjectSystemObject, &runloop_address, 0,29NULL, sizeof(CFRunLoopRef), &run_loop);30if (r != noErr) {31LOG("Could not make global CoreAudio notifications use their own thread.");32}33}343536