main.c (3911B)
1 // 2 // main.cpp 3 // BlackHoleTests 4 // 5 // Created by Devin Roth on 2022-06-16. 6 // 7 8 #include <stdio.h> 9 10 11 #define kDevice_HasInput false 12 #define kDevice_HasOutput true 13 14 #include "../BlackHole/BlackHole.c" 15 16 17 18 int main(int argc, const char * argv[]) { 19 20 #pragma unused(argc, argv) 21 // insert code here... 22 23 UInt32 size; 24 UInt32* data; 25 AudioObjectPropertyAddress address; 26 27 // Owned Objects 28 address.mSelector = kAudioObjectPropertyOwnedObjects; 29 address.mScope = kAudioObjectPropertyScopeGlobal; 30 assert(BlackHole_HasProperty(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address)); 31 32 BlackHole_GetPropertyDataSize(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, &size); 33 assert(size == 12); 34 35 address.mScope = kAudioObjectPropertyScopeInput; 36 BlackHole_GetPropertyDataSize(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, &size); 37 assert(size == 0); 38 39 data = calloc(size, 1); 40 BlackHole_GetPropertyData(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, size, &size, data); 41 assert(data[0] == 0); 42 free(data); 43 44 address.mScope = kAudioObjectPropertyScopeOutput; 45 BlackHole_GetPropertyDataSize(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, &size); 46 assert(size == 12); 47 48 data = calloc(size, 1); 49 BlackHole_GetPropertyData(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, size, &size, data); 50 assert(data[0] == 7); 51 assert(data[1] == 8); 52 assert(data[2] == 9); 53 free(data); 54 55 // Streams 56 address.mSelector = kAudioDevicePropertyStreams; 57 address.mScope = kAudioObjectPropertyScopeGlobal; 58 assert(BlackHole_HasProperty(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address)); 59 60 BlackHole_GetPropertyDataSize(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, &size); 61 assert(size == 4); 62 63 address.mScope = kAudioObjectPropertyScopeInput; 64 BlackHole_GetPropertyDataSize(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, &size); 65 assert(size == 0); 66 67 data = calloc(size, 1); 68 BlackHole_GetPropertyData(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, size, &size, data); 69 assert(data[0] == 0); 70 free(data); 71 72 address.mScope = kAudioObjectPropertyScopeOutput; 73 BlackHole_GetPropertyDataSize(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, &size); 74 assert(size == 4); 75 76 data = calloc(size, 1); 77 BlackHole_GetPropertyData(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, size, &size, data); 78 assert(data[0] == 7); 79 free(data); 80 81 82 // Controls 83 address.mSelector = kAudioClockDevicePropertyControlList; 84 address.mScope = kAudioObjectPropertyScopeGlobal; 85 assert(BlackHole_HasProperty(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address)); 86 87 BlackHole_GetPropertyDataSize(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, &size); 88 assert(size == 8); 89 90 address.mScope = kAudioObjectPropertyScopeInput; 91 BlackHole_GetPropertyDataSize(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, &size); 92 assert(size == 0); 93 94 data = calloc(size, 1); 95 BlackHole_GetPropertyData(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, size, &size, data); 96 assert(data[0] == 0); 97 free(data); 98 99 address.mScope = kAudioObjectPropertyScopeOutput; 100 BlackHole_GetPropertyDataSize(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, &size); 101 assert(size == 8); 102 103 data = calloc(size, 1); 104 BlackHole_GetPropertyData(gAudioServerPlugInDriverRef, kObjectID_Device, 0, &address, 0, NULL, size, &size, data); 105 assert(data[0] == 8); 106 assert(data[1] == 9); 107 free(data); 108 109 110 111 112 return 0; 113 }