this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

CoreAudio: Add DefaultOutputAU, fix some bugs

+106 -4
+6 -2
src/CoreAudio/AudioToolbox/AudioComponentManager.mm
··· 72 72 static UInt32 stringToFourCC(CFStringRef str) 73 73 { 74 74 union { 75 - char chars[4]; 75 + char chars[5]; // CFStringGetCString requires space for the NUL character 76 76 uint32_t code; 77 77 } cc; 78 78 79 79 if (CFStringGetLength(str) != 4) 80 80 return 0; 81 - if (!CFStringGetCString(str, cc.chars, 4, kCFStringEncodingUTF8)) 81 + if (!CFStringGetCString(str, cc.chars, 5, kCFStringEncodingUTF8)) 82 82 return 0; 83 + 84 + #if __LITTLE_ENDIAN__ 85 + cc.code = __builtin_bswap32(cc.code); 86 + #endif 83 87 84 88 return cc.code; 85 89 }
+1
src/CoreAudio/CoreAudioComponent/CMakeLists.txt
··· 29 29 PublicUtility/CAVectorUnit.cpp 30 30 AUHAL.cpp 31 31 SystemOutputAU.cpp 32 + DefaultOutputAU.cpp 32 33 ) 33 34 34 35 add_darling_bundle(CoreAudioComponent "" ${component_sources})
+54
src/CoreAudio/CoreAudioComponent/DefaultOutputAU.cpp
··· 1 + /* 2 + This file is part of Darling. 3 + 4 + Copyright (C) 2020 Lubos Dolezel 5 + 6 + Darling is free software: you can redistribute it and/or modify 7 + it under the terms of the GNU General Public License as published by 8 + the Free Software Foundation, either version 3 of the License, or 9 + (at your option) any later version. 10 + 11 + Darling is distributed in the hope that it will be useful, 12 + but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + GNU General Public License for more details. 15 + 16 + You should have received a copy of the GNU General Public License 17 + along with Darling. If not, see <http://www.gnu.org/licenses/>. 18 + */ 19 + #include "DefaultOutputAU.h" 20 + 21 + #pragma GCC visibility push(default) 22 + AUDIOCOMPONENT_ENTRY(AUOutputBaseFactory, DefaultOutputAU); 23 + #pragma GCC visibility pop 24 + 25 + enum { 26 + kOutputBus = 0, 27 + kInputBus 28 + }; 29 + 30 + DefaultOutputAU::DefaultOutputAU(AudioComponentInstance inInstance) 31 + : AUHAL(inInstance) 32 + { 33 + } 34 + 35 + OSStatus DefaultOutputAU::GetPropertyInfo(AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, UInt32& outDataSize, Boolean& outWritable) 36 + { 37 + OSStatus status = AUHAL::GetPropertyInfo(inID, inScope, inElement, outDataSize, outWritable); 38 + 39 + if (inID == kAudioOutputUnitProperty_CurrentDevice) 40 + outWritable = false; 41 + 42 + return status; 43 + } 44 + 45 + OSStatus DefaultOutputAU::SetProperty(AudioUnitPropertyID inID, AudioUnitScope inScope, 46 + AudioUnitElement inElement, const void* inData, UInt32 inDataSize) 47 + { 48 + switch (inID) 49 + { 50 + case kAudioOutputUnitProperty_CurrentDevice: 51 + return kAudioUnitErr_InvalidProperty; 52 + } 53 + return AUHAL::SetProperty(inID, inScope, inElement, inData, inDataSize); 54 + }
+32
src/CoreAudio/CoreAudioComponent/DefaultOutputAU.h
··· 1 + /* 2 + This file is part of Darling. 3 + 4 + Copyright (C) 2020 Lubos Dolezel 5 + 6 + Darling is free software: you can redistribute it and/or modify 7 + it under the terms of the GNU General Public License as published by 8 + the Free Software Foundation, either version 3 of the License, or 9 + (at your option) any later version. 10 + 11 + Darling is distributed in the hope that it will be useful, 12 + but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + GNU General Public License for more details. 15 + 16 + You should have received a copy of the GNU General Public License 17 + along with Darling. If not, see <http://www.gnu.org/licenses/>. 18 + */ 19 + 20 + #ifndef _CA_DEFAULT_OUTPUT_AU_H 21 + #define _CA_DEFAULT_OUTPUT_AU_H 22 + #include "AUHAL.h" 23 + 24 + class DefaultOutputAU : public AUHAL 25 + { 26 + public: 27 + DefaultOutputAU(AudioComponentInstance inInstance); 28 + OSStatus GetPropertyInfo(AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, UInt32& outDataSize, Boolean& outWritable) override; 29 + OSStatus SetProperty(AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, const void* inData, UInt32 inDataSize) override; 30 + }; 31 + 32 + #endif
+10
src/CoreAudio/CoreAudioComponent/SystemOutputAU.cpp
··· 34 34 AudioHardwareGetProperty(kAudioHardwarePropertyDefaultSystemOutputDevice, &propSize, &m_outputDevice); 35 35 } 36 36 37 + OSStatus SystemOutputAU::GetPropertyInfo(AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, UInt32& outDataSize, Boolean& outWritable) 38 + { 39 + OSStatus status = AUHAL::GetPropertyInfo(inID, inScope, inElement, outDataSize, outWritable); 40 + 41 + if (inID == kAudioOutputUnitProperty_CurrentDevice) 42 + outWritable = false; 43 + 44 + return status; 45 + } 46 + 37 47 OSStatus SystemOutputAU::SetProperty(AudioUnitPropertyID inID, AudioUnitScope inScope, 38 48 AudioUnitElement inElement, const void* inData, UInt32 inDataSize) 39 49 {
+1
src/CoreAudio/CoreAudioComponent/SystemOutputAU.h
··· 25 25 { 26 26 public: 27 27 SystemOutputAU(AudioComponentInstance inInstance); 28 + OSStatus GetPropertyInfo(AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, UInt32& outDataSize, Boolean& outWritable) override; 28 29 OSStatus SetProperty(AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, const void* inData, UInt32 inDataSize) override; 29 30 }; 30 31
+2 -2
src/CoreAudio/include/AudioToolbox/AudioComponent.h
··· 23 23 #include <CoreFoundation/CFDictionary.h> 24 24 #include <CoreServices/MacTypes.h> 25 25 26 - #ifndef __cplusplus 26 + #ifdef __cplusplus 27 27 extern "C" { 28 28 #endif 29 29 ··· 119 119 120 120 OSStatus AudioComponentValidate(AudioComponent component, CFDictionaryRef validationParams, AudioComponentValidationResult* result); 121 121 122 - #ifndef __cplusplus 122 + #ifdef __cplusplus 123 123 } 124 124 #endif 125 125