this repo has no description
1
fork

Configure Feed

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

AudioToolbox: Improve AudioUnit dispatch template trickery

+12 -8
+12 -8
src/CoreAudio/AudioToolbox/AUComponent.cpp
··· 27 27 const CFStringRef kAudioComponentRegistrationsChangedNotification = CFSTR("AudioComponentRegistrationsChangedNotification"); 28 28 const CFStringRef kAudioComponentInstanceInvalidationNotification = CFSTR("AudioComponentInstanceInvalidationNotification"); 29 29 30 - inline static void assignParams(ComponentParameters* cp, size_t totalArgs, size_t argumentIndex) 31 - { 32 - } 33 - 34 30 template <typename First, typename... Rest> 35 31 void assignParams(ComponentParameters* cp, size_t totalArgs, size_t argumentIndex, First arg, Rest... rest) 36 32 { ··· 39 35 #else 40 36 cp->params[totalArgs - argumentIndex - 1] = long(arg); 41 37 #endif 42 - assignParams(cp, totalArgs, argumentIndex+1, rest...); 38 + 39 + if constexpr (sizeof...(Rest) > 0) 40 + assignParams(cp, totalArgs, argumentIndex+1, rest...); 43 41 } 44 42 45 43 template <typename ...Args> ··· 57 55 else 58 56 { 59 57 ComponentParameters* cp = (ComponentParameters*) alloca(sizeof(ComponentParameters) + sizeof...(Args) * sizeof(long)); 60 - assignParams(cp, sizeof...(Args)+1, 0, inUnit); 61 - assignParams(cp, sizeof...(Args)+1, 1, args...); 62 - cp->paramSize = (sizeof...(Args)+1) * sizeof(long); 58 + constexpr size_t totalArgs = sizeof...(Args)+1; 59 + 60 + assignParams(cp, totalArgs, 0, inUnit); 61 + 62 + if constexpr (totalArgs > 1) 63 + assignParams(cp, totalArgs, 1, args...); 64 + 65 + cp->paramSize = totalArgs * sizeof(long); 63 66 cp->what = sel; 64 67 cp->flags = 0; 68 + 65 69 return CallComponentDispatch(cp); 66 70 } 67 71 }