Data buffers placed in low latency memory leads to lower MIPS consumption and hence there will be numerous request for low latency memory. As there is limited low latency memory, the allocator allocates in the next available higher latency memory whenever the requested low latency memory is not available. Hence the memory statistics compiled with the requested latency might not be correct.
An additional argument is passed to the memory allocator APIs to return the allocated latency for the requested data segment and this assigned latency level is used for calculating the memory usage at each latency level.
The memory allocator APIs in the following xAF types header files are changed as shown below:
XafTypesC.h:
typedef void* (*memAlloc)(unsigned int size, unsigned int align, enum xAF_HEAP, enum xAF_memLatency requestedLatency, xAF_memLatency* assignedLatency);
XafTypes.h:
typedef void* (&memAllocRef)(unsigned int size, unsigned int align, enum xAF_HEAP heap, enum xAF_memLatency requestedLatency, xAF_memLatency* assignedLatency);
In the below classes, the APIs related to memory allocation are changed as given below:
CAudioCoreBase:
void* m_Allocator(unsigned int size, unsigned int align, enum xAF_HEAP heap, enum xAF_memLatency requestedLatency, xAF_memLatency* assignedLatency);
InitializationMsgParser:
void* m_memAlloc(unsigned int size, unsigned int align, enum xAF_HEAP heap, enum xAF_memLatency requestedLatency, xAF_memLatency* assignedLatency);
CAudioProcessingBase:
void* heapCreator(unsigned int size, unsigned int align, enum xAF_HEAP heap, enum xAF_memLatency requestedLatency, xAF_memLatency* assignedLatency);
ChunkParserMem:
void* m_memAlloc(unsigned int size, unsigned int align, enum xAF_HEAP heap, enum xAF_memLatency requestedLatency, xAF_memLatency* assignedLatency);
The template to create object is also modified as below:
createObject(void* (*heapCreator)(unsigned int size, unsigned int alignment, enum xAF_HEAP heap, enum xAF_memLatency requestedLatency, xAF_memLatency* assignedLatency)) {}
In addition, following extern APIs used outside the framework are also modified:
extern CAudioObject* createAudioObject(int id, void* (*heapCreator)(unsigned int size, unsigned int alignment, enum xAF_HEAP heap, enum xAF_memLatency requestedLatency, xAF_memLatency* assignedLatency));
extern CAudioObjectToolbox* createAudioObjectToolbox(int id, void*(*heapCreator)(unsigned int size, unsigned int alignment, enum xAF_HEAP heap, enum xAF_memLatency requestedLatency, xAF_memLatency* assignedLatency));