[
  {
    "path": ".github/FUNDING.yml",
    "content": "# These are supported funding model platforms\n\ngithub: existentialaudio # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]\npatreon: # Replace with a single Patreon username\nopen_collective: # Replace with a single Open Collective username\nko_fi: # Replace with a single Ko-fi username\ntidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel\ncommunity_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry\nliberapay: # Replace with a single Liberapay username\nissuehunt: # Replace with a single IssueHunt username\notechie: # Replace with a single Otechie username\ncustom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.yml",
    "content": "name: Bug report\ndescription: Create a bug report about a reproducible problem.\nlabels: bug\nbody:\n- type: checkboxes\n  id: searched-discussions\n  attributes:\n    label: Please Confirm\n    options:\n      - label: I have read the **[FAQ](https://github.com/ExistentialAudio/BlackHole#faq) and [Wiki](https://github.com/ExistentialAudio/BlackHole/wiki)** where most common issues can be resolved\n        required: true\n      - label: I have searched **[Discussions](https://github.com/ExistentialAudio/BlackHole/discussions)** to see if the same question has already been asked\n        required: true\n      - label: This is a **bug** and not a question about audio routing or configuration, which should be posted in [Discussions](https://github.com/ExistentialAudio/BlackHole/discussions)\n        required: true\n- type: dropdown\n  id: operating-system\n  attributes:\n    label: \"macOS Version\"\n    multiple: false\n    options:\n      - \"macOS 26 Tahoe\"\n      - \"macOS 15 Sequoia\"\n      - \"macOS 14 Sonoma\"\n      - \"macOS 13 Ventura\"\n      - \"macOS 12 Monterey\"\n      - \"macOS 11 Big Sur\"\n      - \"macOS 10.15 Catalina\"\n      - \"macOS 10.14 Mojave\"\n      - \"macOS 10.13 High Sierra\"\n      - \"macOS 10.12 Sierra\"\n      - \"macOS 10.11 El Capitan\"\n      - \"macOS 10.10 Yosemite\"\n      - \"macOS 10.9 Mavericks\"\n  validations:\n    required: true\n- type: checkboxes\n  id: blackhole-config\n  attributes:\n    label: \"BlackHole Build(s) Affected\"\n    options:\n      - label: \"2 channel\"\n      - label: \"16 channel\"\n      - label: \"64 channel\"\n      - label: \"other/custom build\"\n  validations:\n    required: true\n- type: textarea\n  id: bug-description\n  attributes:\n    label: Describe the bug\n    description: \"A clear and concise description of what the bug is.\"\n  validations:\n    required: true     \n- type: textarea\n  id: repro\n  attributes:\n    label: Reproduction Steps\n    description: \"Please list steps to reproduce the bug. If exact steps are unknown, please describe what conditions cause the issue.\"\n    value: |\n      1.\n      2.\n      3.\n      etc...\n  validations:\n    required: true\n- type: textarea\n  id: expected-behavior\n  attributes:\n    label: Expected Behavior\n    description: \"A clear and concise description of what you expected to happen.\"\n  validations:\n    required: true\n- type: textarea\n  id: screenshots\n  attributes:\n    label: Screenshots\n    description: \"Please include screenshots of Audio MIDI Setup (BlackHole, your Multi-Output Device, etc.) and any app configuration windows in question. You can take screen shots by pressing <kbd>Shift</kbd><kbd>Cmd</kbd><kbd>4</kbd>, then attach the screenshot image files by dragging them onto the text entry area below:\"\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/config.yml",
    "content": "blank_issues_enabled: false\ncontact_links:\n  - name: Feature request\n    url: https://github.com/ExistentialAudio/BlackHole/discussions\n    about: Suggest an idea for a new feature.\n  - name: I need help setting up or troubleshooting BlackHole\n    url: https://github.com/ExistentialAudio/BlackHole/discussions\n    about: Questions about how to configure your favorite apps.\n"
  },
  {
    "path": ".gitignore",
    "content": "xcuserdata/\n.DS_Store\n*.pkg"
  },
  {
    "path": "BlackHole/BlackHole.c",
    "content": "/*\n     File: BlackHole.c\n  \n Copyright (C) 2019 Existential Audio Inc.\n  \n*/\n/*==================================================================================================\n\tBlackHole.c\n==================================================================================================*/\n\n//==================================================================================================\n//\tIncludes\n//==================================================================================================\n\n#include <CoreAudio/AudioServerPlugIn.h>\n#include <dispatch/dispatch.h>\n#include <mach/mach_time.h>\n#include <pthread.h>\n#include <stdint.h>\n#include <sys/syslog.h>\n#include <Accelerate/Accelerate.h>\n#include <Availability.h>\n\n//==================================================================================================\n#pragma mark -\n#pragma mark Macros\n//==================================================================================================\n\n#if TARGET_RT_BIG_ENDIAN\n#define    FourCCToCString(the4CC)    { ((char*)&the4CC)[0], ((char*)&the4CC)[1], ((char*)&the4CC)[2], ((char*)&the4CC)[3], 0 }\n#else\n#define    FourCCToCString(the4CC)    { ((char*)&the4CC)[3], ((char*)&the4CC)[2], ((char*)&the4CC)[1], ((char*)&the4CC)[0], 0 }\n#endif\n\n#ifndef __MAC_12_0\n#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster\n#endif\n\n#if DEBUG\n\n    #define    DebugMsg(inFormat, ...)    syslog(LOG_NOTICE, inFormat, ## __VA_ARGS__)\n\n    #define    FailIf(inCondition, inHandler, inMessage)                           \\\n    if(inCondition)                                                                \\\n    {                                                                              \\\n        DebugMsg(inMessage);                                                       \\\n        goto inHandler;                                                            \\\n    }\n\n    #define    FailWithAction(inCondition, inAction, inHandler, inMessage)         \\\n    if(inCondition)                                                                \\\n    {                                                                              \\\n        DebugMsg(inMessage);                                                       \\\n        { inAction; }                                                              \\\n        goto inHandler;                                                            \\\n        }\n\n#else\n\n    #define    DebugMsg(inFormat, ...)\n\n    #define    FailIf(inCondition, inHandler, inMessage)                           \\\n    if(inCondition)                                                                \\\n    {                                                                              \\\n    goto inHandler;                                                                \\\n    }\n\n    #define    FailWithAction(inCondition, inAction, inHandler, inMessage)         \\\n    if(inCondition)                                                                \\\n    {                                                                              \\\n    { inAction; }                                                                  \\\n    goto inHandler;                                                                \\\n    }\n\n#endif\n\n\n//==================================================================================================\n#pragma mark -\n#pragma mark BlackHole State\n//==================================================================================================\n\n//    The driver has the following\n//    qualities:\n//    - a box\n//    - a device\n//        - supports 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000, 705600, 768000, 8000, 16000 sample rates\n\n\n//        - provides a rate scalar of 1.0 via hard coding\n//    - a single output stream\n//        - supports 16 channels of 32 bit float LPCM samples\n//        - writes to ring buffer\n//    - a single input stream\n//        - supports 16 channels of 32 bit float LPCM samples\n//        - reads from ring buffer\n//    - controls\n//        - master input volume\n//        - master output volume\n//        - master input mute\n//        - master output mute\n\n\n//    Declare the internal object ID numbers for all the objects this driver implements. Note that\n//    because the driver has fixed set of objects that never grows or shrinks. If this were not the\n//    case, the driver would need to have a means to dynamically allocate these IDs. It is important\n//    to realize that a lot of the structure of this driver is vastly simpler when the IDs are all\n//    known a priori. Comments in the code will try to identify some of these simplifications and\n//    point out what a more complicated driver will need to do.\nenum\n{\n    kObjectID_PlugIn                    = kAudioObjectPlugInObject,\n    kObjectID_Box                       = 2,\n    kObjectID_Device                    = 3,\n    kObjectID_Stream_Input              = 4,\n    kObjectID_Volume_Input_Master       = 5,\n    kObjectID_Mute_Input_Master         = 6,\n    kObjectID_Stream_Output             = 7,\n    kObjectID_Volume_Output_Master      = 8,\n    kObjectID_Mute_Output_Master        = 9,\n    kObjectID_Pitch_Adjust              = 10,\n    kObjectID_ClockSource               = 11,\n    kObjectID_Device2                   = 12,\n};\n\nenum\n{\n    ChangeAction_SetSampleRate          = 1,\n    ChangeAction_EnablePitchControl     = 2,\n    ChangeAction_DisablePitchControl    = 3,\n};\n\nenum ObjectType\n{\n    kObjectType_Stream,\n    kObjectType_Control\n};\n\nstruct ObjectInfo {\n    AudioObjectID id;\n    enum ObjectType type;\n    AudioObjectPropertyScope scope;\n};\n\n//    Declare the stuff that tracks the state of the plug-in, the device and its sub-objects.\n//    Note that we use global variables here because this driver only ever has a single device. If\n//    multiple devices were supported, this state would need to be encapsulated in one or more structs\n//    so that each object's state can be tracked individually.\n//    Note also that we share a single mutex across all objects to be thread safe for the same reason.\n\n\n#ifndef kDriver_Name\n#define                             kDriver_Name                        \"BlackHole\"\n#endif\n\n#ifndef kPlugIn_BundleID\n#define                             kPlugIn_BundleID                    \"audio.existential.BlackHole2ch\"\n#endif\n\n#ifndef kPlugIn_Icon\n#define                             kPlugIn_Icon                        \"BlackHole.icns\"\n#endif\n\n#ifndef kHas_Driver_Name_Format\n#define                             kHas_Driver_Name_Format             true\n#endif\n\n#if kHas_Driver_Name_Format\n#define                             kDriver_Name_Format                 \"%ich\"\n#define                             kBox_UID                            kDriver_Name kDriver_Name_Format \"_UID\"\n#define                             kDevice_UID                         kDriver_Name kDriver_Name_Format \"_UID\"\n#define                             kDevice2_UID                        kDriver_Name kDriver_Name_Format \"_2_UID\"\n#define                             kDevice_ModelUID                    kDriver_Name kDriver_Name_Format \"_ModelUID\"\n\n\n#ifndef kDevice_Name\n#define                             kDevice_Name                        kDriver_Name \" %ich\"\n#endif\n\n#ifndef kDevice2_Name\n#define                             kDevice2_Name                       kDriver_Name \" %ich 2\"\n#endif\n\n\n#else\n#define                             kBox_UID                            kDriver_Name \"_UID\"\n#define                             kDevice_UID                         kDriver_Name \"_UID\"\n#define                             kDevice2_UID                        kDriver_Name \"_2_UID\"\n#define                             kDevice_ModelUID                    kDriver_Name \"_ModelUID\"\n\n\n#ifndef kDevice_Name\n#define                             kDevice_Name                        kDriver_Name \" \"\n#endif\n\n#ifndef kDevice2_Name\n#define                             kDevice2_Name                       kDriver_Name \" Mirror\"\n#endif\n\n#endif\n\n#ifndef kDevice_IsHidden\n#define                             kDevice_IsHidden                    false\n#endif\n\n#ifndef kDevice2_IsHidden\n#define                             kDevice2_IsHidden                   true\n#endif\n\n\n\n#ifndef kDevice_HasInput\n#define                             kDevice_HasInput                    true\n#endif\n\n#ifndef kDevice_HasOutput\n#define                             kDevice_HasOutput                   true\n#endif\n\n#ifndef kDevice2_HasInput\n#define                             kDevice2_HasInput                   true\n#endif\n\n#ifndef kDevice2_HasOutput\n#define                             kDevice2_HasOutput                  true\n#endif\n\n\n\n#ifndef kManufacturer_Name\n#define                             kManufacturer_Name                  \"Existential Audio Inc.\"\n#endif\n\n#define                             kLatency_Frame_Size                 0\n\n#ifndef kNumber_Of_Channels\n#define                             kNumber_Of_Channels                 2\n#endif\n\n#ifndef kEnableVolumeControl\n#define                             kEnableVolumeControl                 true\n#endif\n\n#ifndef kCanBeDefaultDevice\n#define                             kCanBeDefaultDevice                 true\n#endif\n\n#ifndef kCanBeDefaultSystemDevice\n#define                             kCanBeDefaultSystemDevice           true\n#endif\n\nstatic pthread_mutex_t              gPlugIn_StateMutex                  = PTHREAD_MUTEX_INITIALIZER;\nstatic UInt32                       gPlugIn_RefCount                    = 0;\nstatic AudioServerPlugInHostRef     gPlugIn_Host                        = NULL;\n\n\nstatic CFStringRef                  gBox_Name                           = NULL;\n\n#ifndef kBox_Aquired\n#define                             kBox_Aquired                 \ttrue\n#endif\nstatic Boolean                      gBox_Acquired                       = kBox_Aquired;\n\n\nstatic pthread_mutex_t              gDevice_IOMutex                     = PTHREAD_MUTEX_INITIALIZER;\nstatic Float64                      gDevice_SampleRate                  = 48000.0;\nstatic Float64                      gDevice_RequestedSampleRate         = 0.0;\nstatic UInt64                       gDevice_IOIsRunning                 = 0;\nstatic UInt64                       gDevice2_IOIsRunning                = 0;\nstatic const UInt32                 kDevice_RingBufferSize              = 16384;\nstatic Float64                      gDevice_HostTicksPerFrame           = 0.0;\nstatic Float64                      gDevice_AdjustedTicksPerFrame       = 0.0;\nstatic Float64                      gDevice_PreviousTicks               = 0.0;\nstatic UInt64                       gDevice_NumberTimeStamps            = 0;\nstatic Float64                      gDevice_AnchorSampleTime            = 0.0;\nstatic UInt64                       gDevice_AnchorHostTime              = 0;\n\nstatic bool                         gStream_Input_IsActive              = true;\nstatic bool                         gStream_Output_IsActive             = true;\n\nstatic const Float32                kVolume_MinDB                       = -64.0;\nstatic const Float32                kVolume_MaxDB                       = 0.0;\nstatic Float32                      gVolume_Master_Value                = 1.0;\nstatic Float32                      gPitch_Adjust                       = 0.5;\nstatic bool                         gMute_Master_Value                  = false;\nstatic UInt32                       kClockSource_NumberItems            = 2;\n#define                             kClockSource_InternalFixed         \"Internal Fixed\"\n#define                             kClockSource_InternalAdjustable    \"Internal Adjustable\"\nstatic UInt32                       gClockSource_Value                  = 0;\nstatic bool                         gPitch_Adjust_Enabled               = false;\n\nstatic struct ObjectInfo            kDevice_ObjectList[]                = {\n#if kDevice_HasInput\n    { kObjectID_Stream_Input,           kObjectType_Stream,     kAudioObjectPropertyScopeInput  },\n    { kObjectID_Volume_Input_Master,    kObjectType_Control,    kAudioObjectPropertyScopeInput  },\n    { kObjectID_Mute_Input_Master,      kObjectType_Control,    kAudioObjectPropertyScopeInput  },\n#endif\n#if kDevice_HasOutput\n    { kObjectID_Stream_Output,          kObjectType_Stream,     kAudioObjectPropertyScopeOutput },\n    { kObjectID_Volume_Output_Master,   kObjectType_Control,    kAudioObjectPropertyScopeOutput },\n    { kObjectID_Mute_Output_Master,     kObjectType_Control,    kAudioObjectPropertyScopeOutput },\n    { kObjectID_Pitch_Adjust,           kObjectType_Control,    kAudioObjectPropertyScopeOutput },\n#endif\n    { kObjectID_ClockSource,            kObjectType_Control,    kAudioObjectPropertyScopeGlobal }\n};\n\nstatic struct ObjectInfo            kDevice2_ObjectList[]                = {\n#if kDevice2_HasInput\n    { kObjectID_Stream_Input,           kObjectType_Stream,     kAudioObjectPropertyScopeInput  },\n    { kObjectID_Volume_Input_Master,    kObjectType_Control,    kAudioObjectPropertyScopeInput  },\n    { kObjectID_Mute_Input_Master,      kObjectType_Control,    kAudioObjectPropertyScopeInput  },\n#endif\n#if kDevice2_HasOutput\n    { kObjectID_Stream_Output,          kObjectType_Stream,     kAudioObjectPropertyScopeOutput },\n    { kObjectID_Volume_Output_Master,   kObjectType_Control,    kAudioObjectPropertyScopeOutput },\n    { kObjectID_Mute_Output_Master,     kObjectType_Control,    kAudioObjectPropertyScopeOutput },\n#endif\n};\n\nstatic const UInt32                 kDevice_ObjectListSize              = sizeof(kDevice_ObjectList) / sizeof(struct ObjectInfo);\nstatic const UInt32                 kDevice2_ObjectListSize              = sizeof(kDevice2_ObjectList) / sizeof(struct ObjectInfo);\n\n#ifndef kSampleRates\n#define                             kSampleRates       8000, 16000, 24000, 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000, 705600, 768000\n#endif\n\nstatic Float64                      kDevice_SampleRates[]               = { kSampleRates };\n\nstatic const UInt32                 kDevice_SampleRatesSize             = sizeof(kDevice_SampleRates) / sizeof(Float64);\n\n\n\n#define                             kBits_Per_Channel                   32\n#define                             kBytes_Per_Channel                  (kBits_Per_Channel/ 8)\n#define                             kBytes_Per_Frame                    (kNumber_Of_Channels * kBytes_Per_Channel)\n#define                             kRing_Buffer_Frame_Size             ((65536 + kLatency_Frame_Size))\nstatic Float32*                     gRingBuffer = NULL;\n\n\n//==================================================================================================\n#pragma mark -\n#pragma mark AudioServerPlugInDriverInterface Implementation\n//==================================================================================================\n\n#pragma mark Prototypes\n\n//    Entry points for the COM methods\nvoid*                BlackHole_Create(CFAllocatorRef inAllocator, CFUUIDRef inRequestedTypeUUID);\nstatic HRESULT        BlackHole_QueryInterface(void* inDriver, REFIID inUUID, LPVOID* outInterface);\nstatic ULONG        BlackHole_AddRef(void* inDriver);\nstatic ULONG        BlackHole_Release(void* inDriver);\nstatic OSStatus        BlackHole_Initialize(AudioServerPlugInDriverRef inDriver, AudioServerPlugInHostRef inHost);\nstatic OSStatus        BlackHole_CreateDevice(AudioServerPlugInDriverRef inDriver, CFDictionaryRef inDescription, const AudioServerPlugInClientInfo* inClientInfo, AudioObjectID* outDeviceObjectID);\nstatic OSStatus        BlackHole_DestroyDevice(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID);\nstatic OSStatus        BlackHole_AddDeviceClient(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, const AudioServerPlugInClientInfo* inClientInfo);\nstatic OSStatus        BlackHole_RemoveDeviceClient(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, const AudioServerPlugInClientInfo* inClientInfo);\nstatic OSStatus        BlackHole_PerformDeviceConfigurationChange(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, UInt64 inChangeAction, void* inChangeInfo);\nstatic OSStatus        BlackHole_AbortDeviceConfigurationChange(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, UInt64 inChangeAction, void* inChangeInfo);\nstatic Boolean        BlackHole_HasProperty(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress);\nstatic OSStatus        BlackHole_IsPropertySettable(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, Boolean* outIsSettable);\nstatic OSStatus        BlackHole_GetPropertyDataSize(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* outDataSize);\nstatic OSStatus        BlackHole_GetPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, UInt32* outDataSize, void* outData);\nstatic OSStatus        BlackHole_SetPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, const void* inData);\nstatic OSStatus        BlackHole_StartIO(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, UInt32 inClientID);\nstatic OSStatus        BlackHole_StopIO(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, UInt32 inClientID);\nstatic OSStatus        BlackHole_GetZeroTimeStamp(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, UInt32 inClientID, Float64* outSampleTime, UInt64* outHostTime, UInt64* outSeed);\nstatic OSStatus        BlackHole_WillDoIOOperation(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, UInt32 inClientID, UInt32 inOperationID, Boolean* outWillDo, Boolean* outWillDoInPlace);\nstatic OSStatus        BlackHole_BeginIOOperation(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, UInt32 inClientID, UInt32 inOperationID, UInt32 inIOBufferFrameSize, const AudioServerPlugInIOCycleInfo* inIOCycleInfo);\nstatic OSStatus        BlackHole_DoIOOperation(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, AudioObjectID inStreamObjectID, UInt32 inClientID, UInt32 inOperationID, UInt32 inIOBufferFrameSize, const AudioServerPlugInIOCycleInfo* inIOCycleInfo, void* ioMainBuffer, void* ioSecondaryBuffer);\nstatic OSStatus        BlackHole_EndIOOperation(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, UInt32 inClientID, UInt32 inOperationID, UInt32 inIOBufferFrameSize, const AudioServerPlugInIOCycleInfo* inIOCycleInfo);\n\n//    Implementation\nstatic Boolean        BlackHole_HasPlugInProperty(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress);\nstatic OSStatus        BlackHole_IsPlugInPropertySettable(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, Boolean* outIsSettable);\nstatic OSStatus        BlackHole_GetPlugInPropertyDataSize(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* outDataSize);\nstatic OSStatus        BlackHole_GetPlugInPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, UInt32* outDataSize, void* outData);\nstatic OSStatus        BlackHole_SetPlugInPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, const void* inData, UInt32* outNumberPropertiesChanged, AudioObjectPropertyAddress outChangedAddresses[2]);\n\nstatic Boolean        BlackHole_HasBoxProperty(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress);\nstatic OSStatus        BlackHole_IsBoxPropertySettable(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, Boolean* outIsSettable);\nstatic OSStatus        BlackHole_GetBoxPropertyDataSize(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* outDataSize);\nstatic OSStatus        BlackHole_GetBoxPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, UInt32* outDataSize, void* outData);\nstatic OSStatus        BlackHole_SetBoxPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, const void* inData, UInt32* outNumberPropertiesChanged, AudioObjectPropertyAddress outChangedAddresses[2]);\n\nstatic Boolean        BlackHole_HasDeviceProperty(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress);\nstatic OSStatus        BlackHole_IsDevicePropertySettable(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, Boolean* outIsSettable);\nstatic OSStatus        BlackHole_GetDevicePropertyDataSize(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* outDataSize);\nstatic OSStatus        BlackHole_GetDevicePropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, UInt32* outDataSize, void* outData);\nstatic OSStatus        BlackHole_SetDevicePropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, const void* inData, UInt32* outNumberPropertiesChanged, AudioObjectPropertyAddress outChangedAddresses[2]);\n\nstatic Boolean        BlackHole_HasStreamProperty(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress);\nstatic OSStatus        BlackHole_IsStreamPropertySettable(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, Boolean* outIsSettable);\nstatic OSStatus        BlackHole_GetStreamPropertyDataSize(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* outDataSize);\nstatic OSStatus        BlackHole_GetStreamPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, UInt32* outDataSize, void* outData);\nstatic OSStatus        BlackHole_SetStreamPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, const void* inData, UInt32* outNumberPropertiesChanged, AudioObjectPropertyAddress outChangedAddresses[2]);\n\nstatic Boolean        BlackHole_HasControlProperty(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress);\nstatic OSStatus        BlackHole_IsControlPropertySettable(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, Boolean* outIsSettable);\nstatic OSStatus        BlackHole_GetControlPropertyDataSize(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* outDataSize);\nstatic OSStatus        BlackHole_GetControlPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, UInt32* outDataSize, void* outData);\nstatic OSStatus        BlackHole_SetControlPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, const void* inData, UInt32* outNumberPropertiesChanged, AudioObjectPropertyAddress outChangedAddresses[2]);\n\n#pragma mark The Interface\n\nstatic AudioServerPlugInDriverInterface    gAudioServerPlugInDriverInterface =\n{\n    NULL,\n    BlackHole_QueryInterface,\n    BlackHole_AddRef,\n    BlackHole_Release,\n    BlackHole_Initialize,\n    BlackHole_CreateDevice,\n    BlackHole_DestroyDevice,\n    BlackHole_AddDeviceClient,\n    BlackHole_RemoveDeviceClient,\n    BlackHole_PerformDeviceConfigurationChange,\n    BlackHole_AbortDeviceConfigurationChange,\n    BlackHole_HasProperty,\n    BlackHole_IsPropertySettable,\n    BlackHole_GetPropertyDataSize,\n    BlackHole_GetPropertyData,\n    BlackHole_SetPropertyData,\n    BlackHole_StartIO,\n    BlackHole_StopIO,\n    BlackHole_GetZeroTimeStamp,\n    BlackHole_WillDoIOOperation,\n    BlackHole_BeginIOOperation,\n    BlackHole_DoIOOperation,\n    BlackHole_EndIOOperation\n};\nstatic AudioServerPlugInDriverInterface*    gAudioServerPlugInDriverInterfacePtr    = &gAudioServerPlugInDriverInterface;\nstatic AudioServerPlugInDriverRef            gAudioServerPlugInDriverRef                = &gAudioServerPlugInDriverInterfacePtr;\n\n\n#define RETURN_FORMATTED_STRING(_string_fmt)                          \\\nif(kHas_Driver_Name_Format)                                           \\\n{                                                                     \\\n\treturn CFStringCreateWithFormat(NULL, NULL, CFSTR(_string_fmt), kNumber_Of_Channels); \\\n}                                                                     \\\nelse                                                                  \\\n{                                                                     \\\n\treturn CFStringCreateWithCString(NULL, _string_fmt, kCFStringEncodingUTF8); \\\n}\n\nstatic CFStringRef get_box_uid(void)          { RETURN_FORMATTED_STRING(kBox_UID) }\nstatic CFStringRef get_device_uid(void)       { RETURN_FORMATTED_STRING(kDevice_UID) }\nstatic CFStringRef get_device_name(void)      { RETURN_FORMATTED_STRING(kDevice_Name) }\nstatic CFStringRef get_device2_uid(void)      { RETURN_FORMATTED_STRING(kDevice2_UID) }\nstatic CFStringRef get_device2_name(void)     { RETURN_FORMATTED_STRING(kDevice2_Name) }\nstatic CFStringRef get_device_model_uid(void) { RETURN_FORMATTED_STRING(kDevice_ModelUID) }\n\n// Volume conversions\n\nstatic Float32 volume_to_decibel(Float32 volume)\n{\n\tif (volume <= powf(10.0f, kVolume_MinDB / 20.0f))\n\t\treturn kVolume_MinDB;\n\telse\n\t\treturn 20.0f * log10f(volume);\n}\n\nstatic Float32 volume_from_decibel(Float32 decibel)\n{\n\tif (decibel <= kVolume_MinDB)\n\t\treturn 0.0f;\n\telse\n\t\treturn powf(10.0f, decibel / 20.0f);\n}\n\nstatic Float32 volume_to_scalar(Float32 volume)\n{\n\tFloat32 decibel = volume_to_decibel(volume);\n\treturn (decibel - kVolume_MinDB) / (kVolume_MaxDB - kVolume_MinDB);\n}\n\nstatic Float32 volume_from_scalar(Float32 scalar)\n{\n\tFloat32 decibel = scalar * (kVolume_MaxDB - kVolume_MinDB) + kVolume_MinDB;\n\treturn volume_from_decibel(decibel);\n}\n\nstatic UInt32 device_object_list_size(AudioObjectPropertyScope scope, AudioObjectID objectID) {\n    \n    switch (objectID) {\n        case kObjectID_Device:\n            {\n                if (scope == kAudioObjectPropertyScopeGlobal)\n                {\n                    return kDevice_ObjectListSize;\n                }\n\n                UInt32 count = 0;\n                for (UInt32 i = 0; i < kDevice_ObjectListSize; i++)\n                {\n                    count += (kDevice_ObjectList[i].scope == scope);\n                }\n\n                return count;\n            }\n            break;\n            \n        case kObjectID_Device2:\n            {\n                if (scope == kAudioObjectPropertyScopeGlobal)\n                {\n                    return kDevice2_ObjectListSize;\n                }\n\n                UInt32 count = 0;\n                for (UInt32 i = 0; i < kDevice2_ObjectListSize; i++)\n                {\n                    count += (kDevice2_ObjectList[i].scope == scope);\n                }\n\n                return count;\n            }\n            break;\n            \n        default:\n            return 0;\n            break;\n    }\n}\n\nstatic UInt32 device_stream_list_size(AudioObjectPropertyScope scope, AudioObjectID objectID) {\n    \n    switch (objectID) {\n        case kObjectID_Device:\n            {\n                UInt32 count = 0;\n                for (UInt32 i = 0; i < kDevice_ObjectListSize; i++)\n                {\n                    count += (kDevice_ObjectList[i].type == kObjectType_Stream && (kDevice_ObjectList[i].scope == scope || scope == kAudioObjectPropertyScopeGlobal));\n                }\n\n                return count;\n            }\n            break;\n            \n        case kObjectID_Device2:\n            {\n                UInt32 count = 0;\n                for (UInt32 i = 0; i < kDevice2_ObjectListSize; i++)\n                {\n                    count += (kDevice2_ObjectList[i].type == kObjectType_Stream && (kDevice2_ObjectList[i].scope == scope || scope == kAudioObjectPropertyScopeGlobal));\n                }\n\n                return count;\n            }\n            break;\n            \n        default:\n            return 0;\n            break;\n    }\n    \n\n}\n\nstatic UInt32 device_control_list_size(AudioObjectPropertyScope scope, AudioObjectID objectID) {\n    \n    switch (objectID) {\n        case kObjectID_Device:\n        {\n            \n            UInt32 count = 0;\n            for (UInt32 i = 0; i < kDevice_ObjectListSize; i++)\n            {\n                count += (kDevice_ObjectList[i].type == kObjectType_Control && (kDevice_ObjectList[i].scope == scope || scope == kAudioObjectPropertyScopeGlobal));\n            }\n\n            return count;\n        }\n            break;\n        case kObjectID_Device2:\n        {\n            \n            UInt32 count = 0;\n            for (UInt32 i = 0; i < kDevice2_ObjectListSize; i++)\n            {\n                count += (kDevice2_ObjectList[i].type == kObjectType_Control && (kDevice2_ObjectList[i].scope == scope || scope == kAudioObjectPropertyScopeGlobal));\n            }\n\n            return count;\n        }\n            break;\n            \n        default:\n            return 0;\n            break;\n    }\n\n}\n\nstatic UInt32 minimum(UInt32 a, UInt32 b) {\n    return a < b ? a : b;\n}\n\nstatic bool is_valid_sample_rate(Float64 sample_rate)\n{\n    for(UInt32 i = 0; i < kDevice_SampleRatesSize; i++)\n    {\n        if (sample_rate == kDevice_SampleRates[i])\n        {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n#pragma mark Factory\n\nvoid*\tBlackHole_Create(CFAllocatorRef inAllocator, CFUUIDRef inRequestedTypeUUID)\n{\n\t//\tThis is the CFPlugIn factory function. Its job is to create the implementation for the given\n\t//\ttype provided that the type is supported. Because this driver is simple and all its\n\t//\tinitialization is handled via static initialization when the bundle is loaded, all that\n\t//\tneeds to be done is to return the AudioServerPlugInDriverRef that points to the driver's\n\t//\tinterface. A more complicated driver would create any base line objects it needs to satisfy\n\t//\tthe IUnknown methods that are used to discover that actual interface to talk to the driver.\n\t//\tThe majority of the driver's initialization should be handled in the Initialize() method of\n\t//\tthe driver's AudioServerPlugInDriverInterface.\n\t\n\t#pragma unused(inAllocator)\n    void* theAnswer = NULL;\n    if(CFEqual(inRequestedTypeUUID, kAudioServerPlugInTypeUUID))\n    {\n\t\ttheAnswer = gAudioServerPlugInDriverRef;\n    }\n    return theAnswer;\n}\n\n#pragma mark Inheritance\n\nstatic HRESULT\tBlackHole_QueryInterface(void* inDriver, REFIID inUUID, LPVOID* outInterface)\n{\n\t//\tThis function is called by the HAL to get the interface to talk to the plug-in through.\n\t//\tAudioServerPlugIns are required to support the IUnknown interface and the\n\t//\tAudioServerPlugInDriverInterface. As it happens, all interfaces must also provide the\n\t//\tIUnknown interface, so we can always just return the single interface we made with\n\t//\tgAudioServerPlugInDriverInterfacePtr regardless of which one is asked for.\n\n\t//\tdeclare the local variables\n\tHRESULT theAnswer = 0;\n\tCFUUIDRef theRequestedUUID = NULL;\n\t\n\t//\tvalidate the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_QueryInterface: bad driver reference\");\n\tFailWithAction(outInterface == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_QueryInterface: no place to store the returned interface\");\n\n\t//\tmake a CFUUIDRef from inUUID\n\ttheRequestedUUID = CFUUIDCreateFromUUIDBytes(NULL, inUUID);\n\tFailWithAction(theRequestedUUID == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_QueryInterface: failed to create the CFUUIDRef\");\n\n\t//\tAudioServerPlugIns only support two interfaces, IUnknown (which has to be supported by all\n\t//\tCFPlugIns and AudioServerPlugInDriverInterface (which is the actual interface the HAL will\n\t//\tuse).\n\tif(CFEqual(theRequestedUUID, IUnknownUUID) || CFEqual(theRequestedUUID, kAudioServerPlugInDriverInterfaceUUID))\n\t{\n\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\t++gPlugIn_RefCount;\n\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t*outInterface = gAudioServerPlugInDriverRef;\n\t}\n\telse\n\t{\n\t\ttheAnswer = E_NOINTERFACE;\n\t}\n\t\n\t//\tmake sure to release the UUID we created\n\tCFRelease(theRequestedUUID);\n\t\t\nDone:\n\treturn theAnswer;\n}\n\nstatic ULONG\tBlackHole_AddRef(void* inDriver)\n{\n\t//\tThis call returns the resulting reference count after the increment.\n\t\n\t//\tdeclare the local variables\n\tULONG theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailIf(inDriver != gAudioServerPlugInDriverRef, Done, \"BlackHole_AddRef: bad driver reference\");\n\n\t//\tincrement the refcount\n\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\tif(gPlugIn_RefCount < UINT32_MAX)\n\t{\n\t\t++gPlugIn_RefCount;\n\t}\n\ttheAnswer = gPlugIn_RefCount;\n\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\nDone:\n\treturn theAnswer;\n}\n\nstatic ULONG\tBlackHole_Release(void* inDriver)\n{\n\t//\tThis call returns the resulting reference count after the decrement.\n\n\t//\tdeclare the local variables\n\tULONG theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailIf(inDriver != gAudioServerPlugInDriverRef, Done, \"BlackHole_Release: bad driver reference\");\n\n\t//\tdecrement the refcount\n\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\tif(gPlugIn_RefCount > 0)\n\t{\n\t\t--gPlugIn_RefCount;\n\t\t//\tNote that we don't do anything special if the refcount goes to zero as the HAL\n\t\t//\twill never fully release a plug-in it opens. We keep managing the refcount so that\n\t\t//\tthe API semantics are correct though.\n\t}\n\ttheAnswer = gPlugIn_RefCount;\n\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\nDone:\n\treturn theAnswer;\n}\n\n#pragma mark Basic Operations\n\nstatic OSStatus\tBlackHole_Initialize(AudioServerPlugInDriverRef inDriver, AudioServerPlugInHostRef inHost)\n{\n\t//\tThe job of this method is, as the name implies, to get the driver initialized. One specific\n\t//\tthing that needs to be done is to store the AudioServerPlugInHostRef so that it can be used\n\t//\tlater. Note that when this call returns, the HAL will scan the various lists the driver\n\t//\tmaintains (such as the device list) to get the initial set of objects the driver is\n\t//\tpublishing. So, there is no need to notify the HAL about any objects created as part of the\n\t//\texecution of this method.\n\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_Initialize: bad driver reference\");\n\t\n\t//\tstore the AudioServerPlugInHostRef\n\tgPlugIn_Host = inHost;\n\t\n\t//\tinitialize the box acquired property from the settings\n\tCFPropertyListRef theSettingsData = NULL;\n\tgPlugIn_Host->CopyFromStorage(gPlugIn_Host, CFSTR(\"box acquired\"), &theSettingsData);\n\tif(theSettingsData != NULL)\n\t{\n\t\tif(CFGetTypeID(theSettingsData) == CFBooleanGetTypeID())\n\t\t{\n\t\t\tgBox_Acquired = CFBooleanGetValue((CFBooleanRef)theSettingsData);\n\t\t}\n\t\telse if(CFGetTypeID(theSettingsData) == CFNumberGetTypeID())\n\t\t{\n\t\t\tSInt32 theValue = 0;\n\t\t\tCFNumberGetValue((CFNumberRef)theSettingsData, kCFNumberSInt32Type, &theValue);\n\t\t\tgBox_Acquired = theValue ? 1 : 0;\n\t\t}\n\t\tCFRelease(theSettingsData);\n\t}\n\t\n\t//\tinitialize the box name from the settings\n\tgPlugIn_Host->CopyFromStorage(gPlugIn_Host, CFSTR(\"box acquired\"), &theSettingsData);\n\tif(theSettingsData != NULL)\n\t{\n\t\tif(CFGetTypeID(theSettingsData) == CFStringGetTypeID())\n\t\t{\n\t\t\tgBox_Name = (CFStringRef)theSettingsData;\n\t\t\tCFRetain(gBox_Name);\n\t\t}\n\t\tCFRelease(theSettingsData);\n\t}\n\t\n\t//\tset the box name directly as a last resort\n\tif(gBox_Name == NULL)\n\t{\n\t\tgBox_Name = CFSTR(\"BlackHole Box\");\n\t}\n\t\n\t//\tcalculate the host ticks per frame\n\tstruct mach_timebase_info theTimeBaseInfo;\n\tmach_timebase_info(&theTimeBaseInfo);\n\tFloat64 theHostClockFrequency = (Float64)theTimeBaseInfo.denom / (Float64)theTimeBaseInfo.numer;\n\ttheHostClockFrequency *= 1000000000.0;\n\tgDevice_HostTicksPerFrame = theHostClockFrequency / gDevice_SampleRate;\n    gDevice_AdjustedTicksPerFrame = gDevice_HostTicksPerFrame - gDevice_HostTicksPerFrame/100.0 * 2.0*(gPitch_Adjust - 0.5);\n    \n    // DebugMsg(\"BlackHole theTimeBaseInfo.numer: %u \\t theTimeBaseInfo.denom: %u\", theTimeBaseInfo.numer, theTimeBaseInfo.denom);\n\t\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_CreateDevice(AudioServerPlugInDriverRef inDriver, CFDictionaryRef inDescription, const AudioServerPlugInClientInfo* inClientInfo, AudioObjectID* outDeviceObjectID)\n{\n\t//\tThis method is used to tell a driver that implements the Transport Manager semantics to\n\t//\tcreate an AudioEndpointDevice from a set of AudioEndpoints. Since this driver is not a\n\t//\tTransport Manager, we just check the arguments and return\n\t//\tkAudioHardwareUnsupportedOperationError.\n\t\n\t#pragma unused(inDescription, inClientInfo, outDeviceObjectID)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = kAudioHardwareUnsupportedOperationError;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_CreateDevice: bad driver reference\");\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_DestroyDevice(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID)\n{\n\t//\tThis method is used to tell a driver that implements the Transport Manager semantics to\n\t//\tdestroy an AudioEndpointDevice. Since this driver is not a Transport Manager, we just check\n\t//\tthe arguments and return kAudioHardwareUnsupportedOperationError.\n\t\n\t#pragma unused(inDeviceObjectID)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = kAudioHardwareUnsupportedOperationError;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_DestroyDevice: bad driver reference\");\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_AddDeviceClient(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, const AudioServerPlugInClientInfo* inClientInfo)\n{\n\t//\tThis method is used to inform the driver about a new client that is using the given device.\n\t//\tThis allows the device to act differently depending on who the client is. This driver does\n\t//\tnot need to track the clients using the device, so we just check the arguments and return\n\t//\tsuccessfully.\n\t\n\t#pragma unused(inClientInfo)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_AddDeviceClient: bad driver reference\");\n\tFailWithAction(inDeviceObjectID != kObjectID_Device && inDeviceObjectID != kObjectID_Device2, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_AddDeviceClient: bad device ID\");\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_RemoveDeviceClient(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, const AudioServerPlugInClientInfo* inClientInfo)\n{\n\t//\tThis method is used to inform the driver about a client that is no longer using the given\n\t//\tdevice. This driver does not track clients, so we just check the arguments and return\n\t//\tsuccessfully.\n\t\n\t#pragma unused(inClientInfo)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_RemoveDeviceClient: bad driver reference\");\n\tFailWithAction(inDeviceObjectID != kObjectID_Device && inDeviceObjectID != kObjectID_Device2, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_RemoveDeviceClient: bad device ID\");\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_PerformDeviceConfigurationChange(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, UInt64 inChangeAction, void* inChangeInfo)\n{\n\t//\tThis method is called to tell the device that it can perform the configuration change that it\n\t//\thad requested via a call to the host method, RequestDeviceConfigurationChange(). The\n\t//\targuments, inChangeAction and inChangeInfo are the same as what was passed to\n\t//\tRequestDeviceConfigurationChange().\n\t//\n\t//\tThe HAL guarantees that IO will be stopped while this method is in progress. The HAL will\n\t//\talso handle figuring out exactly what changed for the non-control related properties. This\n\t//\tmeans that the only notifications that would need to be sent here would be for either\n\t//\tcustom properties the HAL doesn't know about or for controls.\n\t//\n\t//\tFor the device implemented by this driver, sample rate changes and enabling/disabling\n\t//\tthe pitch adjust go through this process.\n\t//\tThese are the only states that can be changed for the device that aren't controls.\n\t//\tWhich change is requested is passed in the inChangeAction argument.\n\t\n\t#pragma unused(inChangeInfo)\n\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n    Float64 newSampleRate = 0.0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_PerformDeviceConfigurationChange: bad driver reference\");\n    FailWithAction(inDeviceObjectID != kObjectID_Device && inDeviceObjectID != kObjectID_Device2, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_PerformDeviceConfigurationChange: bad device ID\");\n    switch(inChangeAction)\n    {\n        case ChangeAction_EnablePitchControl:\n            pthread_mutex_lock(&gPlugIn_StateMutex);\n            gPitch_Adjust_Enabled = true;\n            pthread_mutex_unlock(&gPlugIn_StateMutex);\n            break;\n        case ChangeAction_DisablePitchControl:\n            pthread_mutex_lock(&gPlugIn_StateMutex);\n            gPitch_Adjust_Enabled = false;\n            pthread_mutex_unlock(&gPlugIn_StateMutex);\n            break;\n        case ChangeAction_SetSampleRate:\n            pthread_mutex_lock(&gPlugIn_StateMutex);\n            newSampleRate = gDevice_RequestedSampleRate;\n            pthread_mutex_unlock(&gPlugIn_StateMutex);\n            FailWithAction(!is_valid_sample_rate(newSampleRate), theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_PerformDeviceConfigurationChange: bad sample rate\");\n            \n            //\tlock the state mutex\n            pthread_mutex_lock(&gPlugIn_StateMutex);\n            \n            //\tchange the sample rate\n            gDevice_SampleRate = newSampleRate;\n            \n            //\trecalculate the state that depends on the sample rate\n            struct mach_timebase_info theTimeBaseInfo;\n            mach_timebase_info(&theTimeBaseInfo);\n            Float64 theHostClockFrequency = (Float64)theTimeBaseInfo.denom / (Float64)theTimeBaseInfo.numer;\n            theHostClockFrequency *= 1000000000.0;\n            gDevice_HostTicksPerFrame = theHostClockFrequency / gDevice_SampleRate;\n            gDevice_AdjustedTicksPerFrame = gDevice_HostTicksPerFrame - gDevice_HostTicksPerFrame/100.0 * 2.0*(gPitch_Adjust - 0.5);\n            \n            //\tunlock the state mutex\n            pthread_mutex_unlock(&gPlugIn_StateMutex);\n            \n            // DebugMsg(\"BlackHole theTimeBaseInfo.numer: %u \\t theTimeBaseInfo.denom: %u\", theTimeBaseInfo.numer, theTimeBaseInfo.denom);\n            break;\n    };\n\t\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_AbortDeviceConfigurationChange(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, UInt64 inChangeAction, void* inChangeInfo)\n{\n\t//\tThis method is called to tell the driver that a request for a config change has been denied.\n\t//\tThis provides the driver an opportunity to clean up any state associated with the request.\n\t//\tFor this driver, an aborted config change requires no action. So we just check the arguments\n\t//\tand return\n\n\t#pragma unused(inChangeAction, inChangeInfo)\n\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_PerformDeviceConfigurationChange: bad driver reference\");\n\tFailWithAction(inDeviceObjectID != kObjectID_Device && inDeviceObjectID != kObjectID_Device2, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_PerformDeviceConfigurationChange: bad device ID\");\n\nDone:\n\treturn theAnswer;\n}\n\n#pragma mark Property Operations\n\nstatic Boolean\tBlackHole_HasProperty(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress)\n{\n\t//\tThis method returns whether or not the given object has the given property.\n\t\n\t//\tdeclare the local variables\n\tBoolean theAnswer = false;\n\t\n\t//\tcheck the arguments\n\tFailIf(inDriver != gAudioServerPlugInDriverRef, Done, \"BlackHole_HasProperty: bad driver reference\");\n\tFailIf(inAddress == NULL, Done, \"BlackHole_HasProperty: no address\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetPropertyData() method.\n\tswitch(inObjectID)\n\t{\n\t\tcase kObjectID_PlugIn:\n\t\t\ttheAnswer = BlackHole_HasPlugInProperty(inDriver, inObjectID, inClientProcessID, inAddress);\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Box:\n\t\t\ttheAnswer = BlackHole_HasBoxProperty(inDriver, inObjectID, inClientProcessID, inAddress);\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Device:\n        case kObjectID_Device2:\n\t\t\ttheAnswer = BlackHole_HasDeviceProperty(inDriver, inObjectID, inClientProcessID, inAddress);\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Stream_Input:\n\t\tcase kObjectID_Stream_Output:\n\t\t\ttheAnswer = BlackHole_HasStreamProperty(inDriver, inObjectID, inClientProcessID, inAddress);\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Volume_Output_Master:\n\t\tcase kObjectID_Mute_Output_Master:\n\t\tcase kObjectID_Volume_Input_Master:\n\t\tcase kObjectID_Mute_Input_Master:\n\t\tcase kObjectID_Pitch_Adjust:\n        case kObjectID_ClockSource:\n\t\t\ttheAnswer = BlackHole_HasControlProperty(inDriver, inObjectID, inClientProcessID, inAddress);\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_IsPropertySettable(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, Boolean* outIsSettable)\n{\n\t//\tThis method returns whether or not the given property on the object can have its value\n\t//\tchanged.\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_IsPropertySettable: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_IsPropertySettable: no address\");\n\tFailWithAction(outIsSettable == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_IsPropertySettable: no place to put the return value\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetPropertyData() method.\n\tswitch(inObjectID)\n\t{\n\t\tcase kObjectID_PlugIn:\n\t\t\ttheAnswer = BlackHole_IsPlugInPropertySettable(inDriver, inObjectID, inClientProcessID, inAddress, outIsSettable);\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Box:\n\t\t\ttheAnswer = BlackHole_IsBoxPropertySettable(inDriver, inObjectID, inClientProcessID, inAddress, outIsSettable);\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Device:\n        case kObjectID_Device2:\n\t\t\ttheAnswer = BlackHole_IsDevicePropertySettable(inDriver, inObjectID, inClientProcessID, inAddress, outIsSettable);\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Stream_Input:\n\t\tcase kObjectID_Stream_Output:\n\t\t\ttheAnswer = BlackHole_IsStreamPropertySettable(inDriver, inObjectID, inClientProcessID, inAddress, outIsSettable);\n\t\t\tbreak;\n\n\t\tcase kObjectID_Volume_Output_Master:\n\t\tcase kObjectID_Mute_Output_Master:\n\t\tcase kObjectID_Volume_Input_Master:\n\t\tcase kObjectID_Mute_Input_Master:\n\t\tcase kObjectID_Pitch_Adjust:\n        case kObjectID_ClockSource:\n\t\t\ttheAnswer = BlackHole_IsControlPropertySettable(inDriver, inObjectID, inClientProcessID, inAddress, outIsSettable);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareBadObjectError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_GetPropertyDataSize(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* outDataSize)\n{\n\t//\tThis method returns the byte size of the property's data.\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetPropertyDataSize: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetPropertyDataSize: no address\");\n\tFailWithAction(outDataSize == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetPropertyDataSize: no place to put the return value\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetPropertyData() method.\n\tswitch(inObjectID)\n\t{\n\t\tcase kObjectID_PlugIn:\n\t\t\ttheAnswer = BlackHole_GetPlugInPropertyDataSize(inDriver, inObjectID, inClientProcessID, inAddress, inQualifierDataSize, inQualifierData, outDataSize);\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Box:\n\t\t\ttheAnswer = BlackHole_GetBoxPropertyDataSize(inDriver, inObjectID, inClientProcessID, inAddress, inQualifierDataSize, inQualifierData, outDataSize);\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Device:\n        case kObjectID_Device2:\n\t\t\ttheAnswer = BlackHole_GetDevicePropertyDataSize(inDriver, inObjectID, inClientProcessID, inAddress, inQualifierDataSize, inQualifierData, outDataSize);\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Stream_Input:\n\t\tcase kObjectID_Stream_Output:\n\t\t\ttheAnswer = BlackHole_GetStreamPropertyDataSize(inDriver, inObjectID, inClientProcessID, inAddress, inQualifierDataSize, inQualifierData, outDataSize);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kObjectID_Volume_Output_Master:\n\t\tcase kObjectID_Mute_Output_Master:\n\t\tcase kObjectID_Volume_Input_Master:\n\t\tcase kObjectID_Mute_Input_Master:\n\t\tcase kObjectID_Pitch_Adjust:\n        case kObjectID_ClockSource:\n\t\t\ttheAnswer = BlackHole_GetControlPropertyDataSize(inDriver, inObjectID, inClientProcessID, inAddress, inQualifierDataSize, inQualifierData, outDataSize);\n\t\t\tbreak;\n\t\t\t\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareBadObjectError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_GetPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, UInt32* outDataSize, void* outData)\n{\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetPropertyData: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetPropertyData: no address\");\n\tFailWithAction(outDataSize == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetPropertyData: no place to put the return value size\");\n\tFailWithAction(outData == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetPropertyData: no place to put the return value\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required.\n\t//\n\t//\tAlso, since most of the data that will get returned is static, there are few instances where\n\t//\tit is necessary to lock the state mutex.\n\tswitch(inObjectID)\n\t{\n\t\tcase kObjectID_PlugIn:\n\t\t\ttheAnswer = BlackHole_GetPlugInPropertyData(inDriver, inObjectID, inClientProcessID, inAddress, inQualifierDataSize, inQualifierData, inDataSize, outDataSize, outData);\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Box:\n\t\t\ttheAnswer = BlackHole_GetBoxPropertyData(inDriver, inObjectID, inClientProcessID, inAddress, inQualifierDataSize, inQualifierData, inDataSize, outDataSize, outData);\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Device:\n        case kObjectID_Device2:\n\t\t\ttheAnswer = BlackHole_GetDevicePropertyData(inDriver, inObjectID, inClientProcessID, inAddress, inQualifierDataSize, inQualifierData, inDataSize, outDataSize, outData);\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Stream_Input:\n\t\tcase kObjectID_Stream_Output:\n\t\t\ttheAnswer = BlackHole_GetStreamPropertyData(inDriver, inObjectID, inClientProcessID, inAddress, inQualifierDataSize, inQualifierData, inDataSize, outDataSize, outData);\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Volume_Output_Master:\n\t\tcase kObjectID_Mute_Output_Master:\n\t\tcase kObjectID_Volume_Input_Master:\n\t\tcase kObjectID_Mute_Input_Master:\n\t\tcase kObjectID_Pitch_Adjust:\n        case kObjectID_ClockSource:\n\t\t\ttheAnswer = BlackHole_GetControlPropertyData(inDriver, inObjectID, inClientProcessID, inAddress, inQualifierDataSize, inQualifierData, inDataSize, outDataSize, outData);\n\t\t\tbreak;\n\t\t\t\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareBadObjectError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_SetPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, const void* inData)\n{\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\tUInt32 theNumberPropertiesChanged = 0;\n\tAudioObjectPropertyAddress theChangedAddresses[2];\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_SetPropertyData: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_SetPropertyData: no address\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetPropertyData() method.\n\tswitch(inObjectID)\n\t{\n\t\tcase kObjectID_PlugIn:\n\t\t\ttheAnswer = BlackHole_SetPlugInPropertyData(inDriver, inObjectID, inClientProcessID, inAddress, inQualifierDataSize, inQualifierData, inDataSize, inData, &theNumberPropertiesChanged, theChangedAddresses);\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Box:\n\t\t\ttheAnswer = BlackHole_SetBoxPropertyData(inDriver, inObjectID, inClientProcessID, inAddress, inQualifierDataSize, inQualifierData, inDataSize, inData, &theNumberPropertiesChanged, theChangedAddresses);\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Device:\n        case kObjectID_Device2:\n\t\t\ttheAnswer = BlackHole_SetDevicePropertyData(inDriver, inObjectID, inClientProcessID, inAddress, inQualifierDataSize, inQualifierData, inDataSize, inData, &theNumberPropertiesChanged, theChangedAddresses);\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Stream_Input:\n\t\tcase kObjectID_Stream_Output:\n\t\t\ttheAnswer = BlackHole_SetStreamPropertyData(inDriver, inObjectID, inClientProcessID, inAddress, inQualifierDataSize, inQualifierData, inDataSize, inData, &theNumberPropertiesChanged, theChangedAddresses);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kObjectID_Volume_Output_Master:\n\t\tcase kObjectID_Mute_Output_Master:\n\t\tcase kObjectID_Volume_Input_Master:\n\t\tcase kObjectID_Mute_Input_Master:\n\t\tcase kObjectID_Pitch_Adjust:\n        case kObjectID_ClockSource:\n\t\t\ttheAnswer = BlackHole_SetControlPropertyData(inDriver, inObjectID, inClientProcessID, inAddress, inQualifierDataSize, inQualifierData, inDataSize, inData, &theNumberPropertiesChanged, theChangedAddresses);\n\t\t\tbreak;\n\t\t\t\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareBadObjectError;\n\t\t\tbreak;\n\t};\n\n\t//\tsend any notifications\n\tif(theNumberPropertiesChanged > 0)\n\t{\n\t\tgPlugIn_Host->PropertiesChanged(gPlugIn_Host, inObjectID, theNumberPropertiesChanged, theChangedAddresses);\n\t}\n\nDone:\n\treturn theAnswer;\n}\n\n#pragma mark PlugIn Property Operations\n\nstatic Boolean\tBlackHole_HasPlugInProperty(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress)\n{\n\t//\tThis method returns whether or not the plug-in object has the given property.\n\t\n\t#pragma unused(inClientProcessID)\n\t\n\t//\tdeclare the local variables\n\tBoolean theAnswer = false;\n\t\n\t//\tcheck the arguments\n\tFailIf(inDriver != gAudioServerPlugInDriverRef, Done, \"BlackHole_HasPlugInProperty: bad driver reference\");\n\tFailIf(inAddress == NULL, Done, \"BlackHole_HasPlugInProperty: no address\");\n\tFailIf(inObjectID != kObjectID_PlugIn, Done, \"BlackHole_HasPlugInProperty: not the plug-in object\");\n\t\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetPlugInPropertyData() method.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tcase kAudioObjectPropertyBaseClass:\n\t\tcase kAudioObjectPropertyClass:\n\t\tcase kAudioObjectPropertyOwner:\n\t\tcase kAudioObjectPropertyManufacturer:\n\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\tcase kAudioPlugInPropertyBoxList:\n\t\tcase kAudioPlugInPropertyTranslateUIDToBox:\n\t\tcase kAudioPlugInPropertyDeviceList:\n\t\tcase kAudioPlugInPropertyTranslateUIDToDevice:\n\t\tcase kAudioPlugInPropertyResourceBundle:\n\t\t\ttheAnswer = true;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_IsPlugInPropertySettable(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, Boolean* outIsSettable)\n{\n\t//\tThis method returns whether or not the given property on the plug-in object can have its\n\t//\tvalue changed.\n\t\n\t#pragma unused(inClientProcessID)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_IsPlugInPropertySettable: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_IsPlugInPropertySettable: no address\");\n\tFailWithAction(outIsSettable == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_IsPlugInPropertySettable: no place to put the return value\");\n\tFailWithAction(inObjectID != kObjectID_PlugIn, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_IsPlugInPropertySettable: not the plug-in object\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetPlugInPropertyData() method.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tcase kAudioObjectPropertyBaseClass:\n\t\tcase kAudioObjectPropertyClass:\n\t\tcase kAudioObjectPropertyOwner:\n\t\tcase kAudioObjectPropertyManufacturer:\n\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\tcase kAudioPlugInPropertyBoxList:\n\t\tcase kAudioPlugInPropertyTranslateUIDToBox:\n\t\tcase kAudioPlugInPropertyDeviceList:\n\t\tcase kAudioPlugInPropertyTranslateUIDToDevice:\n\t\tcase kAudioPlugInPropertyResourceBundle:\n\t\t\t*outIsSettable = false;\n\t\t\tbreak;\n\t\t\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_GetPlugInPropertyDataSize(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* outDataSize)\n{\n\t//\tThis method returns the byte size of the property's data.\n\t\n\t#pragma unused(inClientProcessID, inQualifierDataSize, inQualifierData)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetPlugInPropertyDataSize: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetPlugInPropertyDataSize: no address\");\n\tFailWithAction(outDataSize == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetPlugInPropertyDataSize: no place to put the return value\");\n\tFailWithAction(inObjectID != kObjectID_PlugIn, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetPlugInPropertyDataSize: not the plug-in object\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetPlugInPropertyData() method.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyClass:\n\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyOwner:\n\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyManufacturer:\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\tif(gBox_Acquired)\n\t\t\t{\n\t\t\t\t*outDataSize = 2 * sizeof(AudioClassID);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\t}\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioPlugInPropertyBoxList:\n\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioPlugInPropertyTranslateUIDToBox:\n\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioPlugInPropertyDeviceList:\n\t\t\tif(gBox_Acquired)\n\t\t\t{\n\t\t\t\t*outDataSize = sizeof(AudioClassID)*2;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t*outDataSize = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioPlugInPropertyTranslateUIDToDevice:\n\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioPlugInPropertyResourceBundle:\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\t\t\t\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_GetPlugInPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, UInt32* outDataSize, void* outData)\n{\n\t#pragma unused(inClientProcessID)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\tUInt32 theNumberItemsToFetch;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetPlugInPropertyData: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetPlugInPropertyData: no address\");\n\tFailWithAction(outDataSize == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetPlugInPropertyData: no place to put the return value size\");\n\tFailWithAction(outData == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetPlugInPropertyData: no place to put the return value\");\n\tFailWithAction(inObjectID != kObjectID_PlugIn, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetPlugInPropertyData: not the plug-in object\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required.\n\t//\n\t//\tAlso, since most of the data that will get returned is static, there are few instances where\n\t//\tit is necessary to lock the state mutex.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t//\tThe base class for kAudioPlugInClassID is kAudioObjectClassID\n\t\t\tFailWithAction(inDataSize < sizeof(AudioClassID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetPlugInPropertyData: not enough space for the return value of kAudioObjectPropertyBaseClass for the plug-in\");\n\t\t\t*((AudioClassID*)outData) = kAudioObjectClassID;\n\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyClass:\n\t\t\t//\tThe class is always kAudioPlugInClassID for regular drivers\n\t\t\tFailWithAction(inDataSize < sizeof(AudioClassID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetPlugInPropertyData: not enough space for the return value of kAudioObjectPropertyClass for the plug-in\");\n\t\t\t*((AudioClassID*)outData) = kAudioPlugInClassID;\n\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyOwner:\n\t\t\t//\tThe plug-in doesn't have an owning object\n\t\t\tFailWithAction(inDataSize < sizeof(AudioObjectID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetPlugInPropertyData: not enough space for the return value of kAudioObjectPropertyOwner for the plug-in\");\n\t\t\t*((AudioObjectID*)outData) = kAudioObjectUnknown;\n\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyManufacturer:\n\t\t\t//\tThis is the human readable name of the maker of the plug-in.\n\t\t\tFailWithAction(inDataSize < sizeof(CFStringRef), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetPlugInPropertyData: not enough space for the return value of kAudioObjectPropertyManufacturer for the plug-in\");\n\t\t\t*((CFStringRef*)outData) = CFSTR(\"Apple Inc.\");\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t//\tCalculate the number of items that have been requested. Note that this\n\t\t\t//\tnumber is allowed to be smaller than the actual size of the list. In such\n\t\t\t//\tcase, only that number of items will be returned\n\t\t\ttheNumberItemsToFetch = inDataSize / sizeof(AudioObjectID);\n\t\t\t\n\t\t\t//\tClamp that to the number of boxes this driver implements (which is just 1)\n\t\t\tif(theNumberItemsToFetch > (gBox_Acquired ? 2 : 1))\n\t\t\t{\n\t\t\t\ttheNumberItemsToFetch = (gBox_Acquired ? 2 : 1);\n\t\t\t}\n\t\t\t\n\t\t\t//\tWrite the devices' object IDs into the return value\n\t\t\tif(theNumberItemsToFetch > 1)\n\t\t\t{\n\t\t\t\t((AudioObjectID*)outData)[0] = kObjectID_Box;\n\t\t\t\t((AudioObjectID*)outData)[0] = kObjectID_Device;\n\t\t\t}\n\t\t\telse if(theNumberItemsToFetch > 0)\n\t\t\t{\n\t\t\t\t((AudioObjectID*)outData)[0] = kObjectID_Box;\n\t\t\t}\n\t\t\t\n\t\t\t//\tReturn how many bytes we wrote to\n\t\t\t*outDataSize = theNumberItemsToFetch * sizeof(AudioClassID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioPlugInPropertyBoxList:\n\t\t\t//\tCalculate the number of items that have been requested. Note that this\n\t\t\t//\tnumber is allowed to be smaller than the actual size of the list. In such\n\t\t\t//\tcase, only that number of items will be returned\n\t\t\ttheNumberItemsToFetch = inDataSize / sizeof(AudioObjectID);\n\t\t\t\n\t\t\t//\tClamp that to the number of boxes this driver implements (which is just 1)\n\t\t\tif(theNumberItemsToFetch > 1)\n\t\t\t{\n\t\t\t\ttheNumberItemsToFetch = 1;\n\t\t\t}\n\t\t\t\n\t\t\t//\tWrite the devices' object IDs into the return value\n\t\t\tif(theNumberItemsToFetch > 0)\n\t\t\t{\n\t\t\t\t((AudioObjectID*)outData)[0] = kObjectID_Box;\n\t\t\t}\n\t\t\t\n\t\t\t//\tReturn how many bytes we wrote to\n\t\t\t*outDataSize = theNumberItemsToFetch * sizeof(AudioClassID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioPlugInPropertyTranslateUIDToBox:\n\t\t\t//\tThis property takes the CFString passed in the qualifier and converts that\n\t\t\t//\tto the object ID of the box it corresponds to. For this driver, there is\n\t\t\t//\tjust the one box. Note that it is not an error if the string in the\n\t\t\t//\tqualifier doesn't match any devices. In such case, kAudioObjectUnknown is\n\t\t\t//\tthe object ID to return.\n\t\t\tFailWithAction(inDataSize < sizeof(AudioObjectID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetPlugInPropertyData: not enough space for the return value of kAudioPlugInPropertyTranslateUIDToBox\");\n\t\t\tFailWithAction(inQualifierDataSize == sizeof(CFStringRef), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetPlugInPropertyData: the qualifier is the wrong size for kAudioPlugInPropertyTranslateUIDToBox\");\n\t\t\tFailWithAction(inQualifierData == NULL, theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetPlugInPropertyData: no qualifier for kAudioPlugInPropertyTranslateUIDToBox\");\n\n\t\t\tCFStringRef boxUID = get_box_uid();\n\n\t\t\tif(CFStringCompare(*((CFStringRef*)inQualifierData), boxUID, 0) == kCFCompareEqualTo)\n\t\t\t{\n\t\t\t\tCFStringRef formattedString = CFStringCreateWithFormat(NULL, NULL, CFSTR(kBox_UID), kNumber_Of_Channels);\n\t\t\t\tif(CFStringCompare(*((CFStringRef*)inQualifierData), formattedString, 0) == kCFCompareEqualTo)\n\t\t\t\t{\n\t\t\t\t\t*((AudioObjectID*)outData) = kObjectID_Box;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t*((AudioObjectID*)outData) = kAudioObjectUnknown;\n\t\t\t\t}\n\t\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\t\tCFRelease(formattedString);\n\n\t\t\t\t*((AudioObjectID*)outData) = kObjectID_Box;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t*((AudioObjectID*)outData) = kAudioObjectUnknown;\n\t\t\t}\n\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\tCFRelease(boxUID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioPlugInPropertyDeviceList:\n\t\t\t//\tCalculate the number of items that have been requested. Note that this\n\t\t\t//\tnumber is allowed to be smaller than the actual size of the list. In such\n\t\t\t//\tcase, only that number of items will be returned\n\t\t\ttheNumberItemsToFetch = inDataSize / sizeof(AudioObjectID);\n\t\t\t\n\t\t\t//\tClamp that to the number of devices this driver implements (which is just 1 if the\n\t\t\t//\tbox has been acquired)\n\t\t\tif(theNumberItemsToFetch > (gBox_Acquired ? 2 : 0))\n\t\t\t{\n\t\t\t\ttheNumberItemsToFetch = (gBox_Acquired ? 2 : 0);\n\t\t\t}\n\t\t\t\n\t\t\t//\tWrite the devices' object IDs into the return value\n\t\t\tif(theNumberItemsToFetch > 1)\n\t\t\t{\n\t\t\t\t((AudioObjectID*)outData)[0] = kObjectID_Device;\n                ((AudioObjectID*)outData)[1] = kObjectID_Device2;\n\t\t\t}\n            else if(theNumberItemsToFetch > 0)\n            {\n                ((AudioObjectID*)outData)[0] = kObjectID_Device;\n            }\n\t\t\t\n\t\t\t//\tReturn how many bytes we wrote to\n\t\t\t*outDataSize = theNumberItemsToFetch * sizeof(AudioClassID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioPlugInPropertyTranslateUIDToDevice:\n\t\t\t//\tThis property takes the CFString passed in the qualifier and converts that\n\t\t\t//\tto the object ID of the device it corresponds to. For this driver, there is\n\t\t\t//\tjust the one device. Note that it is not an error if the string in the\n\t\t\t//\tqualifier doesn't match any devices. In such case, kAudioObjectUnknown is\n\t\t\t//\tthe object ID to return.\n\t\t\tFailWithAction(inDataSize < sizeof(AudioObjectID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetPlugInPropertyData: not enough space for the return value of kAudioPlugInPropertyTranslateUIDToDevice\");\n\t\t\tFailWithAction(inQualifierDataSize == sizeof(CFStringRef), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetPlugInPropertyData: the qualifier is the wrong size for kAudioPlugInPropertyTranslateUIDToDevice\");\n\t\t\tFailWithAction(inQualifierData == NULL, theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetPlugInPropertyData: no qualifier for kAudioPlugInPropertyTranslateUIDToDevice\");\n            \n            \n\t\t\t\n\t\t\tCFStringRef deviceUID = get_device_uid();\n            CFStringRef device2UID = get_device2_uid();\n\n\t\t\tif(CFStringCompare(*((CFStringRef*)inQualifierData), deviceUID, 0) == kCFCompareEqualTo)\n\t\t\t{\n\t\t\t\t*((AudioObjectID*)outData) = kObjectID_Device;\n\t\t\t}\n            else if(CFStringCompare(*((CFStringRef*)inQualifierData), device2UID, 0) == kCFCompareEqualTo)\n            {\n                *((AudioObjectID*)outData) = kObjectID_Device2;\n            }\n\t\t\telse\n\t\t\t{\n\t\t\t\t*((AudioObjectID*)outData) = kAudioObjectUnknown;\n\t\t\t}\n\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\tCFRelease(deviceUID);\n            CFRelease(device2UID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioPlugInPropertyResourceBundle:\n\t\t\t//\tThe resource bundle is a path relative to the path of the plug-in's bundle.\n\t\t\t//\tTo specify that the plug-in bundle itself should be used, we just return the\n\t\t\t//\tempty string.\n\t\t\tFailWithAction(inDataSize < sizeof(AudioObjectID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetPlugInPropertyData: not enough space for the return value of kAudioPlugInPropertyResourceBundle\");\n\t\t\t*((CFStringRef*)outData) = CFSTR(\"\");\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\t\t\t\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_SetPlugInPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, const void* inData, UInt32* outNumberPropertiesChanged, AudioObjectPropertyAddress outChangedAddresses[2])\n{\n\t#pragma unused(inClientProcessID, inQualifierDataSize, inQualifierData, inDataSize, inData)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_SetPlugInPropertyData: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_SetPlugInPropertyData: no address\");\n\tFailWithAction(outNumberPropertiesChanged == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_SetPlugInPropertyData: no place to return the number of properties that changed\");\n\tFailWithAction(outChangedAddresses == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_SetPlugInPropertyData: no place to return the properties that changed\");\n\tFailWithAction(inObjectID != kObjectID_PlugIn, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_SetPlugInPropertyData: not the plug-in object\");\n\t\n\t//\tinitialize the returned number of changed properties\n\t*outNumberPropertiesChanged = 0;\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetPlugInPropertyData() method.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\n#pragma mark Box Property Operations\n\nstatic Boolean\tBlackHole_HasBoxProperty(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress)\n{\n\t//\tThis method returns whether or not the box object has the given property.\n\t\n\t#pragma unused(inClientProcessID)\n\t\n\t//\tdeclare the local variables\n\tBoolean theAnswer = false;\n\t\n\t//\tcheck the arguments\n\tFailIf(inDriver != gAudioServerPlugInDriverRef, Done, \"BlackHole_HasBoxProperty: bad driver reference\");\n\tFailIf(inAddress == NULL, Done, \"BlackHole_HasBoxProperty: no address\");\n\tFailIf(inObjectID != kObjectID_Box, Done, \"BlackHole_HasBoxProperty: not the box object\");\n\t\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetBoxPropertyData() method.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tcase kAudioObjectPropertyBaseClass:\n\t\tcase kAudioObjectPropertyClass:\n\t\tcase kAudioObjectPropertyOwner:\n\t\tcase kAudioObjectPropertyName:\n\t\tcase kAudioObjectPropertyModelName:\n\t\tcase kAudioObjectPropertyManufacturer:\n\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\tcase kAudioObjectPropertyIdentify:\n\t\tcase kAudioObjectPropertySerialNumber:\n\t\tcase kAudioObjectPropertyFirmwareVersion:\n\t\tcase kAudioBoxPropertyBoxUID:\n\t\tcase kAudioBoxPropertyTransportType:\n\t\tcase kAudioBoxPropertyHasAudio:\n\t\tcase kAudioBoxPropertyHasVideo:\n\t\tcase kAudioBoxPropertyHasMIDI:\n\t\tcase kAudioBoxPropertyIsProtected:\n\t\tcase kAudioBoxPropertyAcquired:\n\t\tcase kAudioBoxPropertyAcquisitionFailed:\n\t\tcase kAudioBoxPropertyDeviceList:\n\t\t\ttheAnswer = true;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_IsBoxPropertySettable(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, Boolean* outIsSettable)\n{\n\t//\tThis method returns whether or not the given property on the plug-in object can have its\n\t//\tvalue changed.\n\t\n\t#pragma unused(inClientProcessID)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_IsBoxPropertySettable: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_IsBoxPropertySettable: no address\");\n\tFailWithAction(outIsSettable == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_IsBoxPropertySettable: no place to put the return value\");\n\tFailWithAction(inObjectID != kObjectID_Box, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_IsBoxPropertySettable: not the plug-in object\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetBoxPropertyData() method.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tcase kAudioObjectPropertyBaseClass:\n\t\tcase kAudioObjectPropertyClass:\n\t\tcase kAudioObjectPropertyOwner:\n\t\tcase kAudioObjectPropertyModelName:\n\t\tcase kAudioObjectPropertyManufacturer:\n\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\tcase kAudioObjectPropertySerialNumber:\n\t\tcase kAudioObjectPropertyFirmwareVersion:\n\t\tcase kAudioBoxPropertyBoxUID:\n\t\tcase kAudioBoxPropertyTransportType:\n\t\tcase kAudioBoxPropertyHasAudio:\n\t\tcase kAudioBoxPropertyHasVideo:\n\t\tcase kAudioBoxPropertyHasMIDI:\n\t\tcase kAudioBoxPropertyIsProtected:\n\t\tcase kAudioBoxPropertyAcquisitionFailed:\n\t\tcase kAudioBoxPropertyDeviceList:\n\t\t\t*outIsSettable = false;\n\t\t\tbreak;\n\t\t\n\t\tcase kAudioObjectPropertyName:\n\t\tcase kAudioObjectPropertyIdentify:\n\t\tcase kAudioBoxPropertyAcquired:\n\t\t\t*outIsSettable = true;\n\t\t\tbreak;\n\t\t\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_GetBoxPropertyDataSize(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* outDataSize)\n{\n\t//\tThis method returns the byte size of the property's data.\n\t\n\t#pragma unused(inClientProcessID, inQualifierDataSize, inQualifierData)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetBoxPropertyDataSize: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetBoxPropertyDataSize: no address\");\n\tFailWithAction(outDataSize == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetBoxPropertyDataSize: no place to put the return value\");\n\tFailWithAction(inObjectID != kObjectID_Box, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetBoxPropertyDataSize: not the plug-in object\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetBoxPropertyData() method.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyClass:\n\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyOwner:\n\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyName:\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyModelName:\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyManufacturer:\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t*outDataSize = 0;\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyIdentify:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertySerialNumber:\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyFirmwareVersion:\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioBoxPropertyBoxUID:\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioBoxPropertyTransportType:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioBoxPropertyHasAudio:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioBoxPropertyHasVideo:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioBoxPropertyHasMIDI:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioBoxPropertyIsProtected:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioBoxPropertyAcquired:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioBoxPropertyAcquisitionFailed:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioBoxPropertyDeviceList:\n\t\t\t{\n\t\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\t\t\t*outDataSize = gBox_Acquired ? sizeof(AudioObjectID) * 2 : 0;\n\t\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\t}\n\t\t\tbreak;\n\t\t\t\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_GetBoxPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, UInt32* outDataSize, void* outData)\n{\n\t#pragma unused(inClientProcessID, inQualifierDataSize, inQualifierData)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetBoxPropertyData: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetBoxPropertyData: no address\");\n\tFailWithAction(outDataSize == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetBoxPropertyData: no place to put the return value size\");\n\tFailWithAction(outData == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetBoxPropertyData: no place to put the return value\");\n\tFailWithAction(inObjectID != kObjectID_Box, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetBoxPropertyData: not the plug-in object\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required.\n\t//\n\t//\tAlso, since most of the data that will get returned is static, there are few instances where\n\t//\tit is necessary to lock the state mutex.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t//\tThe base class for kAudioBoxClassID is kAudioObjectClassID\n\t\t\tFailWithAction(inDataSize < sizeof(AudioClassID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetBoxPropertyData: not enough space for the return value of kAudioObjectPropertyBaseClass for the box\");\n\t\t\t*((AudioClassID*)outData) = kAudioObjectClassID;\n\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyClass:\n\t\t\t//\tThe class is always kAudioBoxClassID for regular drivers\n\t\t\tFailWithAction(inDataSize < sizeof(AudioClassID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetBoxPropertyData: not enough space for the return value of kAudioObjectPropertyClass for the box\");\n\t\t\t*((AudioClassID*)outData) = kAudioBoxClassID;\n\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyOwner:\n\t\t\t//\tThe owner is the plug-in object\n\t\t\tFailWithAction(inDataSize < sizeof(AudioObjectID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetBoxPropertyData: not enough space for the return value of kAudioObjectPropertyOwner for the box\");\n\t\t\t*((AudioObjectID*)outData) = kObjectID_PlugIn;\n\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyName:\n\t\t\t//\tThis is the human readable name of the maker of the box.\n\t\t\tFailWithAction(inDataSize < sizeof(CFStringRef), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetBoxPropertyData: not enough space for the return value of kAudioObjectPropertyManufacturer for the box\");\n\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\t\t*((CFStringRef*)outData) = gBox_Name;\n\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\tif(*((CFStringRef*)outData) != NULL)\n\t\t\t{\n\t\t\t\tCFRetain(*((CFStringRef*)outData));\n\t\t\t}\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyModelName:\n\t\t\t//\tThis is the human readable name of the maker of the box.\n\t\t\tFailWithAction(inDataSize < sizeof(CFStringRef), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetBoxPropertyData: not enough space for the return value of kAudioObjectPropertyManufacturer for the box\");\n\t\t\t*((CFStringRef*)outData) = CFSTR(\"BlackHole\");\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyManufacturer:\n\t\t\t//\tThis is the human readable name of the maker of the box.\n\t\t\tFailWithAction(inDataSize < sizeof(CFStringRef), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetBoxPropertyData: not enough space for the return value of kAudioObjectPropertyManufacturer for the box\");\n\t\t\t*((CFStringRef*)outData) = CFSTR(\"Existential Audio Inc.\");\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t//\tThis returns the objects directly owned by the object. Boxes don't own anything.\n\t\t\t*outDataSize = 0;\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyIdentify:\n\t\t\t//\tThis is used to highling the device in the UI, but it's value has no meaning\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetBoxPropertyData: not enough space for the return value of kAudioObjectPropertyIdentify for the box\");\n\t\t\t*((UInt32*)outData) = 0;\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertySerialNumber:\n\t\t\t//\tThis is the human readable serial number of the box.\n\t\t\tFailWithAction(inDataSize < sizeof(CFStringRef), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetBoxPropertyData: not enough space for the return value of kAudioObjectPropertySerialNumber for the box\");\n\t\t\t*((CFStringRef*)outData) = CFSTR(\"dd658747-4b9a-4de8-a001-c6a2ef1bb235\");\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyFirmwareVersion:\n\t\t\t//\tThis is the human readable firmware version of the box.\n\t\t\tFailWithAction(inDataSize < sizeof(CFStringRef), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetBoxPropertyData: not enough space for the return value of kAudioObjectPropertyFirmwareVersion for the box\");\n\t\t\t*((CFStringRef*)outData) = CFSTR(\"0.5.1\");\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioBoxPropertyBoxUID:\n\t\t\t//\tBoxes have UIDs the same as devices\n\t\t\tFailWithAction(inDataSize < sizeof(CFStringRef), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetBoxPropertyData: not enough space for the return value of kAudioObjectPropertyManufacturer for the box\");\n\n\t\t\t*((CFStringRef*)outData) = get_box_uid();\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioBoxPropertyTransportType:\n\t\t\t//\tThis value represents how the device is attached to the system. This can be\n\t\t\t//\tany 32 bit integer, but common values for this property are defined in\n\t\t\t//\t<CoreAudio/AudioHardwareBase.h>\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetBoxPropertyData: not enough space for the return value of kAudioDevicePropertyTransportType for the box\");\n\t\t\t*((UInt32*)outData) = kAudioDeviceTransportTypeVirtual;\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioBoxPropertyHasAudio:\n\t\t\t//\tIndicates whether or not the box has audio capabilities\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetBoxPropertyData: not enough space for the return value of kAudioBoxPropertyHasAudio for the box\");\n\t\t\t*((UInt32*)outData) = 1;\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioBoxPropertyHasVideo:\n\t\t\t//\tIndicates whether or not the box has video capabilities\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetBoxPropertyData: not enough space for the return value of kAudioBoxPropertyHasVideo for the box\");\n\t\t\t*((UInt32*)outData) = 0;\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioBoxPropertyHasMIDI:\n\t\t\t//\tIndicates whether or not the box has MIDI capabilities\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetBoxPropertyData: not enough space for the return value of kAudioBoxPropertyHasMIDI for the box\");\n\t\t\t*((UInt32*)outData) = 0;\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioBoxPropertyIsProtected:\n\t\t\t//\tIndicates whether or not the box has requires authentication to use\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetBoxPropertyData: not enough space for the return value of kAudioBoxPropertyIsProtected for the box\");\n\t\t\t*((UInt32*)outData) = 0;\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioBoxPropertyAcquired:\n\t\t\t//\tWhen set to a non-zero value, the device is acquired for use by the local machine\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetBoxPropertyData: not enough space for the return value of kAudioBoxPropertyAcquired for the box\");\n\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\t\t*((UInt32*)outData) = gBox_Acquired ? 1 : 0;\n\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioBoxPropertyAcquisitionFailed:\n\t\t\t//\tThis is used for notifications to say when an attempt to acquire a device has failed.\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetBoxPropertyData: not enough space for the return value of kAudioBoxPropertyAcquisitionFailed for the box\");\n\t\t\t*((UInt32*)outData) = 0;\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioBoxPropertyDeviceList:\n\t\t\t//\tThis is used to indicate which devices came from this box\n\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\t\tif(gBox_Acquired)\n\t\t\t{\n                if(inDataSize < sizeof(AudioObjectID))\n                {\n                    theAnswer = kAudioHardwareBadPropertySizeError;\n                    *outDataSize = 0;\n                }\n                else\n                {\n                    if (inDataSize >= sizeof(AudioObjectID) * 2)\n                    {\n                        ((AudioObjectID*)outData)[0] = kObjectID_Device;\n                        ((AudioObjectID*)outData)[1] = kObjectID_Device2;\n                        *outDataSize = sizeof(AudioObjectID) * 2;\n                    }\n                    else\n                    {\n                        ((AudioObjectID*)outData)[0] = kObjectID_Device;\n                        *outDataSize = sizeof(AudioObjectID) * 1;\n                    }\n                }\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t*outDataSize = 0;\n\t\t\t}\n            \n\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\tbreak;\n\t\t\t\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_SetBoxPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, const void* inData, UInt32* outNumberPropertiesChanged, AudioObjectPropertyAddress outChangedAddresses[2])\n{\n\t#pragma unused(inClientProcessID, inQualifierDataSize, inQualifierData, inDataSize, inData)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_SetBoxPropertyData: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_SetBoxPropertyData: no address\");\n\tFailWithAction(outNumberPropertiesChanged == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_SetBoxPropertyData: no place to return the number of properties that changed\");\n\tFailWithAction(outChangedAddresses == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_SetBoxPropertyData: no place to return the properties that changed\");\n\tFailWithAction(inObjectID != kObjectID_Box, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_SetBoxPropertyData: not the box object\");\n\t\n\t//\tinitialize the returned number of changed properties\n\t*outNumberPropertiesChanged = 0;\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetPlugInPropertyData() method.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tcase kAudioObjectPropertyName:\n\t\t\t//\tBoxes should allow their name to be editable\n\t\t\t{\n\t\t\t\tFailWithAction(inData == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_SetBoxPropertyData: NULL data for kAudioObjectPropertyName\");\n\t\t\t\tFailWithAction(inDataSize != sizeof(CFStringRef), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_SetBoxPropertyData: wrong size for the data for kAudioObjectPropertyName\");\n\t\t\t\tCFStringRef* theNewName = (CFStringRef*)inData;\n\t\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\t\t\tif((theNewName != NULL) && (*theNewName != NULL))\n\t\t\t\t{\n\t\t\t\t\tCFRetain(*theNewName);\n\t\t\t\t}\n\t\t\t\tif(gBox_Name != NULL)\n\t\t\t\t{\n\t\t\t\t\tCFRelease(gBox_Name);\n\t\t\t\t}\n\t\t\t\tgBox_Name = *theNewName;\n\t\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\t\t*outNumberPropertiesChanged = 1;\n\t\t\t\toutChangedAddresses[0].mSelector = kAudioObjectPropertyName;\n\t\t\t\toutChangedAddresses[0].mScope = kAudioObjectPropertyScopeGlobal;\n\t\t\t\toutChangedAddresses[0].mElement = kAudioObjectPropertyElementMain;\n\t\t\t}\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyIdentify:\n\t\t\t//\tsince we don't have any actual hardware to flash, we will schedule a notification for\n\t\t\t//\tthis property off into the future as a testing thing. Note that a real implementation\n\t\t\t//\tof this property should only send the notification if the hardware wants the app to\n\t\t\t//\tflash it's UI for the device.\n\t\t\t{\n\t\t\t\tsyslog(LOG_NOTICE, \"The identify property has been set on the Box implemented by the BlackHole driver.\");\n\t\t\t\tFailWithAction(inDataSize != sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_SetBoxPropertyData: wrong size for the data for kAudioObjectPropertyIdentify\");\n\t\t\t\tdispatch_after(dispatch_time(0, 2ULL * 1000ULL * 1000ULL * 1000ULL), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),\t^()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAudioObjectPropertyAddress theAddress = { kAudioObjectPropertyIdentify, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMain };\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tgPlugIn_Host->PropertiesChanged(gPlugIn_Host, kObjectID_Box, 1, &theAddress);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t}\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioBoxPropertyAcquired:\n\t\t\t//\tWhen the box is acquired, it means the contents, namely the device, are available to the system\n\t\t\t{\n\t\t\t\tFailWithAction(inDataSize != sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_SetBoxPropertyData: wrong size for the data for kAudioBoxPropertyAcquired\");\n\t\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\t\t\tif(gBox_Acquired != (*((UInt32*)inData) != 0))\n\t\t\t\t{\n\t\t\t\t\t//\tthe new value is different from the old value, so save it\n\t\t\t\t\tgBox_Acquired = *((UInt32*)inData) != 0;\n\t\t\t\t\tgPlugIn_Host->WriteToStorage(gPlugIn_Host, CFSTR(\"box acquired\"), gBox_Acquired ? kCFBooleanTrue : kCFBooleanFalse);\n\t\t\t\t\t\n\t\t\t\t\t//\tand it means that this property and the device list property have changed\n\t\t\t\t\t*outNumberPropertiesChanged = 2;\n\t\t\t\t\toutChangedAddresses[0].mSelector = kAudioBoxPropertyAcquired;\n\t\t\t\t\toutChangedAddresses[0].mScope = kAudioObjectPropertyScopeGlobal;\n\t\t\t\t\toutChangedAddresses[0].mElement = kAudioObjectPropertyElementMain;\n\t\t\t\t\toutChangedAddresses[1].mSelector = kAudioBoxPropertyDeviceList;\n\t\t\t\t\toutChangedAddresses[1].mScope = kAudioObjectPropertyScopeGlobal;\n\t\t\t\t\toutChangedAddresses[1].mElement = kAudioObjectPropertyElementMain;\n\t\t\t\t\t\n\t\t\t\t\t//\tbut it also means that the device list has changed for the plug-in too\n\t\t\t\t\tdispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),\t^()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAudioObjectPropertyAddress theAddress = { kAudioPlugInPropertyDeviceList, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMain };\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tgPlugIn_Host->PropertiesChanged(gPlugIn_Host, kObjectID_PlugIn, 1, &theAddress);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\t}\n\t\t\tbreak;\n\t\t\t\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\n#pragma mark Device Property Operations\n\nstatic Boolean\tBlackHole_HasDeviceProperty(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress)\n{\n\t//\tThis method returns whether or not the given object has the given property.\n\t\n\t#pragma unused(inClientProcessID)\n\t\n\t//\tdeclare the local variables\n\tBoolean theAnswer = false;\n\t\n\t//\tcheck the arguments\n\tFailIf(inDriver != gAudioServerPlugInDriverRef, Done, \"BlackHole_HasDeviceProperty: bad driver reference\");\n\tFailIf(inAddress == NULL, Done, \"BlackHole_HasDeviceProperty: no address\");\n\tFailIf(inObjectID != kObjectID_Device && inObjectID != kObjectID_Device2, Done, \"BlackHole_HasDeviceProperty: not the device object\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetDevicePropertyData() method.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tcase kAudioObjectPropertyBaseClass:\n\t\tcase kAudioObjectPropertyClass:\n\t\tcase kAudioObjectPropertyOwner:\n\t\tcase kAudioObjectPropertyName:\n\t\tcase kAudioObjectPropertyManufacturer:\n\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\tcase kAudioDevicePropertyDeviceUID:\n\t\tcase kAudioDevicePropertyModelUID:\n\t\tcase kAudioDevicePropertyTransportType:\n\t\tcase kAudioDevicePropertyRelatedDevices:\n\t\tcase kAudioDevicePropertyClockDomain:\n\t\tcase kAudioDevicePropertyDeviceIsAlive:\n\t\tcase kAudioDevicePropertyDeviceIsRunning:\n\t\tcase kAudioObjectPropertyControlList:\n\t\tcase kAudioDevicePropertyNominalSampleRate:\n\t\tcase kAudioDevicePropertyAvailableNominalSampleRates:\n\t\tcase kAudioDevicePropertyIsHidden:\n\t\tcase kAudioDevicePropertyZeroTimeStampPeriod:\n\t\tcase kAudioDevicePropertyIcon:\n\t\tcase kAudioDevicePropertyStreams:\n\t\t\ttheAnswer = true;\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioDevicePropertyDeviceCanBeDefaultDevice:\n\t\tcase kAudioDevicePropertyDeviceCanBeDefaultSystemDevice:\n\t\tcase kAudioDevicePropertyLatency:\n\t\tcase kAudioDevicePropertySafetyOffset:\n\t\tcase kAudioDevicePropertyPreferredChannelsForStereo:\n\t\tcase kAudioDevicePropertyPreferredChannelLayout:\n\t\t\ttheAnswer = (inAddress->mScope == kAudioObjectPropertyScopeInput) || (inAddress->mScope == kAudioObjectPropertyScopeOutput);\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_IsDevicePropertySettable(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, Boolean* outIsSettable)\n{\n\t//\tThis method returns whether or not the given property on the object can have its value\n\t//\tchanged.\n\t\n\t#pragma unused(inClientProcessID)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_IsDevicePropertySettable: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_IsDevicePropertySettable: no address\");\n\tFailWithAction(outIsSettable == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_IsDevicePropertySettable: no place to put the return value\");\n\tFailWithAction(inObjectID != kObjectID_Device && inObjectID != kObjectID_Device2, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_IsDevicePropertySettable: not the device object\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetDevicePropertyData() method.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tcase kAudioObjectPropertyBaseClass:\n\t\tcase kAudioObjectPropertyClass:\n\t\tcase kAudioObjectPropertyOwner:\n\t\tcase kAudioObjectPropertyName:\n\t\tcase kAudioObjectPropertyManufacturer:\n\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\tcase kAudioDevicePropertyDeviceUID:\n\t\tcase kAudioDevicePropertyModelUID:\n\t\tcase kAudioDevicePropertyTransportType:\n\t\tcase kAudioDevicePropertyRelatedDevices:\n\t\tcase kAudioDevicePropertyClockDomain:\n\t\tcase kAudioDevicePropertyDeviceIsAlive:\n\t\tcase kAudioDevicePropertyDeviceIsRunning:\n\t\tcase kAudioDevicePropertyDeviceCanBeDefaultDevice:\n\t\tcase kAudioDevicePropertyDeviceCanBeDefaultSystemDevice:\n\t\tcase kAudioDevicePropertyLatency:\n\t\tcase kAudioDevicePropertyStreams:\n\t\tcase kAudioObjectPropertyControlList:\n\t\tcase kAudioDevicePropertySafetyOffset:\n\t\tcase kAudioDevicePropertyAvailableNominalSampleRates:\n\t\tcase kAudioDevicePropertyIsHidden:\n\t\tcase kAudioDevicePropertyPreferredChannelsForStereo:\n\t\tcase kAudioDevicePropertyPreferredChannelLayout:\n\t\tcase kAudioDevicePropertyZeroTimeStampPeriod:\n\t\tcase kAudioDevicePropertyIcon:\n\t\t\t*outIsSettable = false;\n\t\t\tbreak;\n\t\t\n\t\tcase kAudioDevicePropertyNominalSampleRate:\n\t\t\t*outIsSettable = true;\n\t\t\tbreak;\n\t\t\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_GetDevicePropertyDataSize(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* outDataSize)\n{\n\t//\tThis method returns the byte size of the property's data.\n\t\n\t#pragma unused(inClientProcessID, inQualifierDataSize, inQualifierData)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetDevicePropertyDataSize: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetDevicePropertyDataSize: no address\");\n\tFailWithAction(outDataSize == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetDevicePropertyDataSize: no place to put the return value\");\n\tFailWithAction(inObjectID != kObjectID_Device && inObjectID != kObjectID_Device2, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetDevicePropertyDataSize: not the device object\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetDevicePropertyData() method.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyClass:\n\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyOwner:\n\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyName:\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyManufacturer:\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyOwnedObjects:\n            *outDataSize = device_object_list_size(inAddress->mScope, inObjectID) * sizeof(AudioObjectID);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyDeviceUID:\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyModelUID:\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyTransportType:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyRelatedDevices:\n\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyClockDomain:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyDeviceIsAlive:\n\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyDeviceIsRunning:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyDeviceCanBeDefaultDevice:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyDeviceCanBeDefaultSystemDevice:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyLatency:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyStreams:\n            *outDataSize = device_stream_list_size(inAddress->mScope, inObjectID) * sizeof(AudioObjectID);\n\t\t\tbreak;\n\n\t\tcase kAudioObjectPropertyControlList:\n            *outDataSize = device_control_list_size(inAddress->mScope, inObjectID) * sizeof(AudioObjectID);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertySafetyOffset:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyNominalSampleRate:\n\t\t\t*outDataSize = sizeof(Float64);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyAvailableNominalSampleRates:\n\t\t\t*outDataSize = kDevice_SampleRatesSize * sizeof(AudioValueRange);\n\t\t\tbreak;\n\t\t\n\t\tcase kAudioDevicePropertyIsHidden:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyPreferredChannelsForStereo:\n\t\t\t*outDataSize = 2 * sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyPreferredChannelLayout:\n\t\t\t*outDataSize = offsetof(AudioChannelLayout, mChannelDescriptions) + (kNumber_Of_Channels * sizeof(AudioChannelDescription));\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyZeroTimeStampPeriod:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyIcon:\n\t\t\t*outDataSize = sizeof(CFURLRef);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_GetDevicePropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, UInt32* outDataSize, void* outData)\n{\n\t#pragma unused(inClientProcessID, inQualifierDataSize, inQualifierData)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\tUInt32 theNumberItemsToFetch;\n\tUInt32 theItemIndex;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetDevicePropertyData: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetDevicePropertyData: no address\");\n\tFailWithAction(outDataSize == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetDevicePropertyData: no place to put the return value size\");\n\tFailWithAction(outData == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetDevicePropertyData: no place to put the return value\");\n\tFailWithAction(inObjectID != kObjectID_Device && inObjectID != kObjectID_Device2, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetDevicePropertyData: not the device object\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required.\n\t//\n\t//\tAlso, since most of the data that will get returned is static, there are few instances where\n\t//\tit is necessary to lock the state mutex.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t//\tThe base class for kAudioDeviceClassID is kAudioObjectClassID\n\t\t\tFailWithAction(inDataSize < sizeof(AudioClassID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioObjectPropertyBaseClass for the device\");\n\t\t\t*((AudioClassID*)outData) = kAudioObjectClassID;\n\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyClass:\n\t\t\t//\tThe class is always kAudioDeviceClassID for devices created by drivers\n\t\t\tFailWithAction(inDataSize < sizeof(AudioClassID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioObjectPropertyClass for the device\");\n\t\t\t*((AudioClassID*)outData) = kAudioDeviceClassID;\n\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyOwner:\n\t\t\t//\tThe device's owner is the plug-in object\n\t\t\tFailWithAction(inDataSize < sizeof(AudioObjectID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioObjectPropertyOwner for the device\");\n\t\t\t*((AudioObjectID*)outData) = kObjectID_PlugIn;\n\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyName:\n\t\t\t//\tThis is the human readable name of the device.\n\t\t\tFailWithAction(inDataSize < sizeof(CFStringRef), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioObjectPropertyManufacturer for the device\");\n            \n            switch (inObjectID) {\n                case kObjectID_Device:\n                    *((CFStringRef*)outData) = get_device_name();\n                    *outDataSize = sizeof(CFStringRef);\n                    break;\n                    \n                case kObjectID_Device2:\n                    *((CFStringRef*)outData) = get_device2_name();\n                    *outDataSize = sizeof(CFStringRef);\n                    break;\n            }\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyManufacturer:\n\t\t\t//\tThis is the human readable name of the maker of the plug-in.\n\t\t\tFailWithAction(inDataSize < sizeof(CFStringRef), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioObjectPropertyManufacturer for the device\");\n\t\t\t*((CFStringRef*)outData) = CFSTR(kManufacturer_Name);\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t//\tCalculate the number of items that have been requested. Note that this\n\t\t\t//\tnumber is allowed to be smaller than the actual size of the list. In such\n\t\t\t//\tcase, only that number of items will be returned\n            theNumberItemsToFetch = minimum(inDataSize / sizeof(AudioObjectID), device_object_list_size(inAddress->mScope, inObjectID));\n\n            //    fill out the list with the right objects\n            switch (inObjectID) {\n                case kObjectID_Device:\n                    for (UInt32 i = 0, k = 0; k < theNumberItemsToFetch; i++)\n                    {\n                        if (kDevice_ObjectList[i].scope == inAddress->mScope || inAddress->mScope == kAudioObjectPropertyScopeGlobal)\n                        {\n                            ((AudioObjectID*)outData)[k++] = kDevice_ObjectList[i].id;\n                        }\n                    }\n                    break;\n\n                case kObjectID_Device2:\n                    for (UInt32 i = 0, k = 0; k < theNumberItemsToFetch; i++)\n                    {\n                        if (kDevice2_ObjectList[i].scope == inAddress->mScope || inAddress->mScope == kAudioObjectPropertyScopeGlobal)\n                        {\n                            ((AudioObjectID*)outData)[k++] = kDevice2_ObjectList[i].id;\n                        }\n                    }\n                    break;\n            }\n\n\t\t\t//\treport how much we wrote\n\t\t\t*outDataSize = theNumberItemsToFetch * sizeof(AudioObjectID);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyDeviceUID:\n\t\t\t//\tThis is a CFString that is a persistent token that can identify the same\n\t\t\t//\taudio device across boot sessions. Note that two instances of the same\n\t\t\t//\tdevice must have different values for this property.\n\t\t\tFailWithAction(inDataSize < sizeof(CFStringRef), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioDevicePropertyDeviceUID for the device\");\n\n            switch (inObjectID) {\n                case kObjectID_Device:\n                    *((CFStringRef*)outData) = get_device_uid();\n                    *outDataSize = sizeof(CFStringRef);\n                    break;\n                    \n                case kObjectID_Device2:\n                    *((CFStringRef*)outData) = get_device2_uid();\n                    *outDataSize = sizeof(CFStringRef);\n                    break;\n            }\n            \n\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyModelUID:\n\t\t\t//\tThis is a CFString that is a persistent token that can identify audio\n\t\t\t//\tdevices that are the same kind of device. Note that two instances of the\n\t\t\t//\tsave device must have the same value for this property.\n\t\t\tFailWithAction(inDataSize < sizeof(CFStringRef), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioDevicePropertyModelUID for the device\");\n\n            *((CFStringRef*)outData) = get_device_model_uid();\n\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyTransportType:\n\t\t\t//\tThis value represents how the device is attached to the system. This can be\n\t\t\t//\tany 32 bit integer, but common values for this property are defined in\n\t\t\t//\t<CoreAudio/AudioHardwareBase.h>\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioDevicePropertyTransportType for the device\");\n\t\t\t*((UInt32*)outData) = kAudioDeviceTransportTypeVirtual;\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyRelatedDevices:\n\t\t\t//\tThe related devices property identifys device objects that are very closely\n\t\t\t//\trelated. Generally, this is for relating devices that are packaged together\n\t\t\t//\tin the hardware such as when the input side and the output side of a piece\n\t\t\t//\tof hardware can be clocked separately and therefore need to be represented\n\t\t\t//\tas separate AudioDevice objects. In such case, both devices would report\n\t\t\t//\tthat they are related to each other. Note that at minimum, a device is\n\t\t\t//\trelated to itself, so this list will always be at least one item long.\n\n\t\t\t//\tCalculate the number of items that have been requested. Note that this\n\t\t\t//\tnumber is allowed to be smaller than the actual size of the list. In such\n\t\t\t//\tcase, only that number of items will be returned\n\t\t\ttheNumberItemsToFetch = inDataSize / sizeof(AudioObjectID);\n\t\t\t\n\t\t\t//\twe only have the one device...\n\t\t\tif(theNumberItemsToFetch > 1)\n\t\t\t{\n\t\t\t\ttheNumberItemsToFetch = 1;\n\t\t\t}\n\t\t\t\n\t\t\t//\tWrite the devices' object IDs into the return value\n\t\t\tif(theNumberItemsToFetch > 0)\n\t\t\t{\n                switch (inObjectID) {\n                    case kObjectID_Device:\n                        ((AudioObjectID*)outData)[0] = kObjectID_Device;\n                        break;\n                        \n                    case kObjectID_Device2:\n                        ((AudioObjectID*)outData)[0] = kObjectID_Device2;\n                        break;\n                }\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t\t//\treport how much we wrote\n\t\t\t*outDataSize = theNumberItemsToFetch * sizeof(AudioObjectID);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyClockDomain:\n\t\t\t//\tThis property allows the device to declare what other devices it is\n\t\t\t//\tsynchronized with in hardware. The way it works is that if two devices have\n\t\t\t//\tthe same value for this property and the value is not zero, then the two\n\t\t\t//\tdevices are synchronized in hardware. Note that a device that either can't\n\t\t\t//\tbe synchronized with others or doesn't know should return 0 for this\n\t\t\t//\tproperty.\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioDevicePropertyClockDomain for the device\");\n\t\t\t*((UInt32*)outData) = 0;\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyDeviceIsAlive:\n\t\t\t//\tThis property returns whether or not the device is alive. Note that it is\n\t\t\t//\tnot uncommon for a device to be dead but still momentarily available in the\n\t\t\t//\tdevice list. In the case of this device, it will always be alive.\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioDevicePropertyDeviceIsAlive for the device\");\n\t\t\t*((UInt32*)outData) = 1;\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n        case kAudioDevicePropertyDeviceIsRunning:\n            //    This property returns whether or not IO is running for the device. Note that\n            //    we need to take both the state lock to check this value for thread safety.\n            FailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioDevicePropertyDeviceIsRunning for the device\");\n            pthread_mutex_lock(&gPlugIn_StateMutex);\n            if (inObjectID == kObjectID_Device) {\n                *((UInt32*)outData) = ((gDevice_IOIsRunning > 0) > 0) ? 1 : 0;\n            }\n            \n            switch (inObjectID) {\n                case kObjectID_Device:\n                    *((UInt32*)outData) = ((gDevice_IOIsRunning > 0) > 0) ? 1 : 0;\n                    break;\n                case kObjectID_Device2:\n                    *((UInt32*)outData) = ((gDevice2_IOIsRunning > 0) > 0) ? 1 : 0;\n                    break;\n                default:\n                    *((UInt32*)outData) = 0;\n                    break;\n            }\n            \n            pthread_mutex_unlock(&gPlugIn_StateMutex);\n            *outDataSize = sizeof(UInt32);\n            break;\n\n\t\tcase kAudioDevicePropertyDeviceCanBeDefaultDevice:\n\t\t\t//\tThis property returns whether or not the device wants to be able to be the\n\t\t\t//\tdefault device for content. This is the device that iTunes and QuickTime\n\t\t\t//\twill use to play their content on and FaceTime will use as it's microhphone.\n\t\t\t//\tNearly all devices should allow for this.\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioDevicePropertyDeviceCanBeDefaultDevice for the device\");\n\t\t\t*((UInt32*)outData) = kCanBeDefaultDevice;\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyDeviceCanBeDefaultSystemDevice:\n\t\t\t//\tThis property returns whether or not the device wants to be the system\n\t\t\t//\tdefault device. This is the device that is used to play interface sounds and\n\t\t\t//\tother incidental or UI-related sounds on. Most devices should allow this\n\t\t\t//\talthough devices with lots of latency may not want to.\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioDevicePropertyDeviceCanBeDefaultSystemDevice for the device\");\n\t\t\t*((UInt32*)outData) = kCanBeDefaultSystemDevice;\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyLatency:\n\t\t\t//\tThis property returns the presentation latency of the device. For this,\n\t\t\t//\tdevice, the value is 0 due to the fact that it always vends silence.\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioDevicePropertyLatency for the device\");\n\t\t\t*((UInt32*)outData) = 0;\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyStreams:\n\t\t\t//\tCalculate the number of items that have been requested. Note that this\n\t\t\t//\tnumber is allowed to be smaller than the actual size of the list. In such\n\t\t\t//\tcase, only that number of items will be returned\n            theNumberItemsToFetch = minimum(inDataSize / sizeof(AudioObjectID), device_stream_list_size(inAddress->mScope, inObjectID));\n\n            //    fill out the list with as many objects as requested\n            switch (inObjectID) {\n                case kObjectID_Device:\n                    for (UInt32 i = 0, k = 0; k < theNumberItemsToFetch; i++)\n                    {\n                        if ((kDevice_ObjectList[i].type == kObjectType_Stream) &&\n                            (kDevice_ObjectList[i].scope == inAddress->mScope || inAddress->mScope == kAudioObjectPropertyScopeGlobal))\n                        {\n                            ((AudioObjectID*)outData)[k++] = kDevice_ObjectList[i].id;\n                        }\n                    }\n                    break;\n\n                case kObjectID_Device2:\n                    for (UInt32 i = 0, k = 0; k < theNumberItemsToFetch; i++)\n                    {\n                        if ((kDevice2_ObjectList[i].type == kObjectType_Stream) &&\n                            (kDevice2_ObjectList[i].scope == inAddress->mScope || inAddress->mScope == kAudioObjectPropertyScopeGlobal))\n                        {\n                            ((AudioObjectID*)outData)[k++] = kDevice2_ObjectList[i].id;\n                        }\n                    }\n                    break;\n            }\n\n\t\t\t//\treport how much we wrote\n\t\t\t*outDataSize = theNumberItemsToFetch * sizeof(AudioObjectID);\n\t\t\tbreak;\n\n\t\tcase kAudioObjectPropertyControlList:\n\t\t\t//\tCalculate the number of items that have been requested. Note that this\n\t\t\t//\tnumber is allowed to be smaller than the actual size of the list. In such\n\t\t\t//\tcase, only that number of items will be returned\n\n            theNumberItemsToFetch = minimum(inDataSize / sizeof(AudioObjectID), device_control_list_size(inAddress->mScope, inObjectID));\n\n            //    fill out the list with as many objects as requested\n            switch (inObjectID) {\n                case kObjectID_Device:\n                    pthread_mutex_lock(&gPlugIn_StateMutex);\n                    for (UInt32 i = 0, k = 0; k < theNumberItemsToFetch; i++)\n                    {\n                        // TODO remove hack! There must be a better way than looking for a fixed i\n                        if ((kDevice_ObjectList[i].type == kObjectType_Control) && !(!gPitch_Adjust_Enabled && kDevice_ObjectList[i].id==kObjectID_Pitch_Adjust))\n                        {\n                            ((AudioObjectID*)outData)[k++] = kDevice_ObjectList[i].id;\n                        }\n                    }\n                    pthread_mutex_unlock(&gPlugIn_StateMutex);\n                    break;\n\n                case kObjectID_Device2:\n                    for (UInt32 i = 0, k = 0; k < theNumberItemsToFetch; i++)\n                    {\n                        if ((kDevice_ObjectList[i].type == kObjectType_Control) && !(!gPitch_Adjust_Enabled && kDevice_ObjectList[i].id==kObjectID_Pitch_Adjust))\n                        {\n                            ((AudioObjectID*)outData)[k++] = kDevice2_ObjectList[i].id;\n                        }\n                    }\n                    break;\n            }\n\n\t\t\t//\treport how much we wrote\n\t\t\t*outDataSize = theNumberItemsToFetch * sizeof(AudioObjectID);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertySafetyOffset:\n\t\t\t//\tThis property returns the how close to now the HAL can read and write. For\n\t\t\t//\tthis, device, the value is 0 due to the fact that it always vends silence.\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioDevicePropertySafetyOffset for the device\");\n\t\t\t*((UInt32*)outData) = kLatency_Frame_Size;\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyNominalSampleRate:\n\t\t\t//\tThis property returns the nominal sample rate of the device. Note that we\n\t\t\t//\tonly need to take the state lock to get this value.\n\t\t\tFailWithAction(inDataSize < sizeof(Float64), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioDevicePropertyNominalSampleRate for the device\");\n\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\t\t*((Float64*)outData) = gDevice_SampleRate;\n\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\t*outDataSize = sizeof(Float64);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyAvailableNominalSampleRates:\n\t\t\t//\tThis returns all nominal sample rates the device supports as an array of\n\t\t\t//\tAudioValueRangeStructs. Note that for discrete sampler rates, the range\n\t\t\t//\twill have the minimum value equal to the maximum value.\n\t\t\t\n\t\t\t//\tCalculate the number of items that have been requested. Note that this\n\t\t\t//\tnumber is allowed to be smaller than the actual size of the list. In such\n\t\t\t//\tcase, only that number of items will be returned\n\t\t\ttheNumberItemsToFetch = inDataSize / sizeof(AudioValueRange);\n\t\t\t\n\t\t\t//\tclamp it to the number of items we have\n\t\t\tif(theNumberItemsToFetch > kDevice_SampleRatesSize)\n\t\t\t{\n\t\t\t\ttheNumberItemsToFetch = kDevice_SampleRatesSize;\n\t\t\t}\n\t\t\t\n            //\tfill out the return array\n            for(UInt32 i = 0; i < theNumberItemsToFetch; i++)\n            {\n                ((AudioValueRange*)outData)[i].mMinimum = kDevice_SampleRates[i];\n                ((AudioValueRange*)outData)[i].mMaximum = kDevice_SampleRates[i];\n            }\n\n\t\t\t//\treport how much we wrote\n\t\t\t*outDataSize = theNumberItemsToFetch * sizeof(AudioValueRange);\n\t\t\tbreak;\n\t\t\n\t\tcase kAudioDevicePropertyIsHidden:\n\t\t\t//\tThis returns whether or not the device is visible to clients.\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioDevicePropertyIsHidden for the device\");\n            \n            switch (inObjectID) {\n                case kObjectID_Device:\n                    *((UInt32*)outData) = kDevice_IsHidden;\n                    break;\n                \n                case kObjectID_Device2:\n                    *((UInt32*)outData) = kDevice2_IsHidden;\n                    break;\n            }\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyPreferredChannelsForStereo:\n\t\t\t//\tThis property returns which two channels to use as left/right for stereo\n\t\t\t//\tdata by default. Note that the channel numbers are 1-based.xz\n\t\t\tFailWithAction(inDataSize < (2 * sizeof(UInt32)), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioDevicePropertyPreferredChannelsForStereo for the device\");\n\t\t\t((UInt32*)outData)[0] = 1;\n\t\t\t((UInt32*)outData)[1] = 2;\n\t\t\t*outDataSize = 2 * sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyPreferredChannelLayout:\n\t\t\t//\tThis property returns the default AudioChannelLayout to use for the device\n\t\t\t//\tby default. For this device, we return a stereo ACL.\n\t\t\t{\n\t\t\t\t//\tcalculate how big the\n\t\t\t\tUInt32 theACLSize = offsetof(AudioChannelLayout, mChannelDescriptions) + (kNumber_Of_Channels * sizeof(AudioChannelDescription));\n\t\t\t\tFailWithAction(inDataSize < theACLSize, theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioDevicePropertyPreferredChannelLayout for the device\");\n\t\t\t\t((AudioChannelLayout*)outData)->mChannelLayoutTag = kAudioChannelLayoutTag_UseChannelDescriptions;\n\t\t\t\t((AudioChannelLayout*)outData)->mChannelBitmap = 0;\n\t\t\t\t((AudioChannelLayout*)outData)->mNumberChannelDescriptions = kNumber_Of_Channels;\n\t\t\t\tfor(theItemIndex = 0; theItemIndex < kNumber_Of_Channels; ++theItemIndex)\n\t\t\t\t{\n\t\t\t\t\t((AudioChannelLayout*)outData)->mChannelDescriptions[theItemIndex].mChannelLabel = kAudioChannelLabel_Left + theItemIndex;\n\t\t\t\t\t((AudioChannelLayout*)outData)->mChannelDescriptions[theItemIndex].mChannelFlags = 0;\n\t\t\t\t\t((AudioChannelLayout*)outData)->mChannelDescriptions[theItemIndex].mCoordinates[0] = 0;\n\t\t\t\t\t((AudioChannelLayout*)outData)->mChannelDescriptions[theItemIndex].mCoordinates[1] = 0;\n\t\t\t\t\t((AudioChannelLayout*)outData)->mChannelDescriptions[theItemIndex].mCoordinates[2] = 0;\n\t\t\t\t}\n\t\t\t\t*outDataSize = theACLSize;\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyZeroTimeStampPeriod:\n\t\t\t//\tThis property returns how many frames the HAL should expect to see between\n\t\t\t//\tsuccessive sample times in the zero time stamps this device provides.\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioDevicePropertyZeroTimeStampPeriod for the device\");\n\t\t\t*((UInt32*)outData) = kDevice_RingBufferSize;\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioDevicePropertyIcon:\n\t\t\t{\n\t\t\t\t//\tThis is a CFURL that points to the device's Icon in the plug-in's resource bundle.\n\t\t\t\tFailWithAction(inDataSize < sizeof(CFURLRef), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetDevicePropertyData: not enough space for the return value of kAudioDevicePropertyDeviceUID for the device\");\n\t\t\t\tCFBundleRef theBundle = CFBundleGetBundleWithIdentifier(CFSTR(kPlugIn_BundleID));\n\t\t\t\tFailWithAction(theBundle == NULL, theAnswer = kAudioHardwareUnspecifiedError, Done, \"BlackHole_GetDevicePropertyData: could not get the plug-in bundle for kAudioDevicePropertyIcon\");\n\t\t\t\tCFURLRef theURL = CFBundleCopyResourceURL(theBundle, CFSTR(kPlugIn_Icon), NULL, NULL);\n\t\t\t\tFailWithAction(theURL == NULL, theAnswer = kAudioHardwareUnspecifiedError, Done, \"BlackHole_GetDevicePropertyData: could not get the URL for kAudioDevicePropertyIcon\");\n\t\t\t\t*((CFURLRef*)outData) = theURL;\n\t\t\t\t*outDataSize = sizeof(CFURLRef);\n\t\t\t}\n\t\t\tbreak;\n\t\t\t\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_SetDevicePropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, const void* inData, UInt32* outNumberPropertiesChanged, AudioObjectPropertyAddress outChangedAddresses[2])\n{\n\t#pragma unused(inClientProcessID, inQualifierDataSize, inQualifierData)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\tFloat64 theOldSampleRate;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_SetDevicePropertyData: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_SetDevicePropertyData: no address\");\n\tFailWithAction(outNumberPropertiesChanged == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_SetDevicePropertyData: no place to return the number of properties that changed\");\n\tFailWithAction(outChangedAddresses == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_SetDevicePropertyData: no place to return the properties that changed\");\n\tFailWithAction(inObjectID != kObjectID_Device && inObjectID != kObjectID_Device2, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_SetDevicePropertyData: not the device object\");\n\t\n\t//\tinitialize the returned number of changed properties\n\t*outNumberPropertiesChanged = 0;\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetDevicePropertyData() method.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tcase kAudioDevicePropertyNominalSampleRate:\n\t\t\t//\tChanging the sample rate needs to be handled via the\n\t\t\t//\tRequestConfigChange/PerformConfigChange machinery.\n\n\t\t\t//\tcheck the arguments\n\t\t\tFailWithAction(inDataSize != sizeof(Float64), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_SetDevicePropertyData: wrong size for the data for kAudioDevicePropertyNominalSampleRate\");\n\t\t\tFailWithAction(!is_valid_sample_rate(*(const Float64*)inData), theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_SetDevicePropertyData: unsupported value for kAudioDevicePropertyNominalSampleRate\");\n\t\t\t\n\t\t\t//\tmake sure that the new value is different than the old value\n\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\t\ttheOldSampleRate = gDevice_SampleRate;\n\t\t\tgDevice_RequestedSampleRate = *((const Float64*)inData);\n\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\tif(*((const Float64*)inData) != theOldSampleRate)\n\t\t\t{\n\t\t\t\t//\twe dispatch this so that the change can happen asynchronously\n\t\t\t\tdispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ gPlugIn_Host->RequestDeviceConfigurationChange(gPlugIn_Host, kObjectID_Device, ChangeAction_SetSampleRate, NULL); });\n\t\t\t}\n\t\t\tbreak;\n\t\t\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\n#pragma mark Stream Property Operations\n\nstatic Boolean\tBlackHole_HasStreamProperty(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress)\n{\n\t//\tThis method returns whether or not the given object has the given property.\n\t\n\t#pragma unused(inClientProcessID)\n\t\n\t//\tdeclare the local variables\n\tBoolean theAnswer = false;\n\t\n\t//\tcheck the arguments\n\tFailIf(inDriver != gAudioServerPlugInDriverRef, Done, \"BlackHole_HasStreamProperty: bad driver reference\");\n\tFailIf(inAddress == NULL, Done, \"BlackHole_HasStreamProperty: no address\");\n\tFailIf((inObjectID != kObjectID_Stream_Input) && (inObjectID != kObjectID_Stream_Output), Done, \"BlackHole_HasStreamProperty: not a stream object\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetStreamPropertyData() method.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tcase kAudioObjectPropertyBaseClass:\n\t\tcase kAudioObjectPropertyClass:\n\t\tcase kAudioObjectPropertyOwner:\n\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\tcase kAudioStreamPropertyIsActive:\n\t\tcase kAudioStreamPropertyDirection:\n\t\tcase kAudioStreamPropertyTerminalType:\n\t\tcase kAudioStreamPropertyStartingChannel:\n\t\tcase kAudioStreamPropertyLatency:\n\t\tcase kAudioStreamPropertyVirtualFormat:\n\t\tcase kAudioStreamPropertyPhysicalFormat:\n\t\tcase kAudioStreamPropertyAvailableVirtualFormats:\n\t\tcase kAudioStreamPropertyAvailablePhysicalFormats:\n\t\t\ttheAnswer = true;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_IsStreamPropertySettable(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, Boolean* outIsSettable)\n{\n\t//\tThis method returns whether or not the given property on the object can have its value\n\t//\tchanged.\n\t\n\t#pragma unused(inClientProcessID)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_IsStreamPropertySettable: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_IsStreamPropertySettable: no address\");\n\tFailWithAction(outIsSettable == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_IsStreamPropertySettable: no place to put the return value\");\n\tFailWithAction((inObjectID != kObjectID_Stream_Input) && (inObjectID != kObjectID_Stream_Output), theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_IsStreamPropertySettable: not a stream object\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetStreamPropertyData() method.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tcase kAudioObjectPropertyBaseClass:\n\t\tcase kAudioObjectPropertyClass:\n\t\tcase kAudioObjectPropertyOwner:\n\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\tcase kAudioStreamPropertyDirection:\n\t\tcase kAudioStreamPropertyTerminalType:\n\t\tcase kAudioStreamPropertyStartingChannel:\n\t\tcase kAudioStreamPropertyLatency:\n\t\tcase kAudioStreamPropertyAvailableVirtualFormats:\n\t\tcase kAudioStreamPropertyAvailablePhysicalFormats:\n\t\t\t*outIsSettable = false;\n\t\t\tbreak;\n\t\t\n\t\tcase kAudioStreamPropertyIsActive:\n\t\tcase kAudioStreamPropertyVirtualFormat:\n\t\tcase kAudioStreamPropertyPhysicalFormat:\n\t\t\t*outIsSettable = true;\n\t\t\tbreak;\n\t\t\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_GetStreamPropertyDataSize(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* outDataSize)\n{\n\t//\tThis method returns the byte size of the property's data.\n\t\n\t#pragma unused(inClientProcessID, inQualifierDataSize, inQualifierData)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetStreamPropertyDataSize: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetStreamPropertyDataSize: no address\");\n\tFailWithAction(outDataSize == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetStreamPropertyDataSize: no place to put the return value\");\n\tFailWithAction((inObjectID != kObjectID_Stream_Input) && (inObjectID != kObjectID_Stream_Output), theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetStreamPropertyDataSize: not a stream object\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetStreamPropertyData() method.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\tbreak;\n\n\t\tcase kAudioObjectPropertyClass:\n\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\tbreak;\n\n\t\tcase kAudioObjectPropertyOwner:\n\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\tbreak;\n\n\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t*outDataSize = 0 * sizeof(AudioObjectID);\n\t\t\tbreak;\n\n\t\tcase kAudioStreamPropertyIsActive:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioStreamPropertyDirection:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioStreamPropertyTerminalType:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioStreamPropertyStartingChannel:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\t\t\n\t\tcase kAudioStreamPropertyLatency:\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioStreamPropertyVirtualFormat:\n\t\tcase kAudioStreamPropertyPhysicalFormat:\n\t\t\t*outDataSize = sizeof(AudioStreamBasicDescription);\n\t\t\tbreak;\n\n\t\tcase kAudioStreamPropertyAvailableVirtualFormats:\n\t\tcase kAudioStreamPropertyAvailablePhysicalFormats:\n\t\t\t*outDataSize = kDevice_SampleRatesSize * sizeof(AudioStreamRangedDescription);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_GetStreamPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, UInt32* outDataSize, void* outData)\n{\n\t#pragma unused(inClientProcessID, inQualifierDataSize, inQualifierData)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\tUInt32 theNumberItemsToFetch;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetStreamPropertyData: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetStreamPropertyData: no address\");\n\tFailWithAction(outDataSize == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetStreamPropertyData: no place to put the return value size\");\n\tFailWithAction(outData == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetStreamPropertyData: no place to put the return value\");\n\tFailWithAction((inObjectID != kObjectID_Stream_Input) && (inObjectID != kObjectID_Stream_Output), theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetStreamPropertyData: not a stream object\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required.\n\t//\n\t//\tAlso, since most of the data that will get returned is static, there are few instances where\n\t//\tit is necessary to lock the state mutex.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t//\tThe base class for kAudioStreamClassID is kAudioObjectClassID\n\t\t\tFailWithAction(inDataSize < sizeof(AudioClassID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetStreamPropertyData: not enough space for the return value of kAudioObjectPropertyBaseClass for the stream\");\n\t\t\t*((AudioClassID*)outData) = kAudioObjectClassID;\n\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyClass:\n\t\t\t//\tThe class is always kAudioStreamClassID for streams created by drivers\n\t\t\tFailWithAction(inDataSize < sizeof(AudioClassID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetStreamPropertyData: not enough space for the return value of kAudioObjectPropertyClass for the stream\");\n\t\t\t*((AudioClassID*)outData) = kAudioStreamClassID;\n\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyOwner:\n\t\t\t//\tThe stream's owner is the device object\n\t\t\tFailWithAction(inDataSize < sizeof(AudioObjectID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetStreamPropertyData: not enough space for the return value of kAudioObjectPropertyOwner for the stream\");\n\t\t\t*((AudioObjectID*)outData) = kObjectID_Device;\n\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t//\tStreams do not own any objects\n\t\t\t*outDataSize = 0 * sizeof(AudioObjectID);\n\t\t\tbreak;\n\n\t\tcase kAudioStreamPropertyIsActive:\n\t\t\t//\tThis property tells the device whether or not the given stream is going to\n\t\t\t//\tbe used for IO. Note that we need to take the state lock to examine this\n\t\t\t//\tvalue.\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetStreamPropertyData: not enough space for the return value of kAudioStreamPropertyIsActive for the stream\");\n\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\t\t*((UInt32*)outData) = (inObjectID == kObjectID_Stream_Input) ? gStream_Input_IsActive : gStream_Output_IsActive;\n\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioStreamPropertyDirection:\n\t\t\t//\tThis returns whether the stream is an input stream or an output stream.\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetStreamPropertyData: not enough space for the return value of kAudioStreamPropertyDirection for the stream\");\n\t\t\t*((UInt32*)outData) = (inObjectID == kObjectID_Stream_Input) ? 1 : 0;\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioStreamPropertyTerminalType:\n\t\t\t//\tThis returns a value that indicates what is at the other end of the stream\n\t\t\t//\tsuch as a speaker or headphones, or a microphone. Values for this property\n\t\t\t//\tare defined in <CoreAudio/AudioHardwareBase.h>\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetStreamPropertyData: not enough space for the return value of kAudioStreamPropertyTerminalType for the stream\");\n\t\t\t*((UInt32*)outData) = (inObjectID == kObjectID_Stream_Input) ? kAudioStreamTerminalTypeMicrophone : kAudioStreamTerminalTypeSpeaker;\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioStreamPropertyStartingChannel:\n\t\t\t//\tThis property returns the absolute channel number for the first channel in\n\t\t\t//\tthe stream. For example, if a device has two output streams with two\n\t\t\t//\tchannels each, then the starting channel number for the first stream is 1\n\t\t\t//\tand the starting channel number fo the second stream is 3.\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetStreamPropertyData: not enough space for the return value of kAudioStreamPropertyStartingChannel for the stream\");\n\t\t\t*((UInt32*)outData) = 1;\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioStreamPropertyLatency:\n\t\t\t//\tThis property returns any additional presentation latency the stream has.\n\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetStreamPropertyData: not enough space for the return value of kAudioStreamPropertyStartingChannel for the stream\");\n\t\t\t*((UInt32*)outData) = kLatency_Frame_Size;\n\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\tbreak;\n\n\t\tcase kAudioStreamPropertyVirtualFormat:\n\t\tcase kAudioStreamPropertyPhysicalFormat:\n\t\t\t//\tThis returns the current format of the stream in an\n\t\t\t//\tAudioStreamBasicDescription. Note that we need to hold the state lock to get\n\t\t\t//\tthis value.\n\t\t\t//\tNote that for devices that don't override the mix operation, the virtual\n\t\t\t//\tformat has to be the same as the physical format.\n\t\t\tFailWithAction(inDataSize < sizeof(AudioStreamBasicDescription), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetStreamPropertyData: not enough space for the return value of kAudioStreamPropertyVirtualFormat for the stream\");\n\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n            ((AudioStreamBasicDescription*)outData)->mSampleRate = gDevice_SampleRate;\n            ((AudioStreamBasicDescription*)outData)->mFormatID = kAudioFormatLinearPCM;\n            ((AudioStreamBasicDescription*)outData)->mFormatFlags = kAudioFormatFlagIsFloat | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked;\n            ((AudioStreamBasicDescription*)outData)->mBytesPerPacket = kBytes_Per_Channel * kNumber_Of_Channels;\n            ((AudioStreamBasicDescription*)outData)->mFramesPerPacket = 1;\n            ((AudioStreamBasicDescription*)outData)->mBytesPerFrame = kBytes_Per_Channel * kNumber_Of_Channels;\n            ((AudioStreamBasicDescription*)outData)->mChannelsPerFrame = kNumber_Of_Channels;\n            ((AudioStreamBasicDescription*)outData)->mBitsPerChannel = kBits_Per_Channel;\n\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\t*outDataSize = sizeof(AudioStreamBasicDescription);\n\t\t\tbreak;\n\n\t\tcase kAudioStreamPropertyAvailableVirtualFormats:\n\t\tcase kAudioStreamPropertyAvailablePhysicalFormats:\n\t\t\t//\tThis returns an array of AudioStreamRangedDescriptions that describe what\n\t\t\t//\tformats are supported.\n\n\t\t\t//\tCalculate the number of items that have been requested. Note that this\n\t\t\t//\tnumber is allowed to be smaller than the actual size of the list. In such\n\t\t\t//\tcase, only that number of items will be returned\n\t\t\ttheNumberItemsToFetch = inDataSize / sizeof(AudioStreamRangedDescription);\n\t\t\t\n\t\t\t//\tclamp it to the number of items we have\n\t\t\tif(theNumberItemsToFetch > kDevice_SampleRatesSize)\n\t\t\t{\n\t\t\t\ttheNumberItemsToFetch = kDevice_SampleRatesSize;\n\t\t\t}\n\n            //\tfill out the return array\n            for(UInt32 i = 0; i < theNumberItemsToFetch; i++)\n            {\n                ((AudioStreamRangedDescription*)outData)[i].mFormat.mSampleRate = kDevice_SampleRates[i];\n                ((AudioStreamRangedDescription*)outData)[i].mFormat.mFormatID = kAudioFormatLinearPCM;\n                ((AudioStreamRangedDescription*)outData)[i].mFormat.mFormatFlags = kAudioFormatFlagIsFloat | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked;\n                ((AudioStreamRangedDescription*)outData)[i].mFormat.mBytesPerPacket = kBytes_Per_Frame;\n                ((AudioStreamRangedDescription*)outData)[i].mFormat.mFramesPerPacket = 1;\n                ((AudioStreamRangedDescription*)outData)[i].mFormat.mBytesPerFrame = kBytes_Per_Frame;\n                ((AudioStreamRangedDescription*)outData)[i].mFormat.mChannelsPerFrame = kNumber_Of_Channels;\n                ((AudioStreamRangedDescription*)outData)[i].mFormat.mBitsPerChannel = kBits_Per_Channel;\n                ((AudioStreamRangedDescription*)outData)[i].mSampleRateRange.mMinimum = kDevice_SampleRates[i];\n                ((AudioStreamRangedDescription*)outData)[i].mSampleRateRange.mMaximum = kDevice_SampleRates[i];\n            }\n\n\t\t\t//\treport how much we wrote\n\t\t\t*outDataSize = theNumberItemsToFetch * sizeof(AudioStreamRangedDescription);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_SetStreamPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, const void* inData, UInt32* outNumberPropertiesChanged, AudioObjectPropertyAddress outChangedAddresses[2])\n{\n\t#pragma unused(inClientProcessID, inQualifierDataSize, inQualifierData)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\tFloat64 theOldSampleRate;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_SetStreamPropertyData: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_SetStreamPropertyData: no address\");\n\tFailWithAction(outNumberPropertiesChanged == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_SetStreamPropertyData: no place to return the number of properties that changed\");\n\tFailWithAction(outChangedAddresses == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_SetStreamPropertyData: no place to return the properties that changed\");\n\tFailWithAction((inObjectID != kObjectID_Stream_Input) && (inObjectID != kObjectID_Stream_Output), theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_SetStreamPropertyData: not a stream object\");\n\t\n\t//\tinitialize the returned number of changed properties\n\t*outNumberPropertiesChanged = 0;\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetStreamPropertyData() method.\n\tswitch(inAddress->mSelector)\n\t{\n\t\tcase kAudioStreamPropertyIsActive:\n\t\t\t//\tChanging the active state of a stream doesn't affect IO or change the structure\n\t\t\t//\tso we can just save the state and send the notification.\n\t\t\tFailWithAction(inDataSize != sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_SetStreamPropertyData: wrong size for the data for kAudioDevicePropertyNominalSampleRate\");\n\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\t\tif(inObjectID == kObjectID_Stream_Input)\n\t\t\t{\n\t\t\t\tif(gStream_Input_IsActive != (*((const UInt32*)inData) != 0))\n\t\t\t\t{\n\t\t\t\t\tgStream_Input_IsActive = *((const UInt32*)inData) != 0;\n\t\t\t\t\t*outNumberPropertiesChanged = 1;\n\t\t\t\t\toutChangedAddresses[0].mSelector = kAudioStreamPropertyIsActive;\n\t\t\t\t\toutChangedAddresses[0].mScope = kAudioObjectPropertyScopeGlobal;\n\t\t\t\t\toutChangedAddresses[0].mElement = kAudioObjectPropertyElementMain;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(gStream_Output_IsActive != (*((const UInt32*)inData) != 0))\n\t\t\t\t{\n\t\t\t\t\tgStream_Output_IsActive = *((const UInt32*)inData) != 0;\n\t\t\t\t\t*outNumberPropertiesChanged = 1;\n\t\t\t\t\toutChangedAddresses[0].mSelector = kAudioStreamPropertyIsActive;\n\t\t\t\t\toutChangedAddresses[0].mScope = kAudioObjectPropertyScopeGlobal;\n\t\t\t\t\toutChangedAddresses[0].mElement = kAudioObjectPropertyElementMain;\n\t\t\t\t}\n\t\t\t}\n\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioStreamPropertyVirtualFormat:\n\t\tcase kAudioStreamPropertyPhysicalFormat:\n\t\t\t//\tChanging the stream format needs to be handled via the\n\t\t\t//\tRequestConfigChange/PerformConfigChange machinery. Note that because this\n\t\t\t//\tdevice only supports 2 channel 32 bit float data, the only thing that can\n\t\t\t//\tchange is the sample rate.\n\t\t\tFailWithAction(inDataSize != sizeof(AudioStreamBasicDescription), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_SetStreamPropertyData: wrong size for the data for kAudioStreamPropertyPhysicalFormat\");\n\t\t\tFailWithAction(((const AudioStreamBasicDescription*)inData)->mFormatID != kAudioFormatLinearPCM, theAnswer = kAudioDeviceUnsupportedFormatError, Done, \"BlackHole_SetStreamPropertyData: unsupported format ID for kAudioStreamPropertyPhysicalFormat\");\n\t\t\tFailWithAction(((const AudioStreamBasicDescription*)inData)->mFormatFlags != (kAudioFormatFlagIsFloat | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked), theAnswer = kAudioDeviceUnsupportedFormatError, Done, \"BlackHole_SetStreamPropertyData: unsupported format flags for kAudioStreamPropertyPhysicalFormat\");\n\t\t\tFailWithAction(((const AudioStreamBasicDescription*)inData)->mBytesPerPacket != kBytes_Per_Frame, theAnswer = kAudioDeviceUnsupportedFormatError, Done, \"BlackHole_SetStreamPropertyData: unsupported bytes per packet for kAudioStreamPropertyPhysicalFormat\");\n\t\t\tFailWithAction(((const AudioStreamBasicDescription*)inData)->mFramesPerPacket != 1, theAnswer = kAudioDeviceUnsupportedFormatError, Done, \"BlackHole_SetStreamPropertyData: unsupported frames per packet for kAudioStreamPropertyPhysicalFormat\");\n\t\t\tFailWithAction(((const AudioStreamBasicDescription*)inData)->mBytesPerFrame != kBytes_Per_Frame, theAnswer = kAudioDeviceUnsupportedFormatError, Done, \"BlackHole_SetStreamPropertyData: unsupported bytes per frame for kAudioStreamPropertyPhysicalFormat\");\n\t\t\tFailWithAction(((const AudioStreamBasicDescription*)inData)->mChannelsPerFrame != kNumber_Of_Channels, theAnswer = kAudioDeviceUnsupportedFormatError, Done, \"BlackHole_SetStreamPropertyData: unsupported channels per frame for kAudioStreamPropertyPhysicalFormat\");\n\t\t\tFailWithAction(((const AudioStreamBasicDescription*)inData)->mBitsPerChannel != kBits_Per_Channel, theAnswer = kAudioDeviceUnsupportedFormatError, Done, \"BlackHole_SetStreamPropertyData: unsupported bits per channel for kAudioStreamPropertyPhysicalFormat\");\n\t\t\tFailWithAction(!is_valid_sample_rate(((const AudioStreamBasicDescription*)inData)->mSampleRate), theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_SetStreamPropertyData: unsupported sample rate for kAudioStreamPropertyPhysicalFormat\");\n\t\t\t\n\t\t\t//\tIf we made it this far, the requested format is something we support, so make sure the sample rate is actually different\n\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\t\ttheOldSampleRate = gDevice_SampleRate;\n\t\t\tgDevice_RequestedSampleRate = ((const AudioStreamBasicDescription*)inData)->mSampleRate;\n\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\tif(((const AudioStreamBasicDescription*)inData)->mSampleRate != theOldSampleRate)\n\t\t\t{\n\t\t\t\t//\twe dispatch this so that the change can happen asynchronously\n\t\t\t\tdispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ gPlugIn_Host->RequestDeviceConfigurationChange(gPlugIn_Host, kObjectID_Device, ChangeAction_SetSampleRate, NULL); });\n\t\t\t}\n\t\t\tbreak;\n\t\t\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\n#pragma mark Control Property Operations\n\nstatic Boolean\tBlackHole_HasControlProperty(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress)\n{\n\t//\tThis method returns whether or not the given object has the given property.\n\t\n\t#pragma unused(inClientProcessID)\n\t\n\t//\tdeclare the local variables\n\tBoolean theAnswer = false;\n\t\n\t//\tcheck the arguments\n\tFailIf(inDriver != gAudioServerPlugInDriverRef, Done, \"BlackHole_HasControlProperty: bad driver reference\");\n\tFailIf(inAddress == NULL, Done, \"BlackHole_HasControlProperty: no address\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetControlPropertyData() method.\n\tswitch(inObjectID)\n\t{\n\t\tcase kObjectID_Volume_Input_Master:\n\t\tcase kObjectID_Volume_Output_Master:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t\tcase kAudioObjectPropertyClass:\n\t\t\t\tcase kAudioObjectPropertyOwner:\n\t\t\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t\tcase kAudioControlPropertyScope:\n\t\t\t\tcase kAudioControlPropertyElement:\n\t\t\t\tcase kAudioLevelControlPropertyScalarValue:\n\t\t\t\tcase kAudioLevelControlPropertyDecibelValue:\n\t\t\t\tcase kAudioLevelControlPropertyDecibelRange:\n\t\t\t\tcase kAudioLevelControlPropertyConvertScalarToDecibels:\n\t\t\t\tcase kAudioLevelControlPropertyConvertDecibelsToScalar:\n\t\t\t\t\ttheAnswer = true;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Mute_Input_Master:\n\t\tcase kObjectID_Mute_Output_Master:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t\tcase kAudioObjectPropertyClass:\n\t\t\t\tcase kAudioObjectPropertyOwner:\n\t\t\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t\tcase kAudioControlPropertyScope:\n\t\t\t\tcase kAudioControlPropertyElement:\n\t\t\t\tcase kAudioBooleanControlPropertyValue:\n\t\t\t\t\ttheAnswer = true;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\n\t\tcase kObjectID_Pitch_Adjust:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t\tcase kAudioObjectPropertyClass:\n\t\t\t\tcase kAudioObjectPropertyOwner:\n\t\t\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t\tcase kAudioControlPropertyScope:\n\t\t\t\tcase kAudioControlPropertyElement:\n\t\t\t\tcase kAudioStereoPanControlPropertyValue:\n\t\t\t\t\ttheAnswer = true;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\t\t\t\n\t\tcase kObjectID_ClockSource:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t\tcase kAudioObjectPropertyClass:\n\t\t\t\tcase kAudioObjectPropertyOwner:\n\t\t\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t\tcase kAudioControlPropertyScope:\n\t\t\t\tcase kAudioControlPropertyElement:\n\t\t\t\tcase kAudioSelectorControlPropertyCurrentItem:\n\t\t\t\tcase kAudioSelectorControlPropertyAvailableItems:\n\t\t\t\tcase kAudioSelectorControlPropertyItemName:\n\t\t\t\t\ttheAnswer = true;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_IsControlPropertySettable(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, Boolean* outIsSettable)\n{\n\t//\tThis method returns whether or not the given property on the object can have its value\n\t//\tchanged.\n\t\n\t#pragma unused(inClientProcessID)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_IsControlPropertySettable: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_IsControlPropertySettable: no address\");\n\tFailWithAction(outIsSettable == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_IsControlPropertySettable: no place to put the return value\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetControlPropertyData() method.\n\tswitch(inObjectID)\n\t{\n\t\tcase kObjectID_Volume_Input_Master:\n\t\tcase kObjectID_Volume_Output_Master:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t\tcase kAudioObjectPropertyClass:\n\t\t\t\tcase kAudioObjectPropertyOwner:\n\t\t\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t\tcase kAudioControlPropertyScope:\n\t\t\t\tcase kAudioControlPropertyElement:\n\t\t\t\tcase kAudioLevelControlPropertyDecibelRange:\n\t\t\t\tcase kAudioLevelControlPropertyConvertScalarToDecibels:\n\t\t\t\tcase kAudioLevelControlPropertyConvertDecibelsToScalar:\n\t\t\t\t\t*outIsSettable = false;\n\t\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\tcase kAudioLevelControlPropertyScalarValue:\n\t\t\t\tcase kAudioLevelControlPropertyDecibelValue:\n\t\t\t\t\t*outIsSettable = true;\n\t\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\tdefault:\n\t\t\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Mute_Input_Master:\n\t\tcase kObjectID_Mute_Output_Master:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t\tcase kAudioObjectPropertyClass:\n\t\t\t\tcase kAudioObjectPropertyOwner:\n\t\t\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t\tcase kAudioControlPropertyScope:\n\t\t\t\tcase kAudioControlPropertyElement:\n\t\t\t\t\t*outIsSettable = false;\n\t\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\tcase kAudioBooleanControlPropertyValue:\n\t\t\t\t\t*outIsSettable = true;\n\t\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\tdefault:\n\t\t\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\n\t\tcase kObjectID_Pitch_Adjust:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t\tcase kAudioObjectPropertyClass:\n\t\t\t\tcase kAudioObjectPropertyOwner:\n\t\t\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t\tcase kAudioControlPropertyScope:\n\t\t\t\tcase kAudioControlPropertyElement:\n\t\t\t\t\t*outIsSettable = false;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioStereoPanControlPropertyValue:\n\t\t\t\t\t*outIsSettable = true;\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\t\tcase kObjectID_ClockSource:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t\tcase kAudioObjectPropertyClass:\n\t\t\t\tcase kAudioObjectPropertyOwner:\n\t\t\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t\tcase kAudioControlPropertyScope:\n\t\t\t\tcase kAudioControlPropertyElement:\n\t\t\t\t\t*outIsSettable = false;\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase kAudioSelectorControlPropertyCurrentItem:\n\t\t\t\t\t*outIsSettable = true;\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tdefault:\n\t\t\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareBadObjectError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_GetControlPropertyDataSize(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* outDataSize)\n{\n\t//\tThis method returns the byte size of the property's data.\n\t\n\t#pragma unused(inClientProcessID, inQualifierDataSize, inQualifierData)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetControlPropertyDataSize: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetControlPropertyDataSize: no address\");\n\tFailWithAction(outDataSize == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetControlPropertyDataSize: no place to put the return value\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetControlPropertyData() method.\n\tswitch(inObjectID)\n\t{\n\t\tcase kObjectID_Volume_Input_Master:\n\t\tcase kObjectID_Volume_Output_Master:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioObjectPropertyClass:\n\t\t\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioObjectPropertyOwner:\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t\t\t*outDataSize = 0 * sizeof(AudioObjectID);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioControlPropertyScope:\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectPropertyScope);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioControlPropertyElement:\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectPropertyElement);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioLevelControlPropertyScalarValue:\n\t\t\t\t\t*outDataSize = sizeof(Float32);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioLevelControlPropertyDecibelValue:\n\t\t\t\t\t*outDataSize = sizeof(Float32);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioLevelControlPropertyDecibelRange:\n\t\t\t\t\t*outDataSize = sizeof(AudioValueRange);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioLevelControlPropertyConvertScalarToDecibels:\n\t\t\t\t\t*outDataSize = sizeof(Float32);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioLevelControlPropertyConvertDecibelsToScalar:\n\t\t\t\t\t*outDataSize = sizeof(Float32);\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Mute_Input_Master:\n\t\tcase kObjectID_Mute_Output_Master:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioObjectPropertyClass:\n\t\t\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioObjectPropertyOwner:\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t\t\t*outDataSize = 0 * sizeof(AudioObjectID);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioControlPropertyScope:\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectPropertyScope);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioControlPropertyElement:\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectPropertyElement);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioBooleanControlPropertyValue:\n\t\t\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\t\t\t\n\t\tcase kObjectID_Pitch_Adjust:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioObjectPropertyClass:\n\t\t\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioObjectPropertyOwner:\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t\t\t*outDataSize = 0 * sizeof(AudioObjectID);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioControlPropertyScope:\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectPropertyScope);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioControlPropertyElement:\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectPropertyElement);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioStereoPanControlPropertyValue:\n\t\t\t\t\t*outDataSize = sizeof(Float32);\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\t\t\t\n\t\tcase kObjectID_ClockSource:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\t\t\tbreak;\n\t\t\t\tcase kAudioObjectPropertyClass:\n\t\t\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\t\t\tbreak;\n\t\t\t\tcase kAudioObjectPropertyOwner:\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\t\t\tbreak;\n\t\t\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t\t\t*outDataSize = 0 * sizeof(AudioObjectID);\n\t\t\t\t\tbreak;\n\t\t\t\tcase kAudioControlPropertyScope:\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectPropertyScope);\n\t\t\t\t\tbreak;\n\t\t\t\tcase kAudioControlPropertyElement:\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectPropertyElement);\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase kAudioSelectorControlPropertyCurrentItem:\n\t\t\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase kAudioSelectorControlPropertyAvailableItems:\n\t\t\t\t\t*outDataSize = kClockSource_NumberItems * sizeof(UInt32);\n\t\t\t\t\tbreak;\n\t\t\t\tcase kAudioSelectorControlPropertyItemName:\n\t\t\t\t\t*outDataSize = sizeof(CFStringRef);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareBadObjectError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_GetControlPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, UInt32* outDataSize, void* outData)\n{\n\t#pragma unused(inClientProcessID, inQualifierData, inQualifierDataSize)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n    UInt32 theNumberItemsToFetch;\n    UInt32 theItemIndex;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetControlPropertyData: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetControlPropertyData: no address\");\n\tFailWithAction(outDataSize == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetControlPropertyData: no place to put the return value size\");\n\tFailWithAction(outData == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetControlPropertyData: no place to put the return value\");\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required.\n\t//\n\t//\tAlso, since most of the data that will get returned is static, there are few instances where\n\t//\tit is necessary to lock the state mutex.\n\tswitch(inObjectID)\n\t{\n\t\tcase kObjectID_Volume_Input_Master:\n\t\tcase kObjectID_Volume_Output_Master:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t\t\t//\tThe base class for kAudioVolumeControlClassID is kAudioLevelControlClassID\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioClassID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioObjectPropertyBaseClass for the volume control\");\n\t\t\t\t\t*((AudioClassID*)outData) = kAudioLevelControlClassID;\n\t\t\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase kAudioObjectPropertyClass:\n\t\t\t\t\t//\tVolume controls are of the class, kAudioVolumeControlClassID\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioClassID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioObjectPropertyClass for the volume control\");\n\t\t\t\t\t*((AudioClassID*)outData) = kAudioVolumeControlClassID;\n\t\t\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase kAudioObjectPropertyOwner:\n\t\t\t\t\t//\tThe control's owner is the device object\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioObjectID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioObjectPropertyOwner for the volume control\");\n\t\t\t\t\t*((AudioObjectID*)outData) = kObjectID_Device;\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t\t\t//\tControls do not own any objects\n\t\t\t\t\t*outDataSize = 0 * sizeof(AudioObjectID);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioControlPropertyScope:\n\t\t\t\t\t//\tThis property returns the scope that the control is attached to.\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioObjectPropertyScope), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioControlPropertyScope for the volume control\");\n\t\t\t\t\t*((AudioObjectPropertyScope*)outData) = (inObjectID == kObjectID_Volume_Input_Master) ? kAudioObjectPropertyScopeInput : kAudioObjectPropertyScopeOutput;\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectPropertyScope);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioControlPropertyElement:\n\t\t\t\t\t//\tThis property returns the element that the control is attached to.\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioObjectPropertyElement), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioControlPropertyElement for the volume control\");\n\t\t\t\t\t*((AudioObjectPropertyElement*)outData) = kAudioObjectPropertyElementMain;\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectPropertyElement);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioLevelControlPropertyScalarValue:\n\t\t\t\t\t//\tThis returns the value of the control in the normalized range of 0 to 1.\n\t\t\t\t\t//\tNote that we need to take the state lock to examine the value.\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(Float32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioLevelControlPropertyScalarValue for the volume control\");\n\t\t\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\t\t\t\t*((Float32*)outData) = volume_to_scalar(gVolume_Master_Value);\n\t\t\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\t\t\t*outDataSize = sizeof(Float32);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioLevelControlPropertyDecibelValue:\n\t\t\t\t\t//\tThis returns the dB value of the control.\n\t\t\t\t\t//\tNote that we need to take the state lock to examine the value.\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(Float32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioLevelControlPropertyDecibelValue for the volume control\");\n\t\t\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\t\t\t\t*((Float32*)outData) = gVolume_Master_Value;\n\t\t\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\t\t\t*((Float32*)outData) = volume_to_decibel(*((Float32*)outData));\n\t\t\t\t\t\n\t\t\t\t\t//\treport how much we wrote\n\t\t\t\t\t*outDataSize = sizeof(Float32);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioLevelControlPropertyDecibelRange:\n\t\t\t\t\t//\tThis returns the dB range of the control.\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioValueRange), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioLevelControlPropertyDecibelRange for the volume control\");\n\t\t\t\t\t((AudioValueRange*)outData)->mMinimum = kVolume_MinDB;\n\t\t\t\t\t((AudioValueRange*)outData)->mMaximum = kVolume_MaxDB;\n\t\t\t\t\t*outDataSize = sizeof(AudioValueRange);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioLevelControlPropertyConvertScalarToDecibels:\n\t\t\t\t\t//\tThis takes the scalar value in outData and converts it to dB.\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(Float32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioLevelControlPropertyDecibelValue for the volume control\");\n\t\t\t\t\t\n\t\t\t\t\t//\tclamp the value to be between 0 and 1\n\t\t\t\t\tif(*((Float32*)outData) < 0.0)\n\t\t\t\t\t{\n\t\t\t\t\t\t*((Float32*)outData) = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif(*((Float32*)outData) > 1.0)\n\t\t\t\t\t{\n\t\t\t\t\t\t*((Float32*)outData) = 1.0;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t//\tNote that we square the scalar value before converting to dB so as to\n\t\t\t\t\t//\tprovide a better curve for the slider\n\t\t\t\t\t*((Float32*)outData) *= *((Float32*)outData);\n\t\t\t\t\t*((Float32*)outData) = kVolume_MinDB + (*((Float32*)outData) * (kVolume_MaxDB - kVolume_MinDB));\n\t\t\t\t\t\n\t\t\t\t\t//\treport how much we wrote\n\t\t\t\t\t*outDataSize = sizeof(Float32);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioLevelControlPropertyConvertDecibelsToScalar:\n\t\t\t\t\t//\tThis takes the dB value in outData and converts it to scalar.\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(Float32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioLevelControlPropertyDecibelValue for the volume control\");\n\t\t\t\t\t\n\t\t\t\t\t//\tclamp the value to be between kVolume_MinDB and kVolume_MaxDB\n\t\t\t\t\tif(*((Float32*)outData) < kVolume_MinDB)\n\t\t\t\t\t{\n\t\t\t\t\t\t*((Float32*)outData) = kVolume_MinDB;\n\t\t\t\t\t}\n\t\t\t\t\tif(*((Float32*)outData) > kVolume_MaxDB)\n\t\t\t\t\t{\n\t\t\t\t\t\t*((Float32*)outData) = kVolume_MaxDB;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t//\tNote that we square the scalar value before converting to dB so as to\n\t\t\t\t\t//\tprovide a better curve for the slider. We undo that here.\n\t\t\t\t\t*((Float32*)outData) = *((Float32*)outData) - kVolume_MinDB;\n\t\t\t\t\t*((Float32*)outData) /= kVolume_MaxDB - kVolume_MinDB;\n\t\t\t\t\t*((Float32*)outData) = sqrtf(*((Float32*)outData));\n\t\t\t\t\t\n\t\t\t\t\t//\treport how much we wrote\n\t\t\t\t\t*outDataSize = sizeof(Float32);\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Mute_Input_Master:\n\t\tcase kObjectID_Mute_Output_Master:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t\t\t//\tThe base class for kAudioMuteControlClassID is kAudioBooleanControlClassID\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioClassID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioObjectPropertyBaseClass for the mute control\");\n\t\t\t\t\t*((AudioClassID*)outData) = kAudioBooleanControlClassID;\n\t\t\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase kAudioObjectPropertyClass:\n\t\t\t\t\t//\tMute controls are of the class, kAudioMuteControlClassID\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioClassID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioObjectPropertyClass for the mute control\");\n\t\t\t\t\t*((AudioClassID*)outData) = kAudioMuteControlClassID;\n\t\t\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase kAudioObjectPropertyOwner:\n\t\t\t\t\t//\tThe control's owner is the device object\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioObjectID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioObjectPropertyOwner for the mute control\");\n\t\t\t\t\t*((AudioObjectID*)outData) = kObjectID_Device;\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t\t\t//\tControls do not own any objects\n\t\t\t\t\t*outDataSize = 0 * sizeof(AudioObjectID);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioControlPropertyScope:\n\t\t\t\t\t//\tThis property returns the scope that the control is attached to.\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioObjectPropertyScope), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioControlPropertyScope for the mute control\");\n\t\t\t\t\t*((AudioObjectPropertyScope*)outData) = (inObjectID == kObjectID_Mute_Input_Master) ? kAudioObjectPropertyScopeInput : kAudioObjectPropertyScopeOutput;\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectPropertyScope);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioControlPropertyElement:\n\t\t\t\t\t//\tThis property returns the element that the control is attached to.\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioObjectPropertyElement), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioControlPropertyElement for the mute control\");\n\t\t\t\t\t*((AudioObjectPropertyElement*)outData) = kAudioObjectPropertyElementMain;\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectPropertyElement);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioBooleanControlPropertyValue:\n\t\t\t\t\t//\tThis returns the value of the mute control where 0 means that mute is off\n\t\t\t\t\t//\tand audio can be heard and 1 means that mute is on and audio cannot be heard.\n\t\t\t\t\t//\tNote that we need to take the state lock to examine this value.\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioBooleanControlPropertyValue for the mute control\");\n\t\t\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\t\t\t\t*((UInt32*)outData) = gMute_Master_Value ? 1 : 0;\n\t\t\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\n\t\tcase kObjectID_Pitch_Adjust:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t\t\t//    The base class for kAudioMuteControlClassID is kAudioBooleanControlClassID\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioClassID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioObjectPropertyBaseClass for the pitch control\");\n\t\t\t\t\t*((AudioClassID*)outData) = kAudioStereoPanControlClassID;\n\t\t\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioObjectPropertyClass:\n\t\t\t\t\t//    Level controls are of the class, kAudioLevelControlClassID\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioClassID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioObjectPropertyClass for the pitch control\");\n\t\t\t\t\t*((AudioClassID*)outData) = kAudioStereoPanControlClassID;\n\t\t\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioObjectPropertyOwner:\n\t\t\t\t\t//    The control's owner is the device object\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioObjectID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioObjectPropertyOwner for the pitch control\");\n\t\t\t\t\t*((AudioObjectID*)outData) = kObjectID_Device;\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t\t\t//    Controls do not own any objects\n\t\t\t\t\t*outDataSize = 0 * sizeof(AudioObjectID);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioControlPropertyScope:\n\t\t\t\t\t//    This property returns the scope that the control is attached to.\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioObjectPropertyScope), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioControlPropertyScope for the pitch control\");\n\t\t\t\t\t*((AudioObjectPropertyScope*)outData) = kAudioObjectPropertyScopeOutput;\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectPropertyScope);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioControlPropertyElement:\n\t\t\t\t\t//    This property returns the element that the control is attached to.\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioObjectPropertyElement), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioControlPropertyElement for the pitch control\");\n\t\t\t\t\t*((AudioObjectPropertyElement*)outData) = kAudioObjectPropertyElementMain;\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectPropertyElement);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioStereoPanControlPropertyValue:\n\t\t\t\t\t//    This returns the value of the pitch control.\n\t\t\t\t\t//    Note that we need to take the state lock to examine this value.\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(Float32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioLevelControlScalarValue for the pitch control\");\n\t\t\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\t\t\t\t*((Float32*)outData) = (inObjectID == kObjectID_Pitch_Adjust) ? gPitch_Adjust : 0.5;\n\t\t\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\t\t\t*outDataSize = sizeof(Float32);\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\t\tcase kObjectID_ClockSource:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioObjectPropertyBaseClass:\n\t\t\t\t\t//    The base class for kAudioDataSourceControlClassID is kAudioSelectorControlClassID\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioClassID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioObjectPropertyBaseClass for the data source control\");\n\t\t\t\t\t*((AudioClassID*)outData) = kAudioSelectorControlClassID;\n\t\t\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase kAudioObjectPropertyClass:\n\t\t\t\t\t//    Data Source controls are of the class, kAudioDataSourceControlClassID\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioClassID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioObjectPropertyClass for the data source control\");\n\t\t\t\t\t*((AudioClassID*)outData) = kAudioClockSourceControlClassID;\n\t\t\t\t\t*outDataSize = sizeof(AudioClassID);\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase kAudioObjectPropertyOwner:\n\t\t\t\t\t//    The control's owner is the device object\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioObjectID), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioObjectPropertyOwner for the data source control\");\n\t\t\t\t\t*((AudioObjectID*)outData) = kObjectID_Device;\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectID);\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase kAudioObjectPropertyOwnedObjects:\n\t\t\t\t\t//    Controls do not own any objects\n\t\t\t\t\t*outDataSize = 0 * sizeof(AudioObjectID);\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase kAudioControlPropertyScope:\n\t\t\t\t\t//    This property returns the scope that the control is attached to.\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioObjectPropertyScope), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioControlPropertyScope for the data source control\");\n\t\t\t\t\t*((AudioObjectPropertyScope*)outData) = kAudioObjectPropertyScopeGlobal;\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectPropertyScope);\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase kAudioControlPropertyElement:\n\t\t\t\t\t//    This property returns the element that the control is attached to.\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(AudioObjectPropertyElement), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioControlPropertyElement for the data source control\");\n\t\t\t\t\t*((AudioObjectPropertyElement*)outData) = kAudioObjectPropertyElementMain;\n\t\t\t\t\t*outDataSize = sizeof(AudioObjectPropertyElement);\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase kAudioSelectorControlPropertyCurrentItem:\n\t\t\t\t\t//    This returns the value of the data source selector.\n\t\t\t\t\t//    Note that we need to take the state lock to examine this value.\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioSelectorControlPropertyCurrentItem for the data source control\");\n\t\t\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\t\t\t\t*((UInt32*)outData) = gClockSource_Value;\n\t\t\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\t\t\t*outDataSize = sizeof(UInt32);\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase kAudioSelectorControlPropertyAvailableItems:\n\t\t\t\t\t//    This returns the IDs for all the items the data source control supports.\n\t\t\t\t\t\n\t\t\t\t\t//    Calculate the number of items that have been requested. Note that this\n\t\t\t\t\t//    number is allowed to be smaller than the actual size of the list. In such\n\t\t\t\t\t//    case, only that number of items will be returned\n\t\t\t\t\ttheNumberItemsToFetch = inDataSize / sizeof(UInt32);\n\t\t\t\t\t\n\t\t\t\t\t//    clamp it to the number of items we have\n\t\t\t\t\tif(theNumberItemsToFetch > kClockSource_NumberItems)\n\t\t\t\t\t{\n\t\t\t\t\t\ttheNumberItemsToFetch = kClockSource_NumberItems;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t//    fill out the return array\n\t\t\t\t\tfor(theItemIndex = 0; theItemIndex < theNumberItemsToFetch; ++theItemIndex)\n\t\t\t\t\t{\n\t\t\t\t\t\t((UInt32*)outData)[theItemIndex] = theItemIndex;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t//    report how much we wrote\n\t\t\t\t\t*outDataSize = theNumberItemsToFetch * sizeof(UInt32);\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase kAudioSelectorControlPropertyItemName:\n\t\t\t\t\t//    This returns the user-readable name for the selector item in the qualifier\n\t\t\t\t\tFailWithAction(inDataSize < sizeof(CFStringRef), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: not enough space for the return value of kAudioSelectorControlPropertyItemName for the clock source control\");\n\t\t\t\t\tFailWithAction(inQualifierDataSize != sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_GetControlPropertyData: wrong size for the qualifier of kAudioSelectorControlPropertyItemName for the clock source control\");\n\t\t\t\t\tFailWithAction(*((const UInt32*)inQualifierData) >= kClockSource_NumberItems, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_GetControlPropertyData: the item in the qualifier is not valid for kAudioSelectorControlPropertyItemName for the data source control\");\n\t\t\t\t\tif (*(UInt32*)inQualifierData == 0) {\n\t\t\t\t\t\t*(CFStringRef*)outData = CFSTR(kClockSource_InternalFixed);\n\t\t\t\t\t}\n\t\t\t\t\telse if (*(UInt32*)inQualifierData == 1) {\n\t\t\t\t\t\t*(CFStringRef*)outData = CFSTR(kClockSource_InternalAdjustable);\n\t\t\t\t\t}\n\t\t\t\t\t//else {\n\t\t\t\t\t//    *(CFStringRef*)outData = CFSTR(\"Unknown\");\n\t\t\t\t\t//}\n\t\t\t\t\t*outDataSize = sizeof(CFStringRef);\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareBadObjectError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_SetControlPropertyData(AudioServerPlugInDriverRef inDriver, AudioObjectID inObjectID, pid_t inClientProcessID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, const void* inData, UInt32* outNumberPropertiesChanged, AudioObjectPropertyAddress outChangedAddresses[2])\n{\n\t#pragma unused(inClientProcessID, inQualifierDataSize, inQualifierData)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\tFloat32 theNewVolume;\n    Float32 theNewPitch;\n    UInt32 theNewSource;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_SetControlPropertyData: bad driver reference\");\n\tFailWithAction(inAddress == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_SetControlPropertyData: no address\");\n\tFailWithAction(outNumberPropertiesChanged == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_SetControlPropertyData: no place to return the number of properties that changed\");\n\tFailWithAction(outChangedAddresses == NULL, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_SetControlPropertyData: no place to return the properties that changed\");\n\t\n\t//\tinitialize the returned number of changed properties\n\t*outNumberPropertiesChanged = 0;\n\t\n\t//\tNote that for each object, this driver implements all the required properties plus a few\n\t//\textras that are useful but not required. There is more detailed commentary about each\n\t//\tproperty in the BlackHole_GetControlPropertyData() method.\n\tswitch(inObjectID)\n\t{\n\t\tcase kObjectID_Volume_Input_Master:\n\t\tcase kObjectID_Volume_Output_Master:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioLevelControlPropertyScalarValue:\n\t\t\t\t\t//\tFor the scalar volume, we clamp the new value to [0, 1]. Note that if this\n\t\t\t\t\t//\tvalue changes, it implies that the dB value changed too.\n\t\t\t\t\tFailWithAction(inDataSize != sizeof(Float32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_SetControlPropertyData: wrong size for the data for kAudioLevelControlPropertyScalarValue\");\n\t\t\t\t\ttheNewVolume = volume_from_scalar(*((const Float32*)inData));\n\t\t\t\t\tif(theNewVolume < 0.0)\n\t\t\t\t\t{\n\t\t\t\t\t\ttheNewVolume = 0.0;\n\t\t\t\t\t}\n\t\t\t\t\telse if(theNewVolume > 1.0)\n\t\t\t\t\t{\n\t\t\t\t\t\ttheNewVolume = 1.0;\n\t\t\t\t\t}\n\t\t\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n                    if(gVolume_Master_Value != theNewVolume)\n                    {\n                        gVolume_Master_Value = theNewVolume;\n                        *outNumberPropertiesChanged = 2;\n                        outChangedAddresses[0].mSelector = kAudioLevelControlPropertyScalarValue;\n                        outChangedAddresses[0].mScope = kAudioObjectPropertyScopeGlobal;\n                        outChangedAddresses[0].mElement = kAudioObjectPropertyElementMain;\n                        outChangedAddresses[1].mSelector = kAudioLevelControlPropertyDecibelValue;\n                        outChangedAddresses[1].mScope = kAudioObjectPropertyScopeGlobal;\n                        outChangedAddresses[1].mElement = kAudioObjectPropertyElementMain;\n                    }\n\t\t\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\tcase kAudioLevelControlPropertyDecibelValue:\n\t\t\t\t\t//\tFor the dB value, we first convert it to a scalar value since that is how\n\t\t\t\t\t//\tthe value is tracked. Note that if this value changes, it implies that the\n\t\t\t\t\t//\tscalar value changes as well.\n\t\t\t\t\tFailWithAction(inDataSize != sizeof(Float32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_SetControlPropertyData: wrong size for the data for kAudioLevelControlPropertyScalarValue\");\n\t\t\t\t\ttheNewVolume = *((const Float32*)inData);\n\t\t\t\t\tif(theNewVolume < kVolume_MinDB)\n\t\t\t\t\t{\n\t\t\t\t\t\ttheNewVolume = kVolume_MinDB;\n\t\t\t\t\t}\n\t\t\t\t\telse if(theNewVolume > kVolume_MaxDB)\n\t\t\t\t\t{\n\t\t\t\t\t\ttheNewVolume = kVolume_MaxDB;\n\t\t\t\t\t}\n\t\t\t\t\ttheNewVolume = volume_from_decibel(theNewVolume);\n\t\t\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n                    if(gVolume_Master_Value != theNewVolume)\n                    {\n                        gVolume_Master_Value = theNewVolume;\n                        *outNumberPropertiesChanged = 2;\n                        outChangedAddresses[0].mSelector = kAudioLevelControlPropertyScalarValue;\n                        outChangedAddresses[0].mScope = kAudioObjectPropertyScopeGlobal;\n                        outChangedAddresses[0].mElement = kAudioObjectPropertyElementMain;\n                        outChangedAddresses[1].mSelector = kAudioLevelControlPropertyDecibelValue;\n                        outChangedAddresses[1].mScope = kAudioObjectPropertyScopeGlobal;\n                        outChangedAddresses[1].mElement = kAudioObjectPropertyElementMain;\n                    }\n\t\t\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\tdefault:\n\t\t\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\t\t\n\t\tcase kObjectID_Mute_Input_Master:\n\t\tcase kObjectID_Mute_Output_Master:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioBooleanControlPropertyValue:\n\t\t\t\t\tFailWithAction(inDataSize != sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_SetControlPropertyData: wrong size for the data for kAudioBooleanControlPropertyValue\");\n\t\t\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n                    if(gMute_Master_Value != (*((const UInt32*)inData) != 0))\n                    {\n                        gMute_Master_Value = *((const UInt32*)inData) != 0;\n                        *outNumberPropertiesChanged = 1;\n                        outChangedAddresses[0].mSelector = kAudioBooleanControlPropertyValue;\n                        outChangedAddresses[0].mScope = kAudioObjectPropertyScopeGlobal;\n                        outChangedAddresses[0].mElement = kAudioObjectPropertyElementMain;\n                    }\n\t\t\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\tdefault:\n\t\t\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\n\t\tcase kObjectID_Pitch_Adjust:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioStereoPanControlPropertyValue:\n\t\t\t\t\t//    For the scalar pitch, we clamp the new value to [0, 1].\n\t\t\t\t\tFailWithAction(inDataSize != sizeof(Float32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_SetControlPropertyData: wrong size for the data for kAudioLevelControlPropertyScalarValue\");\n\t\t\t\t\ttheNewPitch = *((const Float32*)inData);\n\t\t\t\t\tif(theNewPitch < 0.0)\n\t\t\t\t\t{\n\t\t\t\t\t\ttheNewPitch = 0.0;\n\t\t\t\t\t}\n\t\t\t\t\telse if(theNewPitch > 1.0)\n\t\t\t\t\t{\n\t\t\t\t\t\ttheNewPitch = 1.0;\n\t\t\t\t\t}\n\t\t\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\n\t\t\t\t\tif(gPitch_Adjust != theNewPitch)\n\t\t\t\t\t{\n\t\t\t\t\t\tgPitch_Adjust = theNewPitch;\n\t\t\t\t\t\tgDevice_AdjustedTicksPerFrame = gDevice_HostTicksPerFrame - gDevice_HostTicksPerFrame/100.0 * 2.0*(gPitch_Adjust - 0.5);\n\t\t\t\t\t\t*outNumberPropertiesChanged = 1;\n\t\t\t\t\t\toutChangedAddresses[0].mSelector = kAudioStereoPanControlPropertyValue;\n\t\t\t\t\t\toutChangedAddresses[0].mScope = kAudioObjectPropertyScopeGlobal;\n\t\t\t\t\t\toutChangedAddresses[0].mElement = kAudioObjectPropertyElementMain;\n\t\t\t\t\t}\n\t\t\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tdefault:\n\t\t\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\t\t\t\n\t\tcase kObjectID_ClockSource:\n\t\t\tswitch(inAddress->mSelector)\n\t\t\t{\n\t\t\t\tcase kAudioSelectorControlPropertyCurrentItem:\n\t\t\t\t\tFailWithAction(inDataSize != sizeof(UInt32), theAnswer = kAudioHardwareBadPropertySizeError, Done, \"BlackHole_SetControlPropertyData: wrong size for the data for kAudioSelectorControlPropertyCurrentItem\");\n\t\t\t\t\ttheNewSource = *((const UInt32*)inData);\n\t\t\t\t\tif(theNewSource >= kClockSource_NumberItems)\n\t\t\t\t\t{\n\t\t\t\t\t\ttheNewSource = kClockSource_NumberItems - 1;\n\t\t\t\t\t}\n\t\t\t\t\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\t\t\t\tif(gClockSource_Value != theNewSource)\n\t\t\t\t\t{\n\t\t\t\t\t\tgClockSource_Value = theNewSource;\n\t\t\t\t\t\tUInt64 changeAction = (theNewSource > 0) ? ChangeAction_EnablePitchControl : ChangeAction_DisablePitchControl;\n\n\t\t\t\t\t\t*outNumberPropertiesChanged = 1;\n\t\t\t\t\t\toutChangedAddresses[0].mSelector = kAudioSelectorControlPropertyCurrentItem;\n\t\t\t\t\t\toutChangedAddresses[0].mScope = kAudioObjectPropertyScopeGlobal;\n\t\t\t\t\t\toutChangedAddresses[0].mElement = kAudioObjectPropertyElementMain;\n\n\t\t\t\t\t\t// Notify HAL about device configuration change\n\t\t\t\t\t\tdispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{\n\t\t\t\t\t\t\tgPlugIn_Host->RequestDeviceConfigurationChange(gPlugIn_Host, kObjectID_Device, changeAction, NULL);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\ttheAnswer = kAudioHardwareUnknownPropertyError;\n\t\t\t\t\tbreak;\n\t\t\t};\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\ttheAnswer = kAudioHardwareBadObjectError;\n\t\t\tbreak;\n\t};\n\nDone:\n\treturn theAnswer;\n}\n\n#pragma mark IO Operations\n\nstatic OSStatus\tBlackHole_StartIO(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, UInt32 inClientID)\n{\n\t//\tThis call tells the device that IO is starting for the given client. When this routine\n\t//\treturns, the device's clock is running and it is ready to have data read/written. It is\n\t//\timportant to note that multiple clients can have IO running on the device at the same time.\n\t//\tSo, work only needs to be done when the first client starts. All subsequent starts simply\n\t//\tincrement the counter.\n    \n    DebugMsg(\"BlackHole_StartIO\");\n\t\n\t#pragma unused(inClientID, inDeviceObjectID)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_StartIO: bad driver reference\");\n\tFailWithAction(inDeviceObjectID != kObjectID_Device && inDeviceObjectID != kObjectID_Device2, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_StartIO: bad device ID\");\n    FailWithAction(inDeviceObjectID == kObjectID_Device && gDevice_IOIsRunning == UINT64_MAX, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_StartIO: overflow error.\");\n    FailWithAction(inDeviceObjectID == kObjectID_Device2 && gDevice2_IOIsRunning == UINT64_MAX, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_StartIO: overflow error.\");\n\n\t//\twe need to hold the state lock\n\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\n    \n    if (inDeviceObjectID == kObjectID_Device) { gDevice_IOIsRunning += 1; }\n    if (inDeviceObjectID == kObjectID_Device2) { gDevice2_IOIsRunning += 1; }\n    \n    // allocate ring buffer\n    if ((gDevice_IOIsRunning || gDevice2_IOIsRunning) && gRingBuffer == NULL)\n    {\n        gDevice_NumberTimeStamps = 0;\n        gDevice_AnchorSampleTime = 0;\n        gDevice_AnchorHostTime = mach_absolute_time();\n        gDevice_PreviousTicks = 0;\n        gRingBuffer = calloc(kRing_Buffer_Frame_Size * kNumber_Of_Channels, sizeof(Float32));\n    }\n    \n    \n\t//\tunlock the state lock\n\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_StopIO(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, UInt32 inClientID)\n{\n\t//\tThis call tells the device that the client has stopped IO. The driver can stop the hardware\n\t//\tonce all clients have stopped.\n\t\n\t#pragma unused(inClientID, inDeviceObjectID)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_StopIO: bad driver reference\");\n\tFailWithAction(inDeviceObjectID != kObjectID_Device && inDeviceObjectID != kObjectID_Device2, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_StopIO: bad device ID\");\n    FailWithAction(inDeviceObjectID == kObjectID_Device && gDevice_IOIsRunning == 0, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_StartIO: underflow error.\");\n    FailWithAction(inDeviceObjectID == kObjectID_Device2 && gDevice2_IOIsRunning == 0, theAnswer = kAudioHardwareIllegalOperationError, Done, \"BlackHole_StartIO: underflow error.\");\n\n\t//\twe need to hold the state lock\n\tpthread_mutex_lock(&gPlugIn_StateMutex);\n\t\n    \n    if (inDeviceObjectID == kObjectID_Device) { gDevice_IOIsRunning -= 1; }\n    if (inDeviceObjectID == kObjectID_Device2) { gDevice2_IOIsRunning -= 1; }\n    \n    // free the ring buffer\n    if (!gDevice_IOIsRunning && !gDevice2_IOIsRunning && gRingBuffer != NULL)\n    {\n        free(gRingBuffer);\n        gRingBuffer = NULL;\n    }\n\t\n\t//\tunlock the state lock\n\tpthread_mutex_unlock(&gPlugIn_StateMutex);\n\t\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_GetZeroTimeStamp(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, UInt32 inClientID, Float64* outSampleTime, UInt64* outHostTime, UInt64* outSeed)\n{\n\t//\tThis method returns the current zero time stamp for the device. The HAL models the timing of\n\t//\ta device as a series of time stamps that relate the sample time to a host time. The zero\n\t//\ttime stamps are spaced such that the sample times are the value of\n\t//\tkAudioDevicePropertyZeroTimeStampPeriod apart. This is often modeled using a ring buffer\n\t//\twhere the zero time stamp is updated when wrapping around the ring buffer.\n\t//\n\t//\tFor this device, the zero time stamps' sample time increments every kDevice_RingBufferSize\n\t//\tframes and the host time increments by kDevice_RingBufferSize * gDevice_HostTicksPerFrame.\n\t\n\t#pragma unused(inClientID, inDeviceObjectID)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\tUInt64 theCurrentHostTime;\n\tFloat64 theHostTicksPerRingBuffer;\n\tFloat64 theAdjustedTicksPerRingBuffer;\n\tFloat64 theNextTickOffset;\n\tUInt64 theNextHostTime;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetZeroTimeStamp: bad driver reference\");\n\tFailWithAction(inDeviceObjectID != kObjectID_Device && inDeviceObjectID != kObjectID_Device2, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_GetZeroTimeStamp: bad device ID\");\n\n\t//\twe need to hold the locks\n\tpthread_mutex_lock(&gDevice_IOMutex);\n\t\n\t//\tget the current host time\n\ttheCurrentHostTime = mach_absolute_time();\n\t\n\t//\tcalculate the next host time\n\ttheHostTicksPerRingBuffer = gDevice_HostTicksPerFrame * ((Float64)kDevice_RingBufferSize);\n    if (gClockSource_Value > 0) {\n        theAdjustedTicksPerRingBuffer = gDevice_AdjustedTicksPerFrame * ((Float64)kDevice_RingBufferSize);\n    }\n    else {\n        theAdjustedTicksPerRingBuffer = gDevice_HostTicksPerFrame * ((Float64)kDevice_RingBufferSize);\n    }\n    \n\ttheNextTickOffset = gDevice_PreviousTicks + theAdjustedTicksPerRingBuffer;\n    \n\ttheNextHostTime = gDevice_AnchorHostTime + ((UInt64)theNextTickOffset);\n\t\n\t//\tgo to the next time if the next host time is less than the current time\n\tif(theNextHostTime <= theCurrentHostTime)\n\t{\n\t\t++gDevice_NumberTimeStamps;\n\t\tgDevice_PreviousTicks = theNextTickOffset;\n\t}\n\t\n\t//\tset the return values\n\t*outSampleTime = gDevice_NumberTimeStamps * kDevice_RingBufferSize;\n\t*outHostTime = gDevice_AnchorHostTime + gDevice_PreviousTicks;\n\t*outSeed = 1;\n    \n    // DebugMsg(\"SampleTime: %f \\t HostTime: %llu\", *outSampleTime, *outHostTime);\n\t\n\t//\tunlock the state lock\n\tpthread_mutex_unlock(&gDevice_IOMutex);\n\t\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_WillDoIOOperation(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, UInt32 inClientID, UInt32 inOperationID, Boolean* outWillDo, Boolean* outWillDoInPlace)\n{\n\t//\tThis method returns whether or not the device will do a given IO operation. For this device,\n\t//\twe only support reading input data and writing output data.\n\t\n\t#pragma unused(inClientID, inDeviceObjectID)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_WillDoIOOperation: bad driver reference\");\n\tFailWithAction(inDeviceObjectID != kObjectID_Device && inDeviceObjectID != kObjectID_Device2, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_WillDoIOOperation: bad device ID\");\n\n\t//\tfigure out if we support the operation\n\tbool willDo = false;\n\tbool willDoInPlace = true;\n\tswitch(inOperationID)\n\t{\n\t\tcase kAudioServerPlugInIOOperationReadInput:\n\t\t\twillDo = true;\n\t\t\twillDoInPlace = true;\n\t\t\tbreak;\n\t\t\t\n\t\tcase kAudioServerPlugInIOOperationWriteMix:\n\t\t\twillDo = true;\n\t\t\twillDoInPlace = true;\n\t\t\tbreak;\n\t\t\t\n\t};\n\t\n\t//\tfill out the return values\n\tif(outWillDo != NULL)\n\t{\n\t\t*outWillDo = willDo;\n\t}\n\tif(outWillDoInPlace != NULL)\n\t{\n\t\t*outWillDoInPlace = willDoInPlace;\n\t}\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_BeginIOOperation(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, UInt32 inClientID, UInt32 inOperationID, UInt32 inIOBufferFrameSize, const AudioServerPlugInIOCycleInfo* inIOCycleInfo)\n{\n\t//\tThis is called at the beginning of an IO operation. This device doesn't do anything, so just\n\t//\tcheck the arguments and return.\n\t\n\t#pragma unused(inClientID, inOperationID, inIOBufferFrameSize, inIOCycleInfo, inDeviceObjectID)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_BeginIOOperation: bad driver reference\");\n\tFailWithAction(inDeviceObjectID != kObjectID_Device && inDeviceObjectID != kObjectID_Device2, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_BeginIOOperation: bad device ID\");\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_DoIOOperation(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, AudioObjectID inStreamObjectID, UInt32 inClientID, UInt32 inOperationID, UInt32 inIOBufferFrameSize, const AudioServerPlugInIOCycleInfo* inIOCycleInfo, void* ioMainBuffer, void* ioSecondaryBuffer)\n{\n\t//\tThis is called to actually perform a given operation. \n\t\n\t#pragma unused(inClientID, inIOCycleInfo, ioSecondaryBuffer, inDeviceObjectID)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_DoIOOperation: bad driver reference\");\n\tFailWithAction(inDeviceObjectID != kObjectID_Device && inDeviceObjectID != kObjectID_Device2, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_DoIOOperation: bad device ID\");\n\tFailWithAction((inStreamObjectID != kObjectID_Stream_Input) && (inStreamObjectID != kObjectID_Stream_Output), theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_DoIOOperation: bad stream ID\");\n\n    // Calculate the ring buffer offsets and splits.\n    UInt64 mSampleTime = inOperationID == kAudioServerPlugInIOOperationReadInput ? inIOCycleInfo->mInputTime.mSampleTime : inIOCycleInfo->mOutputTime.mSampleTime;\n    UInt32 ringBufferFrameLocationStart = mSampleTime % kRing_Buffer_Frame_Size;\n    UInt32 firstPartFrameSize = kRing_Buffer_Frame_Size - ringBufferFrameLocationStart;\n    UInt32 secondPartFrameSize = 0;\n    \n    if (firstPartFrameSize >= inIOBufferFrameSize)\n    {\n        firstPartFrameSize = inIOBufferFrameSize;\n    }\n    else\n    {\n        secondPartFrameSize = inIOBufferFrameSize - firstPartFrameSize;\n    }\n    \n    // Keep track of last outputSampleTime and the cleared buffer status.\n    static Float64 lastOutputSampleTime = 0;\n    static Boolean isBufferClear = true;\n    \n    // From BlackHole to Application\n    if(inOperationID == kAudioServerPlugInIOOperationReadInput)\n    {\n        // If mute is one let's just fill the buffer with zeros or if there's no apps outputting audio\n        if (gMute_Master_Value || lastOutputSampleTime - inIOBufferFrameSize < inIOCycleInfo->mInputTime.mSampleTime)\n        {\n            // Clear the ioMainBuffer\n            vDSP_vclr(ioMainBuffer, 1, inIOBufferFrameSize * kNumber_Of_Channels);\n            \n            // Clear the ring buffer.\n            if (!isBufferClear)\n            {\n                vDSP_vclr(gRingBuffer, 1, kRing_Buffer_Frame_Size * kNumber_Of_Channels);\n                isBufferClear = true;\n            }\n        }\n        else\n        {\n            // Copy the buffers.\n            memcpy(ioMainBuffer, gRingBuffer + ringBufferFrameLocationStart * kNumber_Of_Channels, firstPartFrameSize * kNumber_Of_Channels * sizeof(Float32));\n            memcpy((Float32*)ioMainBuffer + firstPartFrameSize * kNumber_Of_Channels, gRingBuffer, secondPartFrameSize * kNumber_Of_Channels * sizeof(Float32));\n            \n            // Finally we'll apply the output volume to the buffer.\n\t    if(kEnableVolumeControl)\n\t    {\n\t \tvDSP_vsmul(ioMainBuffer, 1, &gVolume_Master_Value, ioMainBuffer, 1, inIOBufferFrameSize * kNumber_Of_Channels);\n\t    }\n\n        }\n    }\n    \n    // From Application to BlackHole\n    if(inOperationID == kAudioServerPlugInIOOperationWriteMix)\n    {\n        \n        // Overload error.\n        if (inIOCycleInfo->mCurrentTime.mSampleTime > inIOCycleInfo->mOutputTime.mSampleTime + inIOBufferFrameSize + kLatency_Frame_Size)\n        {\n            DebugMsg(\"BlackHole overload error. kAudioServerPlugInIOOperationWriteMix was unable to complete operation before the deadline. Try increasing the buffer frame size.\");\n            return kAudioHardwareUnspecifiedError;\n        }\n        \n        \n        // Copy the buffers.\n        memcpy(gRingBuffer + ringBufferFrameLocationStart * kNumber_Of_Channels, ioMainBuffer, firstPartFrameSize * kNumber_Of_Channels * sizeof(Float32));\n        memcpy(gRingBuffer, (Float32*)ioMainBuffer + firstPartFrameSize * kNumber_Of_Channels, secondPartFrameSize * kNumber_Of_Channels * sizeof(Float32));\n        \n        // Save the last output time.\n        lastOutputSampleTime = inIOCycleInfo->mOutputTime.mSampleTime + inIOBufferFrameSize;\n        isBufferClear = false;\n    }\n\nDone:\n\treturn theAnswer;\n}\n\nstatic OSStatus\tBlackHole_EndIOOperation(AudioServerPlugInDriverRef inDriver, AudioObjectID inDeviceObjectID, UInt32 inClientID, UInt32 inOperationID, UInt32 inIOBufferFrameSize, const AudioServerPlugInIOCycleInfo* inIOCycleInfo)\n{\n\t//\tThis is called at the end of an IO operation. This device doesn't do anything, so just check\n\t//\tthe arguments and return.\n\t\n\t#pragma unused(inClientID, inOperationID, inIOBufferFrameSize, inIOCycleInfo, inDeviceObjectID)\n\t\n\t//\tdeclare the local variables\n\tOSStatus theAnswer = 0;\n\t\n\t//\tcheck the arguments\n\tFailWithAction(inDriver != gAudioServerPlugInDriverRef, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_EndIOOperation: bad driver reference\");\n\tFailWithAction(inDeviceObjectID != kObjectID_Device && inDeviceObjectID != kObjectID_Device2, theAnswer = kAudioHardwareBadObjectError, Done, \"BlackHole_EndIOOperation: bad device ID\");\n\nDone:\n\treturn theAnswer;\n}\n"
  },
  {
    "path": "BlackHole/BlackHole.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>English</string>\n\t<key>CFBundleExecutable</key>\n\t<string>${EXECUTABLE_NAME}</string>\n\t<key>CFBundleIconFile</key>\n\t<string></string>\n\t<key>CFBundleIdentifier</key>\n\t<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundleName</key>\n\t<string>${PRODUCT_NAME}</string>\n\t<key>CFBundlePackageType</key>\n\t<string>BNDL</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string>$(MARKETING_VERSION)</string>\n\t<key>CFBundleSignature</key>\n\t<string>????</string>\n\t<key>CFBundleVersion</key>\n\t<string>596</string>\n\t<key>CFPlugInFactories</key>\n\t<dict>\n\t\t<key>e395c745-4eea-4d94-bb92-46224221047c</key>\n\t\t<string>BlackHole_Create</string>\n\t</dict>\n\t<key>CFPlugInTypes</key>\n\t<dict>\n\t\t<key>443ABAB8-E7B3-491A-B985-BEB9187030DB</key>\n\t\t<array>\n\t\t\t<string>e395c745-4eea-4d94-bb92-46224221047c</string>\n\t\t</array>\n\t</dict>\n</dict>\n</plist>\n"
  },
  {
    "path": "BlackHole.xcodeproj/project.pbxproj",
    "content": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 46;\n\tobjects = {\n\n/* Begin PBXBuildFile section */\n\t\t3D083818284A7F1200C69403 /* VERSION in Resources */ = {isa = PBXBuildFile; fileRef = 3D89662F2849BF1A002AB3F0 /* VERSION */; };\n\t\t3D083819284A7F1500C69403 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 2DA8FA1515FEAAB000F04B50 /* README.md */; };\n\t\t3D88D48F285BBA5800629399 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 3D88D48E285BBA5800629399 /* main.c */; };\n\t\t3D89663F2849C318002AB3F0 /* BlackHole.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D616EF215B8C82500D598BD /* BlackHole.c */; };\n\t\t3D8966412849C318002AB3F0 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D6C8E45275E92B40030C104 /* Accelerate.framework */; };\n\t\t3D8966422849C318002AB3F0 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2D7477EC157823CF00412279 /* CoreAudio.framework */; };\n\t\t3D8966432849C318002AB3F0 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2D7477AC1578168D00412279 /* CoreFoundation.framework */; };\n\t\t3D8966462849C318002AB3F0 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 03FDCADB233FAE0500101681 /* LICENSE */; };\n\t\t3D8966472849C318002AB3F0 /* BlackHole.icns in Resources */ = {isa = PBXBuildFile; fileRef = 03FDCAD9233F235500101681 /* BlackHole.icns */; };\n\t\t3D8966482849C318002AB3F0 /* CHANGELOG.md in Resources */ = {isa = PBXBuildFile; fileRef = 039FF2572341B6E800400D7A /* CHANGELOG.md */; };\n/* End PBXBuildFile section */\n\n/* Begin PBXCopyFilesBuildPhase section */\n\t\t3D88D48A285BBA5800629399 /* CopyFiles */ = {\n\t\t\tisa = PBXCopyFilesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tdstPath = /usr/share/man/man1/;\n\t\t\tdstSubfolderSpec = 0;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 1;\n\t\t};\n/* End PBXCopyFilesBuildPhase section */\n\n/* Begin PBXFileReference section */\n\t\t039FF2572341B6E800400D7A /* CHANGELOG.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = \"<group>\"; };\n\t\t03FDCAD9233F235500101681 /* BlackHole.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = BlackHole.icns; sourceTree = \"<group>\"; };\n\t\t03FDCADB233FAE0500101681 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = \"<group>\"; };\n\t\t2D616EF215B8C82500D598BD /* BlackHole.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BlackHole.c; sourceTree = \"<group>\"; };\n\t\t2D7477AC1578168D00412279 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };\n\t\t2D7477EC157823CF00412279 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; };\n\t\t2DA8FA1515FEAAB000F04B50 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = \"<group>\"; };\n\t\t2DD7AA9915EC572000C67AE1 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };\n\t\t2DED183A15C357180091BE97 /* Kernel.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Kernel.framework; path = System/Library/Frameworks/Kernel.framework; sourceTree = SDKROOT; };\n\t\t3D083806284A7BB000C69403 /* conclusion.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = conclusion.html; sourceTree = \"<group>\"; };\n\t\t3D083807284A7BB000C69403 /* requirements.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = requirements.xml; sourceTree = \"<group>\"; };\n\t\t3D083808284A7BB000C69403 /* welcome.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = welcome.html; sourceTree = \"<group>\"; };\n\t\t3D08380E284A7DE100C69403 /* BlackHole.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = BlackHole.plist; sourceTree = \"<group>\"; };\n\t\t3D08381B284AA8EE00C69403 /* create_installer.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_installer.sh; sourceTree = \"<group>\"; };\n\t\t3D6C8E45275E92B40030C104 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; };\n\t\t3D88D48C285BBA5800629399 /* BlackHoleTests */ = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.executable\"; includeInIndex = 0; path = BlackHoleTests; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t3D88D48E285BBA5800629399 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = \"<group>\"; };\n\t\t3D89662F2849BF1A002AB3F0 /* VERSION */ = {isa = PBXFileReference; lastKnownFileType = text; path = VERSION; sourceTree = \"<group>\"; };\n\t\t3D89664D2849C318002AB3F0 /* BlackHole.driver */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BlackHole.driver; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t3D8966882849D45F002AB3F0 /* postinstall */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = postinstall; sourceTree = \"<group>\"; };\n\t\t3D8966892849D45F002AB3F0 /* preinstall */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = preinstall; sourceTree = \"<group>\"; };\n/* End PBXFileReference section */\n\n/* Begin PBXFrameworksBuildPhase section */\n\t\t3D88D489285BBA5800629399 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t3D8966402849C318002AB3F0 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t3D8966412849C318002AB3F0 /* Accelerate.framework in Frameworks */,\n\t\t\t\t3D8966422849C318002AB3F0 /* CoreAudio.framework in Frameworks */,\n\t\t\t\t3D8966432849C318002AB3F0 /* CoreFoundation.framework in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXFrameworksBuildPhase section */\n\n/* Begin PBXGroup section */\n\t\t2D616EF015B8C82500D598BD /* BlackHole */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t3D08380E284A7DE100C69403 /* BlackHole.plist */,\n\t\t\t\t03FDCAD9233F235500101681 /* BlackHole.icns */,\n\t\t\t\t2D616EF215B8C82500D598BD /* BlackHole.c */,\n\t\t\t);\n\t\t\tpath = BlackHole;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2D74779B1578162B00412279 = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t3D083805284A7BB000C69403 /* Installer */,\n\t\t\t\t3D89662F2849BF1A002AB3F0 /* VERSION */,\n\t\t\t\t2DA8FA1515FEAAB000F04B50 /* README.md */,\n\t\t\t\t03FDCADB233FAE0500101681 /* LICENSE */,\n\t\t\t\t039FF2572341B6E800400D7A /* CHANGELOG.md */,\n\t\t\t\t2D616EF015B8C82500D598BD /* BlackHole */,\n\t\t\t\t3D88D48D285BBA5800629399 /* BlackHoleTests */,\n\t\t\t\t2D7477AB1578168D00412279 /* Frameworks */,\n\t\t\t\t2D7477AA1578168D00412279 /* Products */,\n\t\t\t);\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2D7477AA1578168D00412279 /* Products */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t3D89664D2849C318002AB3F0 /* BlackHole.driver */,\n\t\t\t\t3D88D48C285BBA5800629399 /* BlackHoleTests */,\n\t\t\t);\n\t\t\tname = Products;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2D7477AB1578168D00412279 /* Frameworks */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t3D6C8E45275E92B40030C104 /* Accelerate.framework */,\n\t\t\t\t2D7477EC157823CF00412279 /* CoreAudio.framework */,\n\t\t\t\t2D7477AC1578168D00412279 /* CoreFoundation.framework */,\n\t\t\t\t2DD7AA9915EC572000C67AE1 /* IOKit.framework */,\n\t\t\t\t2DED183A15C357180091BE97 /* Kernel.framework */,\n\t\t\t);\n\t\t\tname = Frameworks;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t3D083805284A7BB000C69403 /* Installer */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t3D08381B284AA8EE00C69403 /* create_installer.sh */,\n\t\t\t\t3D8966872849D45F002AB3F0 /* scripts */,\n\t\t\t\t3D083806284A7BB000C69403 /* conclusion.html */,\n\t\t\t\t3D083807284A7BB000C69403 /* requirements.xml */,\n\t\t\t\t3D083808284A7BB000C69403 /* welcome.html */,\n\t\t\t);\n\t\t\tpath = Installer;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t3D88D48D285BBA5800629399 /* BlackHoleTests */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t3D88D48E285BBA5800629399 /* main.c */,\n\t\t\t);\n\t\t\tpath = BlackHoleTests;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t3D8966872849D45F002AB3F0 /* scripts */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t3D8966882849D45F002AB3F0 /* postinstall */,\n\t\t\t\t3D8966892849D45F002AB3F0 /* preinstall */,\n\t\t\t);\n\t\t\tpath = scripts;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXGroup section */\n\n/* Begin PBXNativeTarget section */\n\t\t3D88D48B285BBA5800629399 /* BlackHoleTests */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 3D88D493285BBA5800629399 /* Build configuration list for PBXNativeTarget \"BlackHoleTests\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t3D88D488285BBA5800629399 /* Sources */,\n\t\t\t\t3D88D489285BBA5800629399 /* Frameworks */,\n\t\t\t\t3D88D48A285BBA5800629399 /* CopyFiles */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = BlackHoleTests;\n\t\t\tproductName = BlackHoleTests;\n\t\t\tproductReference = 3D88D48C285BBA5800629399 /* BlackHoleTests */;\n\t\t\tproductType = \"com.apple.product-type.tool\";\n\t\t};\n\t\t3D89663D2849C318002AB3F0 /* BlackHole */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 3D8966492849C318002AB3F0 /* Build configuration list for PBXNativeTarget \"BlackHole\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t3D89663E2849C318002AB3F0 /* Sources */,\n\t\t\t\t3D8966402849C318002AB3F0 /* Frameworks */,\n\t\t\t\t3D8966452849C318002AB3F0 /* Resources */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = BlackHole;\n\t\t\tproductName = AudioNULLDriver;\n\t\t\tproductReference = 3D89664D2849C318002AB3F0 /* BlackHole.driver */;\n\t\t\tproductType = \"com.apple.product-type.bundle\";\n\t\t};\n/* End PBXNativeTarget section */\n\n/* Begin PBXProject section */\n\t\t2D74779D1578162B00412279 /* Project object */ = {\n\t\t\tisa = PBXProject;\n\t\t\tattributes = {\n\t\t\t\tLastUpgradeCheck = 1220;\n\t\t\t\tTargetAttributes = {\n\t\t\t\t\t3D88D48B285BBA5800629399 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 13.4;\n\t\t\t\t\t\tDevelopmentTeam = Q5C99V536K;\n\t\t\t\t\t\tProvisioningStyle = Automatic;\n\t\t\t\t\t};\n\t\t\t\t\t3D89663D2849C318002AB3F0 = {\n\t\t\t\t\t\tDevelopmentTeam = Q5C99V536K;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t};\n\t\t\tbuildConfigurationList = 2D7477A01578162B00412279 /* Build configuration list for PBXProject \"BlackHole\" */;\n\t\t\tcompatibilityVersion = \"Xcode 3.2\";\n\t\t\tdevelopmentRegion = en;\n\t\t\thasScannedForEncodings = 0;\n\t\t\tknownRegions = (\n\t\t\t\ten,\n\t\t\t\tBase,\n\t\t\t);\n\t\t\tmainGroup = 2D74779B1578162B00412279;\n\t\t\tproductRefGroup = 2D7477AA1578168D00412279 /* Products */;\n\t\t\tprojectDirPath = \"\";\n\t\t\tprojectRoot = \"\";\n\t\t\ttargets = (\n\t\t\t\t3D89663D2849C318002AB3F0 /* BlackHole */,\n\t\t\t\t3D88D48B285BBA5800629399 /* BlackHoleTests */,\n\t\t\t);\n\t\t};\n/* End PBXProject section */\n\n/* Begin PBXResourcesBuildPhase section */\n\t\t3D8966452849C318002AB3F0 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t3D8966462849C318002AB3F0 /* LICENSE in Resources */,\n\t\t\t\t3D8966472849C318002AB3F0 /* BlackHole.icns in Resources */,\n\t\t\t\t3D8966482849C318002AB3F0 /* CHANGELOG.md in Resources */,\n\t\t\t\t3D083818284A7F1200C69403 /* VERSION in Resources */,\n\t\t\t\t3D083819284A7F1500C69403 /* README.md in Resources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXResourcesBuildPhase section */\n\n/* Begin PBXSourcesBuildPhase section */\n\t\t3D88D488285BBA5800629399 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t3D88D48F285BBA5800629399 /* main.c in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t3D89663E2849C318002AB3F0 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t3D89663F2849C318002AB3F0 /* BlackHole.c in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXSourcesBuildPhase section */\n\n/* Begin XCBuildConfiguration section */\n\t\t2D7477A21578162B00412279 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"c++0x\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_COMMA = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_IMPLICIT_SIGN_CONVERSION = NO;\n\t\t\t\tCLANG_WARN_INFINITE_RECURSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;\n\t\t\t\tCLANG_WARN_OBJC_LITERAL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;\n\t\t\t\tCLANG_WARN_RANGE_LOOP_ANALYSIS = YES;\n\t\t\t\tCLANG_WARN_STRICT_PROTOTYPES = YES;\n\t\t\t\tCLANG_WARN_SUSPICIOUS_MOVE = YES;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\tCLANG_WARN__EXIT_TIME_DESTRUCTORS = YES;\n\t\t\t\tDEAD_CODE_STRIPPING = YES;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_OPTIMIZATION_LEVEL = s;\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;\n\t\t\t\tGCC_WARN_ABOUT_MISSING_NEWLINE = YES;\n\t\t\t\tGCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;\n\t\t\t\tGCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;\n\t\t\t\tGCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;\n\t\t\t\tGCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;\n\t\t\t\tGCC_WARN_SHADOW = YES;\n\t\t\t\tGCC_WARN_SIGN_COMPARE = YES;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;\n\t\t\t\tGCC_WARN_UNKNOWN_PRAGMAS = YES;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_LABEL = YES;\n\t\t\t\tGCC_WARN_UNUSED_PARAMETER = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t2D7477A31578162B00412279 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"c++0x\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_COMMA = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_IMPLICIT_SIGN_CONVERSION = NO;\n\t\t\t\tCLANG_WARN_INFINITE_RECURSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;\n\t\t\t\tCLANG_WARN_OBJC_LITERAL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;\n\t\t\t\tCLANG_WARN_RANGE_LOOP_ANALYSIS = YES;\n\t\t\t\tCLANG_WARN_STRICT_PROTOTYPES = YES;\n\t\t\t\tCLANG_WARN_SUSPICIOUS_MOVE = YES;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\tCLANG_WARN__EXIT_TIME_DESTRUCTORS = YES;\n\t\t\t\tDEAD_CODE_STRIPPING = YES;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tENABLE_TESTABILITY = YES;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;\n\t\t\t\tGCC_WARN_ABOUT_MISSING_NEWLINE = YES;\n\t\t\t\tGCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;\n\t\t\t\tGCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;\n\t\t\t\tGCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;\n\t\t\t\tGCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;\n\t\t\t\tGCC_WARN_SHADOW = YES;\n\t\t\t\tGCC_WARN_SIGN_COMPARE = YES;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;\n\t\t\t\tGCC_WARN_UNKNOWN_PRAGMAS = YES;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_LABEL = YES;\n\t\t\t\tGCC_WARN_UNUSED_PARAMETER = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tONLY_ACTIVE_ARCH = YES;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t2D7477A41578164E00412279 /* Debug-Opt */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"c++0x\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_COMMA = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_IMPLICIT_SIGN_CONVERSION = NO;\n\t\t\t\tCLANG_WARN_INFINITE_RECURSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;\n\t\t\t\tCLANG_WARN_OBJC_LITERAL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;\n\t\t\t\tCLANG_WARN_RANGE_LOOP_ANALYSIS = YES;\n\t\t\t\tCLANG_WARN_STRICT_PROTOTYPES = YES;\n\t\t\t\tCLANG_WARN_SUSPICIOUS_MOVE = YES;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\tCLANG_WARN__EXIT_TIME_DESTRUCTORS = YES;\n\t\t\t\tDEAD_CODE_STRIPPING = YES;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tENABLE_TESTABILITY = YES;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_OPTIMIZATION_LEVEL = s;\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;\n\t\t\t\tGCC_WARN_ABOUT_MISSING_NEWLINE = YES;\n\t\t\t\tGCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;\n\t\t\t\tGCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;\n\t\t\t\tGCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;\n\t\t\t\tGCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;\n\t\t\t\tGCC_WARN_SHADOW = YES;\n\t\t\t\tGCC_WARN_SIGN_COMPARE = YES;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;\n\t\t\t\tGCC_WARN_UNKNOWN_PRAGMAS = YES;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_LABEL = YES;\n\t\t\t\tGCC_WARN_UNUSED_PARAMETER = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tONLY_ACTIVE_ARCH = YES;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = \"Debug-Opt\";\n\t\t};\n\t\t3D88D490285BBA5800629399 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ANALYZER_NONNULL = YES;\n\t\t\t\tCLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++17\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_WEAK = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_DOCUMENTATION_COMMENTS = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;\n\t\t\t\tCODE_SIGN_STYLE = Automatic;\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tDEVELOPMENT_TEAM = Q5C99V536K;\n\t\t\t\tENABLE_HARDENED_RUNTIME = YES;\n\t\t\t\tENABLE_NS_ASSERTIONS = NO;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu11;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 12.3;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = NO;\n\t\t\t\tMTL_FAST_MATH = YES;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t3D88D491285BBA5800629399 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ANALYZER_NONNULL = YES;\n\t\t\t\tCLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++17\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_WEAK = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_DOCUMENTATION_COMMENTS = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;\n\t\t\t\tCODE_SIGN_STYLE = Automatic;\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;\n\t\t\t\tDEVELOPMENT_TEAM = Q5C99V536K;\n\t\t\t\tENABLE_HARDENED_RUNTIME = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu11;\n\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"DEBUG=1\",\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t);\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 12.3;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;\n\t\t\t\tMTL_FAST_MATH = YES;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t3D88D492285BBA5800629399 /* Debug-Opt */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ANALYZER_NONNULL = YES;\n\t\t\t\tCLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++17\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_WEAK = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_DOCUMENTATION_COMMENTS = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;\n\t\t\t\tCODE_SIGN_STYLE = Automatic;\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;\n\t\t\t\tDEVELOPMENT_TEAM = Q5C99V536K;\n\t\t\t\tENABLE_HARDENED_RUNTIME = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu11;\n\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"DEBUG=1\",\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t);\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 12.3;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;\n\t\t\t\tMTL_FAST_MATH = YES;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t};\n\t\t\tname = \"Debug-Opt\";\n\t\t};\n\t\t3D89664A2849C318002AB3F0 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ENABLE_OBJC_WEAK = YES;\n\t\t\t\tDEVELOPMENT_TEAM = Q5C99V536K;\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"DEBUG=0\",\n\t\t\t\t);\n\t\t\t\tINFOPLIST_FILE = BlackHole/BlackHole.plist;\n\t\t\t\tINSTALL_PATH = \"$(LOCAL_LIBRARY_DIR)/Audio/Plug-Ins/HAL\";\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 10.10;\n\t\t\t\tMARKETING_VERSION = 0.6.1;\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = audio.existential.BlackHole;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tWRAPPER_EXTENSION = driver;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t3D89664B2849C318002AB3F0 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ENABLE_OBJC_WEAK = YES;\n\t\t\t\tDEVELOPMENT_TEAM = Q5C99V536K;\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"DEBUG=1\",\n\t\t\t\t);\n\t\t\t\tINFOPLIST_FILE = BlackHole/BlackHole.plist;\n\t\t\t\tINSTALL_PATH = \"$(LOCAL_LIBRARY_DIR)/Audio/Plug-Ins/HAL\";\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 10.10;\n\t\t\t\tMARKETING_VERSION = 0.6.1;\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = audio.existential.BlackHole;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tWRAPPER_EXTENSION = driver;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t3D89664C2849C318002AB3F0 /* Debug-Opt */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ENABLE_OBJC_WEAK = YES;\n\t\t\t\tDEVELOPMENT_TEAM = Q5C99V536K;\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"DEBUG=1\",\n\t\t\t\t);\n\t\t\t\tINFOPLIST_FILE = BlackHole/BlackHole.plist;\n\t\t\t\tINSTALL_PATH = \"$(LOCAL_LIBRARY_DIR)/Audio/Plug-Ins/HAL\";\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 10.10;\n\t\t\t\tMARKETING_VERSION = 0.6.1;\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = audio.existential.BlackHole;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tWRAPPER_EXTENSION = driver;\n\t\t\t};\n\t\t\tname = \"Debug-Opt\";\n\t\t};\n/* End XCBuildConfiguration section */\n\n/* Begin XCConfigurationList section */\n\t\t2D7477A01578162B00412279 /* Build configuration list for PBXProject \"BlackHole\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t2D7477A21578162B00412279 /* Release */,\n\t\t\t\t2D7477A31578162B00412279 /* Debug */,\n\t\t\t\t2D7477A41578164E00412279 /* Debug-Opt */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t3D88D493285BBA5800629399 /* Build configuration list for PBXNativeTarget \"BlackHoleTests\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t3D88D490285BBA5800629399 /* Release */,\n\t\t\t\t3D88D491285BBA5800629399 /* Debug */,\n\t\t\t\t3D88D492285BBA5800629399 /* Debug-Opt */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t3D8966492849C318002AB3F0 /* Build configuration list for PBXNativeTarget \"BlackHole\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t3D89664A2849C318002AB3F0 /* Release */,\n\t\t\t\t3D89664B2849C318002AB3F0 /* Debug */,\n\t\t\t\t3D89664C2849C318002AB3F0 /* Debug-Opt */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n/* End XCConfigurationList section */\n\t};\n\trootObject = 2D74779D1578162B00412279 /* Project object */;\n}\n"
  },
  {
    "path": "BlackHole.xcodeproj/project.xcworkspace/contents.xcworkspacedata",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n   version = \"1.0\">\n   <FileRef\n      location = \"self:\">\n   </FileRef>\n</Workspace>\n"
  },
  {
    "path": "BlackHole.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>IDEDidComputeMac32BitWarning</key>\n\t<true/>\n</dict>\n</plist>\n"
  },
  {
    "path": "BlackHole.xcodeproj/xcshareddata/xcschemes/BlackHole.xcscheme",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n   LastUpgradeVersion = \"1340\"\n   version = \"1.3\">\n   <BuildAction\n      parallelizeBuildables = \"YES\"\n      buildImplicitDependencies = \"YES\">\n      <BuildActionEntries>\n         <BuildActionEntry\n            buildForTesting = \"YES\"\n            buildForRunning = \"YES\"\n            buildForProfiling = \"YES\"\n            buildForArchiving = \"YES\"\n            buildForAnalyzing = \"YES\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"3D89663D2849C318002AB3F0\"\n               BuildableName = \"BlackHole.driver\"\n               BlueprintName = \"BlackHole\"\n               ReferencedContainer = \"container:BlackHole.xcodeproj\">\n            </BuildableReference>\n         </BuildActionEntry>\n      </BuildActionEntries>\n   </BuildAction>\n   <TestAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\">\n      <Testables>\n      </Testables>\n   </TestAction>\n   <LaunchAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      launchStyle = \"0\"\n      useCustomWorkingDirectory = \"NO\"\n      ignoresPersistentStateOnLaunch = \"NO\"\n      debugDocumentVersioning = \"YES\"\n      debugServiceExtension = \"internal\"\n      allowLocationSimulation = \"YES\">\n   </LaunchAction>\n   <ProfileAction\n      buildConfiguration = \"Release\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\"\n      savedToolIdentifier = \"\"\n      useCustomWorkingDirectory = \"NO\"\n      debugDocumentVersioning = \"YES\">\n      <MacroExpansion>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"3D89663D2849C318002AB3F0\"\n            BuildableName = \"BlackHole.driver\"\n            BlueprintName = \"BlackHole\"\n            ReferencedContainer = \"container:BlackHole.xcodeproj\">\n         </BuildableReference>\n      </MacroExpansion>\n   </ProfileAction>\n   <AnalyzeAction\n      buildConfiguration = \"Debug\">\n   </AnalyzeAction>\n   <ArchiveAction\n      buildConfiguration = \"Release\"\n      revealArchiveInOrganizer = \"YES\">\n   </ArchiveAction>\n</Scheme>\n"
  },
  {
    "path": "BlackHoleTests/main.c",
    "content": "//\n//  main.cpp\n//  BlackHoleTests\n//\n//  Created by Devin Roth on 2022-06-16.\n//\n\n#include <stdio.h>\n\n\n#define kDevice_HasInput false\n#define kDevice_HasOutput true\n\n#include \"../BlackHole/BlackHole.c\"\n\n\n\nint main(int argc, const char * argv[]) {\n    \n#pragma unused(argc, argv)\n    // insert code here...\n    \n    UInt32 size;\n    UInt32* data;\n    AudioObjectPropertyAddress address;\n    \n    // Owned Objects\n    address.mSelector = kAudioObjectPropertyOwnedObjects;\n    address.mScope = kAudioObjectPropertyScopeGlobal;\n    assert(BlackHole_HasProperty(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address));\n\n    BlackHole_GetPropertyDataSize(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, &size);\n    assert(size == 12);\n    \n    address.mScope = kAudioObjectPropertyScopeInput;\n    BlackHole_GetPropertyDataSize(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, &size);\n    assert(size == 0);\n    \n    data = calloc(size, 1);\n    BlackHole_GetPropertyData(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, size, &size, data);\n    assert(data[0] == 0);\n    free(data);\n    \n    address.mScope = kAudioObjectPropertyScopeOutput;\n    BlackHole_GetPropertyDataSize(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, &size);\n    assert(size == 12);\n    \n    data = calloc(size, 1);\n    BlackHole_GetPropertyData(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, size, &size, data);\n    assert(data[0] == 7);\n    assert(data[1] == 8);\n    assert(data[2] == 9);\n    free(data);\n    \n    // Streams\n    address.mSelector = kAudioDevicePropertyStreams;\n    address.mScope = kAudioObjectPropertyScopeGlobal;\n    assert(BlackHole_HasProperty(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address));\n\n    BlackHole_GetPropertyDataSize(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, &size);\n    assert(size == 4);\n    \n    address.mScope = kAudioObjectPropertyScopeInput;\n    BlackHole_GetPropertyDataSize(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, &size);\n    assert(size == 0);\n    \n    data = calloc(size, 1);\n    BlackHole_GetPropertyData(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, size, &size, data);\n    assert(data[0] == 0);\n    free(data);\n    \n    address.mScope = kAudioObjectPropertyScopeOutput;\n    BlackHole_GetPropertyDataSize(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, &size);\n    assert(size == 4);\n    \n    data = calloc(size, 1);\n    BlackHole_GetPropertyData(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, size, &size, data);\n    assert(data[0] == 7);\n    free(data);\n    \n    \n    // Controls\n    address.mSelector = kAudioClockDevicePropertyControlList;\n    address.mScope = kAudioObjectPropertyScopeGlobal;\n    assert(BlackHole_HasProperty(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address));\n\n    BlackHole_GetPropertyDataSize(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, &size);\n    assert(size == 8);\n    \n    address.mScope = kAudioObjectPropertyScopeInput;\n    BlackHole_GetPropertyDataSize(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, &size);\n    assert(size == 0);\n    \n    data = calloc(size, 1);\n    BlackHole_GetPropertyData(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, size, &size, data);\n    assert(data[0] == 0);\n    free(data);\n    \n    address.mScope = kAudioObjectPropertyScopeOutput;\n    BlackHole_GetPropertyDataSize(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, &size);\n    assert(size == 8);\n    \n    data = calloc(size, 1);\n    BlackHole_GetPropertyData(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, size, &size, data);\n    assert(data[0] == 8);\n    assert(data[1] == 9);\n    free(data);\n\n    \n\n    \n    return 0;\n}\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "#  BlackHole Changelog\n\nAll notable changes to this project will be documented in this file.\n\nThe format is based on [Keep a Changelog](http://keepachangelog.com/en/1.1.0/)\nand this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).\n\n### Feature Requests\n\n- Add support for additional virtual formats. 24-bit, 16-bit.\n- Sync BlackHole audio clock with any audio device.\n- Create multi-output / aggregate device with installer.\n- Keep track of which apps are connected to the driver.\n\n\n## [Unreleased]\n\n### Changed\n\n## [0.6.1] - 2025-02-06\n- Updated installer to force a computer reboot as recommended by Apple.\n- Updated create_installer.sh script.\n\n### Changed \n\n\n## [0.6.0] - 2024-03-22\n\n## Added\n- Added precompiler constant for kCanBeDefaultDevice and kCanBeDefaultSystemDevice.\n\n## Changed\n- Updated postinstall script to use 'kill' instead of 'kickstart'.\n- Updated strings for model name, \n\n\n## [0.5.1] - 2023-11-06\n\n### Changed\n\n- Improved installer build script.\n- Bumped minimum required operating system to macOS 10.10 Yosemite.\n- Update kAudioDevicePropertyDeviceIsRunning separately for device1 and device2\n\n## [0.5.0] - 2023-02-10\n\n### Changed\n\n- Various typo fixes.\n\n### Added\n\n- kObjectID_Pitch_Adjust and kObjectID_ClockSource to adjust clock speed.\n\n## [0.4.1] - 2023-02-10\n\n### Changed\n\n- Merged BlackHole.h into BlackHole.c for easier testing.\n- Fixed control size bugs.\n\n### Added\n\n- Added BlackHoleTests target and relevant files.\n\n## [0.4.0] - 2021-06-10\n\n### Added\n\n- Hidden duplicate device.\n- Ability to easily modify device streams. \n- Builds multiple versions.\n- create_installer.sh to easily build multiple channel versions. \n\n### Changed\n\n- Fix potential memory leak.\n- Fix dropouts when experiencing minor loads. \n\n## [0.3.0] - 2021-12-07\n\n### Added\n\n- Sample rates: 8kHz, 16kHz, 352.8kHz, 384kHz, 705.6kHz, 768kHz.\n\n### Changed\n\n- Improved performance.\n- Fixed various bugs.\n- Renamed constants and variables for consistency.\n- Connect input and output volume.\n- Connect input and output mute. \n\n## [0.2.10] - 2021-08-21\n\n### Changed\n\n- Increased internal buffer size.\n- Change kDataSource_NumberItems to zero.\n\n## [0.2.9] - 2021-1-27\n\n### Changed\n\n- Fix clock bug. Fixes issues with BlackHole crashing on Apple Silicon.\n\n## [0.2.8] - 2020-12-26\n\n### Added\n\n- Support for Apple Silicon.\n\n### Changed\n\n- Set deployment target to macOS 10.9. \n- Fixed bug where there is a loud pop when audio starts.\n- Fix bug that caused crashes in certain situations. (Issue #206)\n- Disable Volume and Mute controls on input. They are only needed on the output. \n- Fix clock bug.\n- Automatically change UIDs to include the number of channels. Makes it easier to build and install multiple versions. Ex: BlackHole2ch_UID\n\n## [0.2.7] - 2020-08-08\n\n### Changed\n\n- Improved Logarithmic Volume Control.\n- Various updates to README. \n\n### Added\n\n- Added IOMutex to IO operations.\n\n## [0.2.6] - 2020-02-09\n\n### Changed\n\n- Fixed BlackHole buffer allocation error when switching audio devices from DAW.\n- Fixed BlackHole buffer allocation error when sleeping.\n- Audio Midi Setup speaker configuration now saves preferences.\n\n## [0.2.5] - 2019-11-29\n\n### Changed\n\n- Set default volume to 1.0.\n\n## [0.2.4] - 2019-11-28\n\n### Added\n\n- Ability to mute and changed volume on input and out of BlackHole. \n\n## [0.2.3] - 2019-11-22\n\n### Changed\n\n- Display number of channels in audio source name.\n\n## [0.2.2] - 2019-10-02\n\n### Fixed\n\n- Fixed bugs when multiple devices are reading and writing simultaneously.\n\n## [0.2.1] - 2019-09-30\n\n### Changed\n\n- Set deployment target to macOS 10.10 to include Yosemite and Sierra\n\n## [0.2.0] - 2019-09-29\n\n### Added\n\n- Support for 88.2kHz, 96kHz, 176.4kHz and 192kHz.\n- Sums audio from multiple sources.\n- Changelog.\n- Device Icon.\n\n## [0.1.0] - 2019-09-27\n\n### Added\n\n- Ability to pass audio between applications.\n- Support for 16 channels of audio.\n- Support for 44.1kHz and 48kHz.\n"
  },
  {
    "path": "Installer/conclusion.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n\t<title></title>\n</head>\n<body>\n\t<h1>BlackHole: Audio Loopback Driver</h1>\n\n\t<h2>Donate</h2>\n\t<p>If you find this software useful please <a href=\"https://github.com/sponsors/ExistentialAudio\">sponsor Existential Audio on GitHub.</a></p>\n\n\t<h2>Help and Support</h2>\n\t<p>Visit the <a href=\"https://existential.audio/blackhole/support/\">BlackHole Help and Support</a> page for help and guides.</p>\n\n\t<h2>FAQ</h2>\n\t<h3>Where is BlackHole located?</h3>\n\t<p>BlackHole is an audio driver. You can find it in Audio MIDI Setup and within audio applications.</p>\n\n\t<h3>How can I listen to the audio and use BlackHole at the same time?</h3>\n\t<p><a href=\"https://github.com/ExistentialAudio/BlackHole/wiki/Multi-Output-Device\">Set up a Multi-Output Device</a>.</p>\n\n\t<h3>Why is nothing audible through BlackHole?</h3>\n\t<p>\n\t<ul>\n\t\t<li>Check System Preferences -> Security & Privacy -> Microphone to make sure your audio application has microphone access.</li>\n\t\t<li>Check that the volume is all the way up on BlackHole output in Audio MIDI Setup.</li>\n\t\t<li>If you are using a Multi-Output Device, due to issues with macOS a 2ch audio driver must be enabled and listed as the top device in the Multi-Output.</li>\n\t</ul>\n\t</p>\n\t<h3>How do I uninstall BlackHole?</h3>\n\t<p>You can download the uninstaller from the <a href=\"https://existential.audio/blackhole/support/\">BlackHole Help and Support</a> page.</p>\n</body>\n</html>"
  },
  {
    "path": "Installer/create_installer.sh",
    "content": "#!/usr/bin/env sh\nset -euo pipefail\n\n# Creates installer for different channel versions.\n# Run this script from the local BlackHole repo's root directory.\n# If this script is not executable from the Terminal, \n# it may need execute permissions first by running this command:\n#   chmod +x create_installer.sh\n\ndriverName=\"BlackHole\"\ndevTeamID=\"Q5C99V536K\" # ⚠️ Replace this with your own developer team ID\nnotarize=true # To skip notarization, set this to false\nnotarizeProfile=\"notarize\" # ⚠️ Replace this with your own notarytool keychain profile name\n\n############################################################################\n\n# Basic Validation\nif [ ! -d BlackHole.xcodeproj ]; then\n    echo \"This script must be run from the BlackHole repo root folder.\"\n    echo \"For example:\"\n    echo \"  cd /path/to/BlackHole\"\n    echo \"  ./Installer/create_installer.sh\"\n    exit 1\nfi\n\nversion=`cat VERSION`\n\n#Version Validation6\nif [ -z \"$version\" ]; then\n    echo \"Could not find version number. VERSION file is missing from repo root or is empty.\"\n    exit 1\nfi\n\nfor channels in 2 16 64 128 256; do\n    # Env\n    ch=$channels\"ch\"\n    driverVartiantName=$driverName$ch\n    bundleID=\"audio.existential.$driverVartiantName\"\n    \n    # Build\n    xcodebuild \\\n      -project BlackHole.xcodeproj \\\n      -configuration Release \\\n      -target BlackHole CONFIGURATION_BUILD_DIR=build \\\n      PRODUCT_BUNDLE_IDENTIFIER=$bundleID \\\n      GCC_PREPROCESSOR_DEFINITIONS='$GCC_PREPROCESSOR_DEFINITIONS \n      kNumber_Of_Channels='$channels' \n      kPlugIn_BundleID=\\\"'$bundleID'\\\" \n      kDriver_Name=\\\"'$driverName'\\\"'\n    \n    # Generate a new UUID\n    uuid=$(uuidgen)\n    awk '{sub(/e395c745-4eea-4d94-bb92-46224221047c/,\"'$uuid'\")}1' build/BlackHole.driver/Contents/Info.plist > Temp.plist\n    mv Temp.plist build/BlackHole.driver/Contents/Info.plist\n    \n    mkdir Installer/root\n    driverBundleName=$driverVartiantName.driver\n    mv build/BlackHole.driver Installer/root/$driverBundleName\n    rm -r build\n    \n    # Sign\n    codesign \\\n      --force \\\n      --deep \\\n      --options runtime \\\n      --sign $devTeamID \\\n      Installer/root/$driverBundleName\n    \n    # Create package with pkgbuild\n    chmod 755 Installer/Scripts/preinstall\n    chmod 755 Installer/Scripts/postinstall\n    \n    pkgbuild \\\n      --sign $devTeamID \\\n      --root Installer/root \\\n      --scripts Installer/Scripts \\\n      --install-location /Library/Audio/Plug-Ins/HAL \\\n      \"Installer/$driverName.pkg\"\n    rm -r Installer/root\n    \n    # Create installer with productbuild\n    cd Installer\n    \n    echo \"<?xml version=\\\"1.0\\\" encoding='utf-8'?>\n    <installer-gui-script minSpecVersion='2'>\n        <title>$driverName: Audio Loopback Driver ($ch) $version</title>\n        <welcome file='welcome.html'/>\n        <license file='../LICENSE'/>\n        <conclusion file='conclusion.html'/>\n        <domains enable_anywhere='false' enable_currentUserHome='false' enable_localSystem='true'/>\n        <pkg-ref id=\\\"$bundleID\\\"/>\n        <options customize='never' require-scripts='false' hostArchitectures='x86_64,arm64'/>\n        <volume-check>\n            <allowed-os-versions>\n                <os-version min='10.10'/>\n            </allowed-os-versions>\n        </volume-check>\n        <choices-outline>\n            <line choice=\\\"$bundleID\\\"/>\n        </choices-outline>\n        <choice id=\\\"$bundleID\\\" visible='true' title=\\\"$driverName $ch\\\" start_selected='true'>\n            <pkg-ref id=\\\"$bundleID\\\"/>\n        </choice>\n        <pkg-ref id=\\\"$bundleID\\\" version=\\\"$version\\\" onConclusion='RequireRestart'>$driverName.pkg</pkg-ref>\n    </installer-gui-script>\" >> distribution.xml\n    \n    # Build\n    installerPkgName=\"$driverVartiantName-$version.pkg\"\n    productbuild \\\n      --sign $devTeamID \\\n      --distribution distribution.xml \\\n      --resources . \\\n      --package-path $driverName.pkg $installerPkgName\n    rm distribution.xml\n    rm -f $driverName.pkg\n    \n    # Notarize and Staple\n    if [ \"$notarize\" = true ]; then\n        xcrun \\\n          notarytool submit $installerPkgName \\\n          --team-id $devTeamID \\\n          --progress \\\n          --wait \\\n          --keychain-profile $notarizeProfile\n        \n        xcrun stapler staple $installerPkgName\n    fi\n\n    cd ..\ndone"
  },
  {
    "path": "Installer/requirements.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n  <key>os</key>\n  <array>\n    <string>10.10</string>\n  </array>\n</dict>\n</plist>"
  },
  {
    "path": "Installer/scripts/postinstall",
    "content": "#!/bin/sh\n\nsudo chown -R root:wheel /Library/Audio/Plug-Ins/HAL/BlackHole*ch.driver\n"
  },
  {
    "path": "Installer/scripts/preinstall",
    "content": "#!/bin/sh\n\nsudo mkdir -p /Library/Audio/Plug-Ins/HAL\nsudo chown root:wheel /Library/Audio/Plug-Ins/HAL\n"
  },
  {
    "path": "Installer/welcome.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n</head>\n<body>\n\t<h1>BlackHole: Audio Loopback Driver</h1>\n\t<p>BlackHole is a modern macOS virtual audio loopback driver that allows applications to pass audio to other applications with zero additional latency.</p>\n\t<p><font color=\"red\"><b>Please note that a system restart is required to complete the installation.</b></font></p>\n\t<h2>Features</h2>\n\t<ul>\n\t\t<li>Supports 8kHz, 16kHz, 44.1kHz, 48kHz, 88.2kHz, 96kHz, 176.4kHz, 192kHz, 352.8kHz, 384kHz, 705.6kHz and 768kHz sample rates</li>\n\t\t<li>Zero additional driver latency</li>\n\t\t<li>Compatible with macOS 10.10 Yosemite and newer</li>\n\t\t<li>Built for Intel and Apple Silicon</li>\n\t\t<li>No kernel extensions or modifications to system security necessary</li>\n\t</ul>\n</body>\n</html>"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "README.md",
    "content": "![BlackHole: Audio Loopback Driver](Images/blackhole-banner-830px.png)\n\n# BlackHole: Audio Loopback Driver\n\n![Platform: macOS](https://img.shields.io/badge/platform-macOS-lightgrey)\n[![Release](https://img.shields.io/github/v/release/ExistentialAudio/BlackHole)](https://github.com/ExistentialAudio/BlackHole/releases)\n[![License](https://img.shields.io/github/license/ExistentialAudio/BlackHole)](LICENSE)\n[![Twitter](https://img.shields.io/badge/Follow%20on%20Twitter-1da1f2)](https://twitter.com/ExistentialAI)\n[![Facebook](https://img.shields.io/badge/Like%20on%20Facebook-4267B2)](https://www.facebook.com/Existential-Audio-103423234434751)\n\nBlackHole is a modern macOS virtual audio loopback driver that allows applications to pass audio to other applications with zero additional latency.\n\n### [Download Installer](https://existential.audio/blackhole) \n\n### [Join the Discord Server](https://discord.gg/y8BWfnWRnn)\n\n## Sponsors\n\n### Recall.ai - API for desktop recording\n\nIf you’re looking for a desktop recording API, consider checking out [Recall.ai](https://www.recall.ai/product/desktop-recording-sdk?utm_source=github&utm_medium=sponsorship&utm_campaign=existentialaudio-blackhole), an API that records video, audio, and transcripts from Zoom, Google Meet, Microsoft Teams, in-person meetings, and more.\n\nTo sponsor this project visit https://github.com/sponsors/ExistentialAudio\n\n## Table of Contents\n\n- [Features](#features)\n- [Installation Instructions](#installation-instructions)\n- [Uninstallation Instructions](#uninstallation-instructions)\n- [User Guides](#user-guides)\n- [Developer Guides](#developer-guides)\n- [Feature Requests](#feature-requests)\n- [FAQ](#faq)\n- [Wiki](https://github.com/ExistentialAudio/BlackHole/wiki)\n\n## Features\n\n- Builds 2, 16, 64, 128, and 256 audio channels versions\n- Customizable channel count, latency, hidden devices\n- Customizable mirror device to allow for a hidden input or output\n- Supports 8kHz, 16kHz, 44.1kHz, 48kHz, 88.2kHz, 96kHz, 176.4kHz, 192kHz, 352.8kHz, 384kHz, 705.6kHz and 768kHz sample rates\n- Zero additional driver latency\n- Compatible with macOS 10.10 Yosemite and newer\n- Builds for Intel and Apple Silicon\n- No kernel extensions or modifications to system security necessary\n\n![Audio MIDI Setup](Images/audio-midi-setup.png)\n\n## Installation Instructions\n\n### Option 1: Download Installer\n\n1. [Download the latest installer](https://existential.audio/blackhole)\n2. Close all running audio applications\n3. Open and install package\n4. Restart your system when prompted\n\n### Option 2: Install via Homebrew\n\n- 2ch: `brew install blackhole-2ch`\n- 16ch: `brew install blackhole-16ch`\n- 64ch: `brew install blackhole-64ch`\n\n## Uninstallation Instructions\n\n### Option 1: Use Uninstaller\n\n- [Download BlackHole 2ch Uninstaller](https://existential.audio/downloads/BlackHole2chUninstaller.pkg)\n- [Download BlackHole 16ch Uninstaller](https://existential.audio/downloads/BlackHole16chUninstaller.pkg)\n- [Download BlackHole 64ch Uninstaller](https://existential.audio/downloads/BlackHole64chUninstaller.pkg)\n\n### Option 2: Manually Uninstall\n\n1. Delete the BlackHole driver with the terminal command:\n   \n    `rm -R /Library/Audio/Plug-Ins/HAL/BlackHoleXch.driver` \n   \n   Be sure to replace `X` with either `2`, `16`, or `64`.\n   \n   Note that the directory is the root `/Library` not `/Users/user/Library`.\n\n2. Restart CoreAudio with the terminal command:\n\n    `sudo killall -9 coreaudiod`\n\nFor more specific details [visit the Wiki](https://github.com/ExistentialAudio/BlackHole/wiki/Uninstallation).\n\n## User Guides\n\n### Logic Pro X\n\n- [Logic Pro X to FaceTime](https://existential.audio/howto/StreamFromLogicProXtoFaceTime.php)\n- [Logic Pro X to Google Meet](https://existential.audio/howto/StreamFromLogicProXtoGoogleMeet.php)\n- [Logic Pro X to Skype](https://existential.audio/howto/StreamFromLogicProXtoSkype.php)\n- [Logic Pro X to Zoom](https://existential.audio/howto/StreamFromLogicProXtoZoom.php)\n\n### GarageBand\n\n- [GarageBand to FaceTime](https://existential.audio/howto/StreamFromGarageBandToFaceTime.php)\n- [GarageBand to Google Meet](https://existential.audio/howto/StreamFromGarageBandToGoogleMeet.php)\n- [GarageBand to Skype](https://existential.audio/howto/StreamFromGarageBandToSkype.php)\n- [GarageBand to Zoom](https://existential.audio/howto/StreamFromGarageBandToZoom.php)\n\n### Audacity\n\n- [Audacity Setup](https://github.com/ExistentialAudio/BlackHole/wiki/Audacity)\n\n### Reaper\n\n- [Reaper to Zoom](https://noahliebman.net/2020/12/telephone-colophon-or-how-i-overengineered-my-call-audio/) by Noah Liebman\n\n### Record System Audio\n\n1. [Setup Multi-Output Device](https://github.com/ExistentialAudio/BlackHole/wiki/Multi-Output-Device)\n2. In `Audio MIDI Setup` → `Audio Devices` right-click on the newly created Multi-Output and select \"Use This Device For Sound Output\"\n3. Open digital audio workstation (DAW) such as GarageBand and set input device to \"BlackHole\" \n4. Set track to input from channel 1-2\n5. Play audio from another application and monitor or record in your DAW\n\n### Route Audio Between Applications\n\n1. Set output driver to \"BlackHole\" in sending application\n2. Output audio to any channel\n3. Open receiving application and set input device to \"BlackHole\" \n4. Input audio from the corresponding output channels\n\n## Developer Guides\n\n### A license is required for all non-GPLv3 projects\nPlease support our hard work and continued development. To request a license [contact Existential Audio](mailto:devinroth@existential.audio).\n\n### Build & Install\nAfter building, to install BlackHole:\n\n1. Copy or move the built `BlackHoleXch.driver` bundle to `/Library/Audio/Plug-Ins/HAL`\n2. Restart CoreAudio using `sudo killall -9 coreaudiod`\n\n### Customizing BlackHole\n\nThe following pre-compiler constants may be used to easily customize a build of BlackHole.\n\n```\nkDriver_Name\nkPlugIn_BundleID\nkPlugIn_Icon\n\nkDevice_Name\nkDevice_IsHidden\nkDevice_HasInput\nkDevice_HasOutput\n\nkDevice2_Name\nkDevice2_IsHidden\nkDevice2_HasInput\nkDevice2_HasOutput\n\nkLatency_Frame_Size\nkNumber_Of_Channels\nkSampleRates\n```\n\nThey can be specified at build time with `xcodebuild` using `GCC_PREPROCESSOR_DEFINITIONS`. \n\nExample:\n\n```bash\nxcodebuild \\\n  -project BlackHole.xcodeproj \\\n  GCC_PREPROCESSOR_DEFINITIONS='$GCC_PREPROCESSOR_DEFINITIONS kSomeConstant=value'\n```\n\nBe sure to escape any quotation marks when using strings. \n\n### Renaming BlackHole\n\nTo customize BlackHole it is required to change the following constants. \n- `kDriver_Name`\n- `kPlugIn_BundleID` (note that this must match the target bundleID)\n- `kPlugIn_Icon`\n\nThese can specified as pre-compiler constants using ```xcodebuild```.\n\n```bash\ndriverName=\"BlackHole\"\nbundleID=\"audio.existential.BlackHole\"\nicon=\"BlackHole.icns\"\n\nxcodebuild \\\n  -project BlackHole.xcodeproj \\\n  -configuration Release \\\n  PRODUCT_BUNDLE_IDENTIFIER=$bundleID \\\n  GCC_PREPROCESSOR_DEFINITIONS='$GCC_PREPROCESSOR_DEFINITIONS\n  kDriver_Name=\\\"'$driverName'\\\"\n  kPlugIn_BundleID=\\\"'$bundleID'\\\"\n  kPlugIn_Icon=\\\"'$icon'\\\"'\n```\n\n### Customizing Channels, Latency, and Sample Rates\n\n`kNumber_Of_Channels` is used to set the number of channels. Be careful when specifying high channel counts. Although BlackHole is designed to be extremely efficient at higher channel counts it's possible that your computer might not be able to keep up. Sample rates play a role as well. Don't use high sample rates with a high number of channels. Some applications don't know how to handle high channel counts. Proceed with caution.\n\n`kLatency_Frame_Size` is how much time in frames that the driver has to process incoming and outgoing audio. It can be used to delay the audio inside of BlackHole up to a maximum of 65536 frames. This may be helpful if using BlackHole with a high channel count. \n\n`kSampleRates` set the sample rate or sample rates of the audio device. If using multiple sample rates separate each with a comma (`,`). For example: `kSampleRates='44100,48000'`.\n\n### Mirror Device\n\nBy default BlackHole has a hidden mirrored audio device. The devices may be customized using the following constants. \n\n```\n// Original Device\nkDevice_IsHidden\nkDevice_HasInput\nkDevice_HasOutput\n\n// Mirrored Device\nkDevice2_IsHidden\nkDevice2_HasInput\nkDevice2_HasOutput\n```\n\nWhen all are set to true a 2nd BlackHole will show up that works exactly the same. The inputs and outputs are mirrored so the outputs from both devices go to the inputs of both devices.\n\nThis is useful if you need a separate device for input and output.\n\nExample\n\n```\n// Original Device\nkDevice_IsHidden=false\nkDevice_HasInput=true\nkDevice_HasOutput=false\n\n// Mirrored Device\nkDevice2_IsHidden=false\nkDevice2_HasInput=false\nkDevice2_HasOutput=true\n```\n\nIn this situation we have two BlackHole devices. One will have inputs only and the other will have outputs only.\n\nOne way to use this in projects is to hide the mirrored device and use it behind the scenes. That way the user will see an input only device while routing audio through to the output behind them scenes. \n\nHidden audio devices can be accessed using `kAudioHardwarePropertyTranslateUIDToDevice`.\n\n### Continuous Integration / Continuous Deployment\n\nBlackHole can be integrated into your CI/CD. Take a look at the [create_installer.sh](https://github.com/ExistentialAudio/BlackHole/blob/master/Installer/create_installer.sh) shell script to see how the installer is built, signed and notarized.\n\n## Feature Requests\n\nIf you are interested in any of the following features please leave a comment in the linked issue. To request a features not listed please create a new issue.\n\n- [Sync Clock with other Audio Devices](https://github.com/ExistentialAudio/BlackHole/issues/27) in development see v0.3.0\n- [Output Blackhole to other Audio Device](https://github.com/ExistentialAudio/BlackHole/issues/40)\n- [Add Support for AU Plug-ins](https://github.com/ExistentialAudio/BlackHole/issues/18)\n- [Inter-channel routing](https://github.com/ExistentialAudio/BlackHole/issues/13)\n- [Record Directly to File](https://github.com/ExistentialAudio/BlackHole/issues/8)\n- [Configuration Options Menu](https://github.com/ExistentialAudio/BlackHole/issues/7)\n- [Support for Additional Bit Depths](https://github.com/ExistentialAudio/BlackHole/issues/42)\n\n## FAQ\n\n### Why isn't BlackHole showing up in the Applications folder?\n\nBlackHole is a virtual audio loopback driver. It only shows up in `Audio MIDI Setup`, `Sound Preferences`, or other audio applications.\n\n### How can I listen to the audio and use BlackHole at the same time?\n\nSee [Setup a Multi-Output Device](https://github.com/ExistentialAudio/BlackHole/wiki/Multi-Output-Device).\n\n### What bit depth does BlackHole use, and can I change it?\n\nBlackHole uses 32-bit float bit depth since macOS Core Audio natively uses 32-bit at the system level. This provides the broadest compatibility and greatest audio headroom.\n\nThis format is lossless for up to 24-bit integer. All applications should be able to playback and record audio, and do not require adjusting bit depth at the BlackHole driver level.\n\n### How can I change the volume of a Multi-Output device?\n\nUnfortunately macOS does not support changing the volume of a Multi-Output device but you can set the volume of individual devices in Audio MIDI Setup. \n\n### Why is nothing playing through BlackHole? \n\n- Check `System Preferences` → `Security & Privacy` → `Privacy` → `Microphone` to make sure your digital audio workstation (DAW) application has microphone access. \n\n- Check that the volume is all the way up on BlackHole input and output in ``Audio MIDI Setup``.\n\n- If you are using a multi-output device, due to issues with macOS the Built-in Output must be enabled and listed as the top device in the Multi-Output. [See here for details](https://github.com/ExistentialAudio/BlackHole/wiki/Multi-Output-Device#4-select-output-devices).\n\n### Why is audio glitching after X minutes when using a multi-output or an aggregate?\n\n- You need to enable drift correction for all devices except the Clock Source also known as Master Device or Primary Device.\n\n### Why is the Installer failing?\n\n- Certain versions of macOS have a known issue where install packages may fail to install when the install package is located in certain folders. If you downloaded the .pkg file to your Downloads folder, try moving it to the Desktop and open the .pkg again (or vice-versa).\n\n### What Apps Don't Work with Multi-Outputs?\n\nUnfortunately multi-outputs can be buggy and some apps won't work with them at all. Here is a list of known ones. If additional incompatible applications are found, please report them by opening an [issue](https://github.com/ExistentialAudio/BlackHole/issues).\n\n- Apple Podcasts\n- Apple Messages\n- HDHomeRun\n\n### AirPods with an Aggregate/Multi-Output is not working.\n\nThe microphone from AirPods runs at a lower sample rate which means it should not be used as the primary/clock device in an Aggregate or Multi-Output device. The solution is to use your built-in speakers (and just mute them) or BlackHole 2ch as the primary/clock device. BlackHole 16ch will not work as the primary since the primary needs to have 2ch. \n\nRead [this discussion](https://github.com/ExistentialAudio/BlackHole/issues/146) for more details.\n\n### Can I integrate BlackHole into my app?\n\nBlackHole is licensed under GPL-3.0. You can use BlackHole as long as your app is also licensed as GPL-3.0. For all other applications please [contact Existential Audio directly](mailto:devinroth@existential.audio).\n\n## Links and Resources\n### [MultiSoundChanger](https://github.com/rlxone/MultiSoundChanger)\nA small tool for changing sound volume even for aggregate devices cause native sound volume controller can't change volume of aggregate devices\n### [BackgroundMusic](https://github.com/kyleneideck/BackgroundMusic)\nBackground Music, a macOS audio utility: automatically pause your music, set individual apps' volumes and record system audio.\n\n"
  },
  {
    "path": "Uninstaller/Scripts/postinstall",
    "content": "#!/bin/bash\n\nfile=\"/Library/Audio/Plug-Ins/HAL/BlackHole256ch.driver\"\n\nif [ -d \"$file\" ] ; then\n    sudo rm -R \"$file\"\n    sudo killall coreaudiod\nfi\n"
  },
  {
    "path": "Uninstaller/create_uninstaller.sh",
    "content": "#!/bin/bash\nset -euo pipefail\n\ndevTeamID=\"Q5C99V536K\" # ⚠️ Replace this with your own developer team ID\nnotarize=true # To skip notarization, set this to false\nnotarizeProfile=\"notarize\" # ⚠️ Replace this with your own notarytool keychain profile name\n\n# Basic Validation\nif [ ! -d BlackHole.xcodeproj ]; then\n    echo \"This script must be run from the BlackHole repo root folder.\"\n    echo \"For example:\"\n    echo \"  cd /path/to/BlackHole\"\n    echo \"  ./Uninstaller/create_uninstaller.sh\"\n    exit 1\nfi\n\nfor channels in 2 16 64 128 256; do\n\n\t# create script\n\techo \\\n\t'#!/bin/bash\n\nfile=\"/Library/Audio/Plug-Ins/HAL/BlackHole'$channels'ch.driver\"\n\nif [ -d \"$file\" ] ; then\n    sudo rm -R \"$file\"\n    sudo killall coreaudiod\nfi' > Uninstaller/Scripts/postinstall\n\n\tchmod 755 Uninstaller/Scripts/postinstall\n\n\t# Build .pkg\n    packageName='Uninstaller/BlackHole'$channels'ch-Uninstaller.pkg'\n\n    pkgbuild --nopayload --scripts Uninstaller/Scripts --sign $devTeamID --identifier 'audio.existential.BlackHole'$channels'ch.Uninstaller' $packageName\n\n    # Notarize and Staple\n    if [ \"$notarize\" = true ]; then\n\n        # Submit the package for notarization and capture output, also displaying it simultaneously\n        output=$(xcrun notarytool submit \"$packageName\" --progress --wait --keychain-profile \"notarize\" 2>&1 | tee /dev/tty)\n\n        # Extract the submission ID\n        submission_id=$(echo \"$output\" | grep -o -E 'id: [a-f0-9-]+' | awk '{print $2}' | head -n1)\n\n        if [ -z \"$submission_id\" ]; then\n          echo \"Failed to extract submission ID. ❌\"\n          exit 1\n        fi\n\n        # Check the captured output for the \"status: Invalid\" indicator\n        if echo \"$output\" | grep -q \"status: Invalid\"; then\n          echo \"Error detected during notarization: Submission Invalid ❌\"\n\n          # Fetch and display notarization logs\n          echo -e \"\\nFetching logs for submission ID: $submission_id\"\n          xcrun notarytool log --keychain-profile \"notarize\" \"$submission_id\"\n          exit 1\n        else\n          echo \"Notarization submitted successfully ✅\"\n        fi\n\n        xcrun stapler staple $packageName\n    fi\n\ndone\n\nrm Uninstaller/Scripts/postinstall\n"
  },
  {
    "path": "VERSION",
    "content": "0.6.1\n"
  }
]