Audacity 3.2.0
Classes | Functions
AudioUnitUtils Namespace Reference

Classes

struct  Buffer
 
struct  Parameter
 
struct  ParameterInfo
 
struct  ParameterNameInfo
 
struct  Property
 
struct  RenderCallback
 
struct  StreamBasicDescription
 
struct  UserPreset
 

Functions

OSStatus GetFixedSizePropertyPtr (AudioUnit unit, AudioUnitPropertyID inID, void *pProperty, UInt32 size, AudioUnitScope inScope, AudioUnitElement inElement)
 Type-erased function to get an AudioUnit property of fixed size. More...
 
template<typename T >
OSStatus GetFixedSizeProperty (AudioUnit unit, AudioUnitPropertyID inID, T &property, AudioUnitScope inScope=kAudioUnitScope_Global, AudioUnitElement inElement=0)
 
OSStatus GetVariableSizePropertyPtr (AudioUnit unit, AudioUnitPropertyID inID, size_t minSize, void *&pObject, size_t &size, AudioUnitScope inScope, AudioUnitElement inElement)
 Type-erased function to get an AudioUnit property of variable size. More...
 
template<typename T >
OSStatus GetVariableSizeProperty (AudioUnit unit, AudioUnitPropertyID inID, PackedArray::Ptr< T > &pObject, AudioUnitScope inScope=kAudioUnitScope_Global, AudioUnitElement inElement=0)
 
OSStatus SetPropertyPtr (AudioUnit unit, AudioUnitPropertyID inID, const void *pProperty, UInt32 size, AudioUnitScope inScope, AudioUnitElement inElement)
 Type-erased function to set an AudioUnit property. More...
 
template<typename T >
OSStatus SetProperty (AudioUnit unit, AudioUnitPropertyID inID, const T &property, AudioUnitScope inScope=kAudioUnitScope_Global, AudioUnitElement inElement=0)
 

Function Documentation

◆ GetFixedSizeProperty()

template<typename T >
OSStatus AudioUnitUtils::GetFixedSizeProperty ( AudioUnit  unit,
AudioUnitPropertyID  inID,
T &  property,
AudioUnitScope  inScope = kAudioUnitScope_Global,
AudioUnitElement  inElement = 0 
)

Get an AudioUnit property of deduced type and fixed size, supplying most often used values as defaults for scope and element

Definition at line 40 of file AudioUnitUtils.h.

44 {
45 return GetFixedSizePropertyPtr(unit, inID,
46 &property, sizeof(property), inScope, inElement);
47 }
OSStatus GetFixedSizePropertyPtr(AudioUnit unit, AudioUnitPropertyID inID, void *pProperty, UInt32 size, AudioUnitScope inScope, AudioUnitElement inElement)
Type-erased function to get an AudioUnit property of fixed size.

References GetFixedSizePropertyPtr().

Referenced by AudioUnitWrapper::GetFixedSizeProperty(), AudioUnitInstance::GetLatency(), and AudioUnitWrapper::ParameterInfo::ParameterInfo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFixedSizePropertyPtr()

OSStatus AudioUnitUtils::GetFixedSizePropertyPtr ( AudioUnit  unit,
AudioUnitPropertyID  inID,
void *  pProperty,
UInt32  size,
AudioUnitScope  inScope,
AudioUnitElement  inElement 
)

Type-erased function to get an AudioUnit property of fixed size.

Definition at line 14 of file AudioUnitUtils.cpp.

17{
18 auto newSize = size;
19 auto result = AudioUnitGetProperty(unit, inID, inScope, inElement,
20 pProperty, &newSize);
21 assert(newSize <= size);
22 return result;
23}

References size.

Referenced by GetFixedSizeProperty().

Here is the caller graph for this function:

◆ GetVariableSizeProperty()

template<typename T >
OSStatus AudioUnitUtils::GetVariableSizeProperty ( AudioUnit  unit,
AudioUnitPropertyID  inID,
PackedArray::Ptr< T > &  pObject,
AudioUnitScope  inScope = kAudioUnitScope_Global,
AudioUnitElement  inElement = 0 
)

Get an AudioUnit property of deduced type and variable size, supplying most often used values as defaults for scope and element, and seating the raw pointer result into a smart pointer

Definition at line 62 of file AudioUnitUtils.h.

66 {
67 void *p{};
68 size_t size{};
69 auto result = GetVariableSizePropertyPtr(unit, inID,
70 sizeof(typename PackedArray::Traits<T>::header_type), p, size,
71 inScope, inElement);
72 if (!result)
73 // Construct PackedArray::Ptr
74 pObject = {
75 static_cast<T*>(p), // the pointer
76 size // the size that the deleter must remember
77 };
78 return result;
79 }
OSStatus GetVariableSizePropertyPtr(AudioUnit unit, AudioUnitPropertyID inID, size_t minSize, void *&pObject, size_t &size, AudioUnitScope inScope, AudioUnitElement inElement)
Type-erased function to get an AudioUnit property of variable size.

References GetVariableSizePropertyPtr(), and size.

Referenced by AudioUnitWrapper::GetVariableSizeProperty().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVariableSizePropertyPtr()

OSStatus AudioUnitUtils::GetVariableSizePropertyPtr ( AudioUnit  unit,
AudioUnitPropertyID  inID,
size_t  minSize,
void *&  pObject,
size_t &  size,
AudioUnitScope  inScope,
AudioUnitElement  inElement 
)

Type-erased function to get an AudioUnit property of variable size.

Warning: on success, performs a "naked" allocation in pObject! Else, nulls it.

Definition at line 25 of file AudioUnitUtils.cpp.

29{
30 size = 0;
31
32 // Query for statically unknown size of the property first
33 UInt32 dataSize;
34 auto result = AudioUnitGetPropertyInfo(unit, inID, inScope, inElement,
35 &dataSize, nullptr);
36 if (result)
37 return result;
38
39 // Allocate
40 auto newSize = std::max<size_t>(minSize, dataSize);
41 auto pObj = ::operator new(newSize);
42 auto cleanup = finally([&]{
43 // In case AudioUnitGetProperty fails
44 if (!pObject)
45 ::operator delete(pObj);
46 });
47
48 // Try to get the property
49 dataSize = newSize;
50 result =
51 AudioUnitGetProperty(unit, inID, inScope, inElement, pObj, &dataSize);
52 if (result) {
53 pObject = nullptr;
54 return result;
55 }
56
57 // Success
58 pObject = pObj;
59 size = newSize;
60 return result;
61}

References size.

Referenced by GetVariableSizeProperty().

Here is the caller graph for this function:

◆ SetProperty()

template<typename T >
OSStatus AudioUnitUtils::SetProperty ( AudioUnit  unit,
AudioUnitPropertyID  inID,
const T &  property,
AudioUnitScope  inScope = kAudioUnitScope_Global,
AudioUnitElement  inElement = 0 
)

Set an AudioUnit property of deduced type, supplying most often used values as defaults for scope and element

Definition at line 89 of file AudioUnitUtils.h.

93 {
94 return SetPropertyPtr(unit, inID,
95 &property, sizeof(property), inScope, inElement);
96 }
OSStatus SetPropertyPtr(AudioUnit unit, AudioUnitPropertyID inID, const void *pProperty, UInt32 size, AudioUnitScope inScope, AudioUnitElement inElement)
Type-erased function to set an AudioUnit property.

References SetPropertyPtr().

Referenced by AudioUnitWrapper::SetProperty().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetPropertyPtr()

OSStatus AudioUnitUtils::SetPropertyPtr ( AudioUnit  unit,
AudioUnitPropertyID  inID,
const void *  pProperty,
UInt32  size,
AudioUnitScope  inScope,
AudioUnitElement  inElement 
)

Type-erased function to set an AudioUnit property.

Definition at line 63 of file AudioUnitUtils.cpp.

66{
67 return AudioUnitSetProperty(unit, inID, inScope, inElement,
68 pProperty, size);
69}

References size.

Referenced by SetProperty().

Here is the caller graph for this function: