Added an API to access the memory usage
This commit is contained in:
parent
d849d4f8b7
commit
9f96968169
3 changed files with 46 additions and 0 deletions
20
src/sfizz.h
20
src/sfizz.h
|
|
@ -305,6 +305,26 @@ void sfizz_set_num_voices(sfizz_synth_t* synth, int num_voices);
|
|||
*/
|
||||
int sfizz_get_num_voices(sfizz_synth_t* synth);
|
||||
|
||||
/**
|
||||
* @brief Get the number of allocated buffers from the synth.
|
||||
*
|
||||
* @param synth The synth
|
||||
*
|
||||
* @return The number of buffers held by the synth
|
||||
*/
|
||||
int sfizz_get_num_buffers(sfizz_synth_t* synth);
|
||||
/**
|
||||
* @brief Get the number of bytes allocated from the synth. Note that this
|
||||
* value can be less than the actual memory usage since it only
|
||||
* counts the buffer objects managed by sfizz.
|
||||
*
|
||||
* @param synth The synth
|
||||
*
|
||||
* @return The number of bytes held by the synth in buffers;
|
||||
*/
|
||||
int sfizz_get_num_bytes(sfizz_synth_t* synth);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -310,6 +310,20 @@ public:
|
|||
* @return Oversampling
|
||||
*/
|
||||
uint32_t getPreloadSize() const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Gets the number of allocated buffers.
|
||||
*
|
||||
* @return The allocated buffers.
|
||||
*/
|
||||
int getAllocatedBuffers() const noexcept { return Buffer<float>::counter().getNumBuffers(); }
|
||||
|
||||
/**
|
||||
* @brief Gets the number of bytes allocated through the buffers
|
||||
*
|
||||
* @return The allocated bytes.
|
||||
*/
|
||||
int getAllocatedBytes() const noexcept { return Buffer<float>::counter().getTotalBytes(); }
|
||||
protected:
|
||||
/**
|
||||
* @brief The parser callback; this is called by the parent object each time
|
||||
|
|
|
|||
|
|
@ -192,6 +192,18 @@ int sfizz_get_num_voices(sfizz_synth_t* synth)
|
|||
return self->getNumVoices();
|
||||
}
|
||||
|
||||
int sfizz_get_num_buffers(sfizz_synth_t* synth)
|
||||
{
|
||||
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
||||
return self->getAllocatedBuffers();
|
||||
}
|
||||
|
||||
int sfizz_get_num_bytes(sfizz_synth_t* synth)
|
||||
{
|
||||
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
||||
return self->getAllocatedBytes();
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue