this repo has no description
at fixPythonPipStalling 98 lines 3.3 kB view raw
1/* 2This file is part of Darling. 3 4Copyright (C) 2020 Lubos Dolezel 5 6Darling is free software: you can redistribute it and/or modify 7it under the terms of the GNU General Public License as published by 8the Free Software Foundation, either version 3 of the License, or 9(at your option) any later version. 10 11Darling is distributed in the hope that it will be useful, 12but WITHOUT ANY WARRANTY; without even the implied warranty of 13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14GNU General Public License for more details. 15 16You should have received a copy of the GNU General Public License 17along with Darling. If not, see <http://www.gnu.org/licenses/>. 18*/ 19 20#ifndef _AT_AUDIO_COMPONENT_MANAGER_H 21#define _AT_AUDIO_COMPONENT_MANAGER_H 22#include <AudioToolbox/AudioComponent.h> 23#include <CoreFoundation/CFBundle.h> 24#include <mutex> 25#include <unordered_map> 26#include <stdint.h> 27#include <string> 28#include <memory> 29#include <vector> 30 31class __attribute__((visibility("hidden"))) AudioComponentManager 32{ 33private: 34 AudioComponentManager(); 35 void discoverComponents(); 36 void discoverComponents(const char* dir); 37 void analyzeComponent(CFBundleRef bundle); 38 39 static CFBundleRef bundleFromPath(const char* path); 40 41 struct RegisteredComponent 42 { 43 AudioComponent id; 44 AudioComponentDescription desc; 45 std::string name; 46 uint32_t version; 47 AudioComponentFactoryFunction factory; 48 AudioComponentFlags flags = 0; 49 50 CFBundleRef loadedBundle = nullptr; 51 std::string bundlePath, entryPointName; 52 53 int instances = 0; 54 }; 55 56 RegisteredComponent* getById(AudioComponent component); 57public: 58 static AudioComponentManager* instance(); 59 // Returns true if it looks like an instance managed by this class. 60 // False means it is probably managed by the Carbon Component Manager. 61 static bool isOurInstance(AudioComponentInstance instance); 62 static bool isOurInstance(AudioComponent component); 63 64 AudioComponent registerComponent(const AudioComponentDescription* desc, const char* name, 65 uint32_t version, AudioComponentFactoryFunction factory); 66 AudioComponent registerComponent(const AudioComponentDescription* desc, const char* name, 67 uint32_t version, const char* bundlePath, const char* entryPointName, AudioComponentFlags flags); 68 69 OSStatus instantiate(AudioComponent c, AudioComponentInstance* out); 70 OSStatus dispose(AudioComponentInstance instance); 71 72 AudioComponentPlugInInterface* instanceInterface(AudioComponentInstance instance); 73 74 std::vector<AudioComponent> findMatching(const AudioComponentDescription* cd); 75 76 OSStatus getDescription(AudioComponent c, AudioComponentDescription* out); 77 OSStatus getName(AudioComponent c, const char** name); 78 OSStatus getVersion(AudioComponent c, uint32_t* version); 79 80 AudioComponent getComponent(AudioComponentInstance instance); 81private: 82 83 std::unordered_map<AudioComponent, RegisteredComponent> m_components; 84 uint32_t m_nextComponentId = 0x4000 | 0x80000000; 85 std::recursive_mutex m_componentsMutex; 86 87 struct ComponentInstanceData 88 { 89 AudioComponent component; 90 AudioComponentPlugInInterface* object; 91 }; 92 93 std::unordered_map<AudioComponentInstance, ComponentInstanceData> m_componentInstances; 94 uint32_t m_nextComponentInstanceId = 0x1000 | 0x80000000; 95 std::recursive_mutex m_componentInstancesMutex; 96}; 97 98#endif