duckstation

duckstation, but archived from the revision just before upstream changed it to a proprietary software project, this version is the libre one
git clone https://git.neptards.moe/u3shit/duckstation.git
Log | Files | Refs | README | LICENSE

cubeb_osx_run_loop.cpp (1114B)


      1 /*
      2  * Copyright © 2016 Mozilla Foundation
      3  *
      4  * This program is made available under an ISC-style license.  See the
      5  * accompanying file LICENSE for details.
      6  */
      7 
      8 #include "cubeb_osx_run_loop.h"
      9 #include "cubeb_log.h"
     10 #include <AudioUnit/AudioUnit.h>
     11 #include <CoreAudio/AudioHardware.h>
     12 #include <CoreAudio/HostTime.h>
     13 #include <CoreFoundation/CoreFoundation.h>
     14 #include <cubeb/cubeb.h>
     15 
     16 void
     17 cubeb_set_coreaudio_notification_runloop()
     18 {
     19   /* This is needed so that AudioUnit listeners get called on this thread, and
     20    * not the main thread. If we don't do that, they are not called, or a crash
     21    * occur, depending on the OSX version. */
     22   AudioObjectPropertyAddress runloop_address = {
     23       kAudioHardwarePropertyRunLoop, kAudioObjectPropertyScopeGlobal,
     24       kAudioObjectPropertyElementMaster};
     25 
     26   CFRunLoopRef run_loop = nullptr;
     27 
     28   OSStatus r;
     29   r = AudioObjectSetPropertyData(kAudioObjectSystemObject, &runloop_address, 0,
     30                                  NULL, sizeof(CFRunLoopRef), &run_loop);
     31   if (r != noErr) {
     32     LOG("Could not make global CoreAudio notifications use their own thread.");
     33   }
     34 }