-
Notifications
You must be signed in to change notification settings - Fork 16
aubuf: preallocate mbuf frames to avoid malloc #55
base: main
Are you sure you want to change the base?
Conversation
@@ -42,7 +40,14 @@ static inline int aubuf_write(struct aubuf *ab, const uint8_t *p, size_t sz) | |||
|
|||
static inline int aubuf_append(struct aubuf *ab, struct mbuf *mb) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this API should probably be removed.
it contains no Samplerate or Channels info, which is needed now
/* Values for startup preallocation, can be tuned if needed */ | ||
enum { | ||
SRATE = 48000, /* Default sample rate in [Hz] */ | ||
CHANNELS = 2, /* Default number of channels */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to avoid hardcoded samplerate values inside the library ?
struct frame *f = frame_alloc(ab, SAMPSZ); | ||
if (!f) | ||
return ENOMEM; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of pre-allocating, is it possible to reuse the buffer instead ?
I'd like to vote again for this improvement (maybe simplified somehow). After planned v2.11.0? |
Yes, will take a look into this for next release. |
malloc and free calls should be avoided in realtime audio context as much as possible. this makes aubuf write/read calls ~1.8x times faster.